Recherche avancée

Médias (1)

Mot : - Tags -/book

Autres articles (42)

Sur d’autres sites (8082)

  • Play drm protected video

    10 mars 2023, par Aaditya Kumar

    I downloaded video from this link :-

    


    https://zee5vod.akamaized.net/drm1/elemental/dash/TV_SHOWS/ZEE_TV/March2021/15032021/Seamless/BQC_Kumkum_Bhagya_CS_Ep1787_Seamless_15032021_hi_a2808b31106f106303f084b9943d5986/manifest1080lowp/1080lowp_000000649.mp4

    


    


    but when i am playing video then the video is not supported

    


    


    someone help that how can i able to play this video

    


  • RTMP live stream directly from NVENC encoder

    16 novembre 2018, par rnd

    I am trying to create a live RTMP stream containing the animation generated with NVIDIA OptiX. The stream is to be received by nginx + rtmp module and broadcasted in MPEG-DASH format. Full chain up to dash.js player is working if the video is first saved to .flv file and then I send it with ffmpeg without any reformatting using command :

    



    ffmpeg -re -i my_video.flv -c:v copy -f flv rtmp://x.x.x.x:1935/dash/test


    



    But I want to stream directly from the code. And with this I am failng... Nginx logs an error "dash : invalid avcc received (2 : No such file or directory)". Then it seems to receive the stream correctly (segments are rolling, dash manifest is there), however the stream is not possible to play in the browser.

    



    I can see only one difference in the manifest between direct stream and stream from file. Codecs attribute of the representation in the direct stream is missed : codecs="avcc1.000000" instead of "avc1.640028" which I get when streaming from file.

    



    My code opens the stream :

    



    av_register_all();
AVOutputFormat* fmt = av_guess_format("flv",
file_name, nullptr);
fmt->video_codec = AV_CODEC_ID_H264;

AVFormatContext* _oc;
avformat_alloc_output_context2(&_oc, fmt, nullptr, "rtmp://x.x.x.x:1935/dash/test");

AVStream* _vs = avformat_new_stream(_oc, nullptr);
_vs->id = 0;
_vs->time_base = AVRational { 1, 25 };
_vs->avg_frame_rate = AVRational{ 25, 1 };

AVCodecParameters *vpar = _vs->codecpar;
vpar->codec_id = fmt->video_codec;
vpar->codec_type = AVMEDIA_TYPE_VIDEO;
vpar->format = AV_PIX_FMT_YUV420P;
vpar->profile = FF_PROFILE_H264_HIGH;
vpar->level = _level;
vpar->width = _width;
vpar->height = _height;
vpar->bit_rate = _avg_bitrate;

avio_open(&_oc->pb, _oc->filename, AVIO_FLAG_WRITE);
avformat_write_header(_oc, nullptr);


    



    Width, height, bitrate, level and profile I get from NVENC encoder settings. I also do the error checking, ommited here. Then I have a loop writing each encoded packets, with IDR frames etc all prepared on the fly with NVENC. The loop body is :

    



    auto & pkt_data = _packets[i];
AVPacket pkt = { 0 };
av_init_packet(&pkt);
pkt.pts = av_rescale_q(_n_frames++, AVRational{ 1, 25 }, _vs->time_base);
pkt.duration = av_rescale_q(1, AVRational{ 1, 25 }, _vs->time_base);
pkt.dts = pkt.pts;
pkt.stream_index = _vs->index;
pkt.data = pkt_data.data();
pkt.size = (int)pkt_data.size();

if (!memcmp(pkt_data.data(), "\x00\x00\x00\x01\x67", 5))
{
    pkt.flags |= AV_PKT_FLAG_KEY;
}

av_write_frame(_oc, &pkt);


    



    Obviously ffmpeg is writing avcc code somewhere... I have no clue where to add this code so the RTMP server can recognize it. Or I am missing something else ?

    



    Any hint greatly appreciated, folks !

    


  • RTMP live stream directly from NVENC encoder

    16 novembre 2018, par rnd

    I am trying to create a live RTMP stream containing the animation generated with NVIDIA OptiX. The stream is to be received by nginx + rtmp module and broadcasted in MPEG-DASH format. Full chain up to dash.js player is working if the video is first saved to .flv file and then I send it with ffmpeg without any reformatting using command :

    ffmpeg -re -i my_video.flv -c:v copy -f flv rtmp://x.x.x.x:1935/dash/test

    But I want to stream directly from the code. And with this I am failng... Nginx logs an error "dash : invalid avcc received (2 : No such file or directory)". Then it seems to receive the stream correctly (segments are rolling, dash manifest is there), however the stream is not possible to play in the browser.

    I can see only one difference in the manifest between direct stream and stream from file. Codecs attribute of the representation in the direct stream is missed : codecs="avcc1.000000" instead of "avc1.640028" which I get when streaming from file.

    My code opens the stream :

    av_register_all();
    AVOutputFormat* fmt = av_guess_format("flv",
    file_name, nullptr);
    fmt->video_codec = AV_CODEC_ID_H264;

    AVFormatContext* _oc;
    avformat_alloc_output_context2(&_oc, fmt, nullptr, "rtmp://x.x.x.x:1935/dash/test");

    AVStream* _vs = avformat_new_stream(_oc, nullptr);
    _vs->id = 0;
    _vs->time_base = AVRational { 1, 25 };
    _vs->avg_frame_rate = AVRational{ 25, 1 };

    AVCodecParameters *vpar = _vs->codecpar;
    vpar->codec_id = fmt->video_codec;
    vpar->codec_type = AVMEDIA_TYPE_VIDEO;
    vpar->format = AV_PIX_FMT_YUV420P;
    vpar->profile = FF_PROFILE_H264_HIGH;
    vpar->level = _level;
    vpar->width = _width;
    vpar->height = _height;
    vpar->bit_rate = _avg_bitrate;

    avio_open(&_oc->pb, _oc->filename, AVIO_FLAG_WRITE);
    avformat_write_header(_oc, nullptr);

    Width, height, bitrate, level and profile I get from NVENC encoder settings. I also do the error checking, ommited here. Then I have a loop writing each encoded packets, with IDR frames etc all prepared on the fly with NVENC. The loop body is :

    auto & pkt_data = _packets[i];
    AVPacket pkt = { 0 };
    av_init_packet(&pkt);
    pkt.pts = av_rescale_q(_n_frames++, AVRational{ 1, 25 }, _vs->time_base);
    pkt.duration = av_rescale_q(1, AVRational{ 1, 25 }, _vs->time_base);
    pkt.dts = pkt.pts;
    pkt.stream_index = _vs->index;
    pkt.data = pkt_data.data();
    pkt.size = (int)pkt_data.size();

    if (!memcmp(pkt_data.data(), "\x00\x00\x00\x01\x67", 5))
    {
       pkt.flags |= AV_PKT_FLAG_KEY;
    }

    av_write_frame(_oc, &pkt);

    Obviously ffmpeg is writing avcc code somewhere... I have no clue where to add this code so the RTMP server can recognize it. Or I am missing something else ?

    Any hint greatly appreciated, folks !