Recherche avancée

Médias (91)

Autres articles (53)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Possibilité de déploiement en ferme

    12 avril 2011, par

    MediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
    Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)

Sur d’autres sites (10600)

  • ffmpeg : libavfilter API av_buffersink_get_frame returns alway EAGAIN

    29 juin 2024, par aculnaig

    I want to resize an image with libavfilter C API through zscale filter and libplacebo filter but no matter how I call av_buffersink_get_frame, it always returns EAGAIN and no data is filled in the filtered_frame.

    


    #include &#xA;#include &#xA;#include &#xA;#include &#xA;#include &#xA;&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavfilter></libavfilter>avfilter.h>&#xA;#include <libavfilter></libavfilter>buffersrc.h>&#xA;#include <libavfilter></libavfilter>buffersink.h>&#xA;#include <libavutil></libavutil>log.h>&#xA;&#xA;int main(int argc, char **argv)&#xA;{&#xA;    if (argc != 2) {&#xA;        fprintf(stderr, "usage: %s <filename>\n", argv[0]);&#xA;        exit(EXIT_FAILURE);&#xA;    }&#xA;&#xA;    const char *src_name = argv[1];&#xA;    const char *dst_name = basename(src_name);&#xA;    int ret = 0;&#xA;&#xA;    const enum AVPixelFormat src_format = AV_PIX_FMT_YUV422P;&#xA;&#xA;    av_log_set_level(AV_LOG_TRACE);&#xA;&#xA;    AVFormatContext *fmt_ctx = avformat_alloc_context();&#xA;    if (fmt_ctx == NULL) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avformat_alloc_context(): failed.\n");&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;    if ((ret = avformat_open_input(&amp;fmt_ctx, src_name, NULL, NULL)) != 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avformat_open_input(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;&#xA;    AVCodecContext *dec_ctx;&#xA;    AVCodec *dec;&#xA;&#xA;    if ((ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &amp;dec, 0)) &lt; 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "av_find_best_stream(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;    dec_ctx = avcodec_alloc_context3(dec);&#xA;    if (dec_ctx == NULL) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avcodec_alloc_context3(): failed.\n");&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;    if ((ret = avcodec_open2(dec_ctx, dec, NULL)) &lt; 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avcodec_open2(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;&#xA;    AVFrame *frame = av_frame_alloc();&#xA;    if (frame == NULL) {&#xA;        av_log(NULL, AV_LOG_TRACE, "av_frame_alloc(): failed.\n");&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;    AVPacket *packet = av_packet_alloc();&#xA;    if (packet == NULL) {&#xA;        av_log(NULL, AV_LOG_TRACE, "av_packet_alloc(): failed.\n");&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;&#xA;    if ((ret = av_read_frame(fmt_ctx, packet)) &lt; 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "av_read_frame(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;    ret = avcodec_send_packet(dec_ctx, packet);&#xA;    if (ret == AVERROR(EAGAIN)) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avcodec_send_packet(): %s.\n", av_err2str(ret));&#xA;        avcodec_receive_frame(dec_ctx, frame);&#xA;        avcodec_send_packet(dec_ctx, packet);&#xA;    }&#xA;    &#xA;    if ((ret = avcodec_receive_frame(dec_ctx, frame)) &lt; 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avcodec_receive_frame(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;    av_packet_unref(packet);&#xA;&#xA;    av_log(NULL, AV_LOG_TRACE, "filename: %s, w: %d, h: %d, fmt: %d\n", src_name, frame->width, frame->height, frame->format);&#xA;&#xA;    AVFilterGraph *filter_graph = avfilter_graph_alloc();&#xA;&#xA;    char buffersrc_args[512];&#xA;    snprintf(buffersrc_args, sizeof(buffersrc_args), "video_size=%dx%d:pix_fmt=%d:time_base=1/25", frame->width, frame->height, frame->format); &#xA;&#xA;    AVFilterContext *buffersrc_ctx;&#xA;    if ((ret = avfilter_graph_create_filter(&amp;buffersrc_ctx, avfilter_get_by_name("buffer"), NULL, buffersrc_args, NULL, filter_graph)) &lt; 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avfilter_graph_create_filter(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;&#xA;    char libplacebo_args[512];&#xA;    snprintf(libplacebo_args, sizeof(libplacebo_args), "format=yuv420p:colorspace=bt470bg:color_primaries=bt709:color_trc=iec61966-2-1:range=pc:w=(iw/2):h=(ih/2):downscaler=none:dithering=none");&#xA;    AVFilterContext *libplacebo_ctx;&#xA;    if ((ret = avfilter_graph_create_filter(&amp;libplacebo_ctx, avfilter_get_by_name("libplacebo"), NULL, libplacebo_args, NULL, filter_graph)) &lt; 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avfilter_graph_create_filter(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;&#xA;    AVFilterContext *buffersink_ctx;&#xA;    if ((ret = avfilter_graph_create_filter(&amp;buffersink_ctx, avfilter_get_by_name("buffersink"), NULL, NULL, NULL, filter_graph)) &lt; 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avfilter_graph_create_filter(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;&#xA;    if ((ret = avfilter_link(buffersrc_ctx, 0, libplacebo_ctx, 0)) != 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avfilter_link(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;    if ((ret = avfilter_link(libplacebo_ctx, 0, buffersink_ctx, 0)) != 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avfilter_link(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;    &#xA;    if ((ret = avfilter_graph_config(filter_graph, NULL)) &lt; 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "avfilter_graph_config(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;&#xA;    AVFrame *filtered_frame = av_frame_alloc();&#xA;    if (filtered_frame == NULL) {&#xA;        av_log(NULL, AV_LOG_TRACE, "av_frame_alloc(): failed.\n");&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;    if ((ret = av_buffersrc_add_frame(buffersrc_ctx, frame)) &lt; 0) {&#xA;        av_log(NULL, AV_LOG_TRACE, "av_buffersrc_add_frame(): %s.\n", av_err2str(ret));&#xA;        exit(EXIT_SUCCESS);&#xA;    }&#xA;    &#xA;    while (1) {&#xA;        int ret = av_buffersink_get_frame(buffersink_ctx, filtered_frame);&#xA;        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;            break;&#xA;        if (ret &lt; 0) {&#xA;            av_log(NULL, AV_LOG_TRACE, "av_buffersink_get_frame(): %s.\n", av_err2str(ret));&#xA;            exit(EXIT_FAILURE);&#xA;        }    &#xA;    }&#xA;&#xA;    av_log(NULL, AV_LOG_TRACE, "filename: %s, w: %d, h: %d, f: %d\n", dst_name, filtered_frame->width, filtered_frame->height, filtered_frame->format);&#xA;&#xA;    AVCodecContext *enc_ctx;&#xA;    AVCodec *enc;&#xA;    AVPacket *enc_packet = av_packet_alloc();&#xA;&#xA;    enc = avcodec_find_encoder_by_name("mjpeg");&#xA;    enc_ctx = avcodec_alloc_context3(enc);&#xA;    enc_ctx->width = filtered_frame->width;&#xA;    enc_ctx->height = filtered_frame->height;&#xA;    enc_ctx->bit_rate = dec_ctx->bit_rate * 1024;&#xA;    enc_ctx->time_base = (AVRational) {1, 25};&#xA;    enc_ctx->framerate = (AVRational) {25, 1};&#xA;    enc_ctx->pix_fmt = filtered_frame->format;&#xA;    enc_ctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;&#xA;    enc_ctx->compression_level = 0;&#xA;    enc_ctx->color_range = AVCOL_RANGE_JPEG;&#xA;&#xA;    avcodec_open2(enc_ctx, enc, NULL);&#xA;&#xA;    avcodec_send_frame(enc_ctx, filtered_frame);&#xA;    avcodec_receive_packet(enc_ctx, enc_packet);&#xA;&#xA;    FILE *dst_file = fopen(dst_name, "wb");&#xA;    fwrite(enc_packet->data, 1, enc_packet->size, dst_file);&#xA;    fclose(dst_file);&#xA;&#xA;    av_packet_unref(enc_packet);&#xA;    av_frame_free(&amp;frame);&#xA;    av_frame_free(&amp;filtered_frame);&#xA;    &#xA;    avfilter_graph_free(&amp;filter_graph);&#xA;&#xA;    avformat_close_input(&amp;fmt_ctx);&#xA;    avformat_free_context(fmt_ctx);&#xA;    &#xA;    exit(EXIT_SUCCESS);&#xA;}&#xA;</filename>

    &#xA;

    and here are the logs

    &#xA;

    https://pastebin.com/bbMKHcdj

    &#xA;

    PS : the logs were so many I could paste in stackoverflow

    &#xA;

  • FFmpeg - avcodec_receive_frame returns AVERROR(EAGAIN)

    8 novembre 2019, par Jinx

    I’m using an QOpenGL widget to draw frames. However, I’m struggling to get frames by using avcodec_receive_frame. It ended within the block else if (ret == AVERROR(EAGAIN)) and returned -11. I have no idea what made this happen. Also I checked that codecs were fine, so I guess the problem wasn’t caused by codecs.

    MyDemux.cpp

    AVPacket* MyDemux::allocatePacket()
    {
       AVPacket* packet = av_packet_alloc();
       return packet;
    }

    AVFrame* MyDemux::allocateFrame()
    {
       AVFrame* frame = av_frame_alloc();
       return frame;
    }

    int MyDemux::readFrame(AVPacket* packet)
    {
       mux.lock();
       if (!formatCtx) {
           std::cout &lt;&lt; "formaetCtx is null" &lt;&lt; std::endl;
           mux.unlock();
           return -1;
       }
       int ret = av_read_frame(formatCtx, packet);
       if (ret == AVERROR_EOF) {
           return -2;
       }
       if (ret != 0) {
           mux.unlock();
           av_packet_free(&amp;packet);
           return -1;
       }
       media_type = packet->stream_index;
       mux.unlock();
       return 0;
    }

    MyDecode.cpp

    void MyDecode::decode(AVFrame* frame, AVPacket* packet)
    {
       int ret;
       ret = avcodec_send_packet(codecCtx, packet); // this returned 0
       while (ret == 0) {
           ret = avcodec_receive_frame(codecCtx, frame); // this returned -11
           if (ret == AVERROR(EINVAL)) {
               std::cout &lt;&lt; "codec issue" &lt;&lt; std::endl;
               av_frame_free(&amp;frame);
               return;
           }
           else if (ret == AVERROR(EAGAIN)) { // program ends here
               std::cout &lt;&lt; "output is not available this state" &lt;&lt; std::endl;
               av_frame_free(&amp;frame);
               return;
           }
           else if (ret == AVERROR(EINVAL)) {
               std::cout &lt;&lt; "no more frames" &lt;&lt; std::endl;
               av_frame_free(&amp;frame);
               return;
           }
       }
    }

    main.cpp

    class MyThread : public QThread
    {
    public:

       MyDemux demux;
       MyDecode video_decode;
       myDecode audio_decode;
       MyVideoWidget* videoWidget;
       AVPacket* packet;
       AVFrame* frame;

       void initThread()
       {
           char* url = "demo.mp4";
           demux.openFile(url);
           video_decode.openCodec(demux.copy_video_codec_par());
           audio_decode.openCodec(demux.copy_audio_codec_par());
           packet = demux.allocatePacket();
           frame = demux.allocateFrame();
       }
       void run()
       {
           while (demux.readFrame(packet) != -2) {
               if (demux.get_media_type() == 0) {
                   video_decode.decode(frame, packet);
                   videoWidget->paintFrame(frame);
               }
               else if (demux.get_media_type() == 1) {
               }
           }
           video_decode.decode(frame, nullptr);
           demux.clear();
           demux.close();
       }
    };
  • FFMPEG and Mencoder building screenshot returns 0 size images

    12 avril 2014, par Genus

    I have a script and it used to work fine but suddenly it stopped working and giving me zero size images as screenshot after video convert.

    here is the command for video screenshot.

    $cmd = $GLOBALS["paths"]["ffmpeg"]." -y -i ".$file." -f mjpeg -r 1 -ss ".$time." -vframes 1 -an ".$tmpdir."/00000001.jpg 2>&amp;1";
       exec($cmd,$results);

    Debug :

    -----------------------------------------------------

    ------------mencoder_and_fmpeg.php SCREENSHOT -------

    -----------------------------------------------------

     COMMAND: ffmpeg -y -i /home/TESTING/public_html/vid/6d/ad/29/6dad2946a2ba102.flv -f mjpeg -r 1 -ss 14.48 -vframes 1 -an /home/TESTING/public_html/scr/42/3a/92/00000001.jpg 2>&amp;1

     FFmpeg version SVN-r16244, Copyright (c) 2000-2008 Fabrice Bellard, et al.

     configuration: --disable-mmx --enable-shared --enable-libvorbis --enable-gpl --enable-swscale --enable-pthreads --disable-static --disable-demuxer=v4l --disable-demuxer=v4l2 --enable-libtheora --enable-gpl --enable-libspeex --enable-libmp3lame --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libamr-nb --enable-libamr-wb --enable-nonfree --enable-libxvid
     libavutil     49.12. 0 / 49.12. 0
     libavcodec    52. 7. 0 / 52.108. 0
     libavformat   52.23. 1 / 52.92. 0
     libavdevice   52. 1. 0 / 52. 2. 3
     libswscale     0. 6. 1 /  0.12. 0

     built on Apr  9 2011 22:48:41, gcc: 4.1.2 20080704 (Red Hat 4.1.2-50)
     built by Admin-Ahead Server Technologies FFmpeg installer v5.0.6b
     Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 10.92 (131/12)
     Stream mapping:
     Stream #0.0 -> #0.0

     Press [q] to stop encoding
     ffmpeg: symbol lookup error: ffmpeg: undefined symbol: frame_hook_process