Recherche avancée

Médias (91)

Autres articles (76)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

  • Contribute to a better visual interface

    13 avril 2011

    MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
    Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.

Sur d’autres sites (6055)

  • How do you properly free a BitStreamFilter (bsf) without getting a double free error ?

    19 janvier 2021, par Alexis Wilke

    I'm trying to write a C++ class handling MP4 movies via ffmpeg.

    


    First I created a couple of functions to use with std::unique<>() so that way things get released even on exceptions.

    


    However, I get a double free when I try to free the BitStreamFilter object, yet the documentation clearly says that each av_bsf_alloc() must be paired with an av_bsf_free() call.

    


    


    @param ctx a pointer into which the pointer to the newly-allocated context
will be written. It must be freed with av_bsf_free() after the
filtering is done.

    


    


    Note : emphasis mine.

    


    However, at the time I call the avformat_close_input() I get a double free error, even if I haven't used the two contexts for anything !? I'm thinking that there may be a packet that both allocate and both try to free. But since these two contexts are not directly connected, I really don't understand how they end up freeing something twice.

    


    Below is code which reproduce the error (at least on an amd64 platform). Once compiled, you can just execute it. Make sure to specify a filename as in :

    


    ./ffmpeg_demuxer_test mymovie.mp4


    


    I used the following command to compile & link the code :

    


    $ /usr/bin/c++ -std=c++17 -DDEBUG -D_DEBUG -D_GLIBCXX_ASSERTIONS -g -O0 \
    -fsanitize=address -fsanitize=enum -fsanitize=unreachable \
    -o ffmpeg_demuxer_test ffmpeg_demuxer_test.cpp \
    -lavformat -lavcodec


    


    Notice the -fsanitize=... options to capture errors such as a double free error.

    


    Here is the code :

    


    extern "C" {&#xA;#include    <libavformat></libavformat>avformat.h>&#xA;#include    <libavformat></libavformat>avio.h>&#xA;#include    <libavcodec></libavcodec>avcodec.h>&#xA;}&#xA;#include    <iostream>&#xA;#include    <memory>&#xA;&#xA;&#xA;void ffmpeg_demuxer_avformat_context_free(AVFormatContext * context)&#xA;{&#xA;    if(context != nullptr) avformat_close_input(&amp;context);&#xA;}&#xA;&#xA;void ffmpeg_demuxer_av_bsf_free(AVBSFContext * context)&#xA;{&#xA;    if(context != nullptr) av_bsf_free(&amp;context);&#xA;}&#xA;&#xA;&#xA;int main(int argc, char * argv [])&#xA;{&#xA;    if(argc != 2)&#xA;    {&#xA;        std::cout &lt;&lt; "Usage: " &lt;&lt; argv[0] &lt;&lt; " movie.mp4" &lt;&lt; std::endl;&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // init the AV libraries&#xA;    //&#xA;    av_register_all();&#xA;    avformat_network_init();&#xA;&#xA;    // allocate the AVFormatContext&#xA;    //&#xA;    AVFormatContext * format_context(nullptr);&#xA;    int const r1(avformat_open_input(&#xA;                  &amp;format_context&#xA;                , argv[1]&#xA;                , nullptr           // input format&#xA;                , nullptr));        // options&#xA;    if(r1 != 0&#xA;    || format_context == nullptr)&#xA;    {&#xA;        throw std::bad_alloc();&#xA;    }&#xA;&#xA;    auto f_format_context = std::unique_ptr&lt;&#xA;              AVFormatContext&#xA;            , decltype(&amp;ffmpeg_demuxer_avformat_context_free)>(&#xA;                      format_context&#xA;                    , &amp;ffmpeg_demuxer_avformat_context_free);&#xA;&#xA;&#xA;    // now allocate a stream&#xA;    //&#xA;    if(avformat_find_stream_info(f_format_context.get(), nullptr) &lt; 0)&#xA;    {&#xA;        throw std::runtime_error("ffmpeg: Could not find stream info");&#xA;    }&#xA;&#xA;    auto f_video_stream_index = av_find_best_stream(&#xA;              f_format_context.get()&#xA;            , AVMEDIA_TYPE_VIDEO&#xA;            , -1            // wanted stream (any)&#xA;            , -1            // related stream (none)&#xA;            , nullptr       // AVCodec *&#xA;            , 0);           // flags&#xA;    if(f_video_stream_index &lt; 0)&#xA;    {&#xA;        throw std::runtime_error("ffmpeg: Could not find stream in input file");&#xA;    }&#xA;    if(static_cast<unsigned int="int">(f_video_stream_index) >= f_format_context->nb_streams)&#xA;    {&#xA;        throw std::range_error("ffmpeg: Stream index out of range");&#xA;    }&#xA;&#xA;    auto f_stream = f_format_context->streams[f_video_stream_index];&#xA;&#xA;    auto f_video_codec = f_stream->codecpar->codec_id;&#xA;&#xA;    int f_bit_depth(0);&#xA;    switch(f_stream->codecpar->format)&#xA;    {&#xA;    case AV_PIX_FMT_YUV420P10LE:&#xA;        f_bit_depth = 10;&#xA;        break;&#xA;&#xA;    case AV_PIX_FMT_YUV420P12LE:&#xA;        f_bit_depth = 12;&#xA;        break;&#xA;&#xA;    default:&#xA;        f_bit_depth = 8;&#xA;        break;&#xA;&#xA;    }&#xA;&#xA;    bool f_mp4_h264 = f_video_codec == AV_CODEC_ID_H264 &amp;&amp; (&#xA;               strcmp(f_format_context->iformat->long_name, "QuickTime / MOV") == 0&#xA;            || strcmp(f_format_context->iformat->long_name, "FLV (Flash Video)") == 0&#xA;            || strcmp(f_format_context->iformat->long_name, "Matroska / WebM") == 0&#xA;        );&#xA;&#xA;    if(f_mp4_h264)&#xA;    {&#xA;        AVBitStreamFilter const * bsf_stream_filter(av_bsf_get_by_name("h264_mp4toannexb"));&#xA;        if(bsf_stream_filter == nullptr)&#xA;        {&#xA;            throw std::runtime_error("av_bsf_get_by_name(\"h264_mp4toannexb\") failed");&#xA;        }&#xA;        AVBSFContext * bsf_context(nullptr);&#xA;        int const r2(av_bsf_alloc(bsf_stream_filter, &amp;bsf_context));&#xA;        if(r2 &lt; 0&#xA;        || bsf_context == nullptr)&#xA;        {&#xA;            throw std::bad_alloc();&#xA;        }&#xA;        auto f_bsf_context = std::unique_ptr&lt;&#xA;                  AVBSFContext&#xA;                , decltype(&amp;ffmpeg_demuxer_av_bsf_free)>(&#xA;                          bsf_context&#xA;                        , &amp;ffmpeg_demuxer_av_bsf_free);&#xA;        f_bsf_context->par_in = f_stream->codecpar;&#xA;        if(av_bsf_init(f_bsf_context.get()) &lt; 0)&#xA;        {&#xA;            throw std::runtime_error("av_bsf_init() failed");&#xA;        }&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;</unsigned></memory></iostream>

    &#xA;

    So. Am I misreading the documentation or misusing one of the free/close function ? I don't think that the AVBSFContext itself gets released when I close the AVFormatContext, but I may be mistaken ?

    &#xA;

    I won't put "C" as a tag since it will get removed even though this applies to C. It's not because I use C++ that I get a double free (i.e. it happens in the ffmpeg C library).

    &#xA;

  • Avoiding ffmpeg audio drift for live dash output

    22 mai 2021, par mdale

    Have people experienced playback drift with ffmpeg based dash segment generation ? For example :

    &#xA;

    ffmpeg -threads 2 -re -fflags &#x2B;genpts -stream_loop -1 -i AVSyncTest.mp4 \&#xA;-af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" \&#xA;-c:v:0 libx264 \&#xA;-pix_fmt:0 yuv420p \&#xA;-preset:0 medium \&#xA;-a53cc:0 1 \&#xA;-nal-hrd:0 cbr \&#xA;-x264opts:0 scenecut=-1:rc_lookahead=0 -b:v:0 5000k -bufsize:0 500k \&#xA;-force_key_frames:0 "expr:gte(t,n_forced*2)" \&#xA;-bf:0 8 \&#xA;-r 30 \&#xA;-c:a:0 aac  -ar 48000 \&#xA;-b:a:1 96k  \&#xA;-f tee -map 0:v \&#xA;-map 0:a "[f=dash:media_seg_name=&#x27;chunk-stream_\$RepresentationID\$-\$Number%05d\$.mp4&#x27;:init_seg_name=&#x27;init-stream_\$RepresentationID\$.mp4&#x27;:seg_duration=2:utc_timing_url=https\\\://time.akamai.com\\?iso:remove_at_exit=0:use_timeline=0:http_user_agent=ffmpeg_encoder.0:streaming=1:index_correction=1:timeout=1:dash_segment_type=mp4:method=PUT:http_persistent=1:adaptation_sets=&#x27;id=0,streams=v\:0 id=1,streams=a&#x27; ]http://localhost:5000/out.mpd "&#xA;

    &#xA;

    After a bit of playback it starts audio starts to drift. Analysis of the moof (with tools like mp4box) shows 1024 sample size with 93 Moofs with Moof->traf->default_sample_duration=1024 at 48000 sample rate giving segment duration of 1.984 seconds with every 3rd segment or so with 92 Moofs with duration of 1.962 … While each segment starts aligned ( if you reset playback you get alignment) it drifts against continuous playback.

    &#xA;

    Other examples like Akamai’s public stream. show 94 Moofs or 2.005 duration with every 3rd segment or so at the 1.984 duration. (what one would want)

    &#xA;

    Akamai’s (presumably ffmepg based) stream is averaging out to the 2s target where the above ffmpeg command is not …

    &#xA;

  • avcodec/hashtable : Only free buffer if there is buffer to free

    3 juin, par Andreas Rheinhardt
    avcodec/hashtable : Only free buffer if there is buffer to free
    

    Reviewed-by : Emma Worley <emma@emma.gg>
    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

    • [DH] libavcodec/hashtable.c