Recherche avancée

Médias (3)

Mot : - Tags -/image

Autres articles (6)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 is the first MediaSPIP stable release.
    Its official release date is June 21, 2013 and is announced here.
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

Sur d’autres sites (4546)

  • Unable to encode H264 video using FFMPEG example

    4 mai 2020, par Basit Anwer

    FFMPEG encode example fails to create a H264 video. MPEG1 works fine though.

    



    Pasting the code here as well

    



    &#xA;     * @file&#xA;     * video encoding with libavcodec API example&#xA;     *&#xA;     * @example encode_video.c&#xA;     */&#xA;    #include &#xA;    #include &#xA;    #include &#xA;    #include <libavcodec></libavcodec>avcodec.h>&#xA;    #include <libavutil></libavutil>opt.h>&#xA;    #include <libavutil></libavutil>imgutils.h>&#xA;    static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt,&#xA;                       FILE *outfile)&#xA;    {&#xA;        int ret;&#xA;        /* send the frame to the encoder */&#xA;        if (frame)&#xA;            printf("Send frame %3"PRId64"\n", frame->pts);&#xA;        ret = avcodec_send_frame(enc_ctx, frame);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error sending a frame for encoding\n");&#xA;            exit(1);&#xA;        }&#xA;        while (ret >= 0) {&#xA;            ret = avcodec_receive_packet(enc_ctx, pkt);&#xA;            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;                return;&#xA;            else if (ret &lt; 0) {&#xA;                fprintf(stderr, "Error during encoding\n");&#xA;                exit(1);&#xA;            }&#xA;            printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size);&#xA;            fwrite(pkt->data, 1, pkt->size, outfile);&#xA;            av_packet_unref(pkt);&#xA;        }&#xA;    }&#xA;&#xA;    int main(int argc, char **argv)&#xA;    {&#xA;        const char *filename, *codec_name;&#xA;        const AVCodec *codec;&#xA;        AVCodecContext *c= NULL;&#xA;        int i, ret, x, y;&#xA;        FILE *f;&#xA;        AVFrame *frame;&#xA;        AVPacket *pkt;&#xA;        uint8_t endcode[] = { 0, 0, 1, 0xb7 };&#xA;        if (argc &lt;= 2) {&#xA;            fprintf(stderr, "Usage: %s <output file="file"> <codec>\n", argv[0]);&#xA;            exit(0);&#xA;        }&#xA;        filename = argv[1];&#xA;        codec_name = argv[2];&#xA;        /* find the mpeg1video encoder */&#xA;        codec = avcodec_find_encoder_by_name(codec_name);&#xA;        if (!codec) {&#xA;            fprintf(stderr, "Codec &#x27;%s&#x27; not found\n", codec_name);&#xA;            exit(1);&#xA;        }&#xA;        c = avcodec_alloc_context3(codec);&#xA;        if (!c) {&#xA;            fprintf(stderr, "Could not allocate video codec context\n");&#xA;            exit(1);&#xA;        }&#xA;        pkt = av_packet_alloc();&#xA;        if (!pkt)&#xA;            exit(1);&#xA;        /* put sample parameters */&#xA;        c->bit_rate = 400000;&#xA;        /* resolution must be a multiple of two */&#xA;        c->width = 352;&#xA;        c->height = 288;&#xA;        /* frames per second */&#xA;        c->time_base = (AVRational){1, 25};&#xA;        c->framerate = (AVRational){25, 1};&#xA;        /* emit one intra frame every ten frames&#xA;         * check frame pict_type before passing frame&#xA;         * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I&#xA;         * then gop_size is ignored and the output of encoder&#xA;         * will always be I frame irrespective to gop_size&#xA;         */&#xA;        c->gop_size = 10;&#xA;        c->max_b_frames = 1;&#xA;        c->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;        if (codec->id == AV_CODEC_ID_H264)&#xA;            av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;        /* open it */&#xA;        ret = avcodec_open2(c, codec, NULL);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not open codec: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;        f = fopen(filename, "wb");&#xA;        if (!f) {&#xA;            fprintf(stderr, "Could not open %s\n", filename);&#xA;            exit(1);&#xA;        }&#xA;        frame = av_frame_alloc();&#xA;        if (!frame) {&#xA;            fprintf(stderr, "Could not allocate video frame\n");&#xA;            exit(1);&#xA;        }&#xA;        frame->format = c->pix_fmt;&#xA;        frame->width  = c->width;&#xA;        frame->height = c->height;&#xA;        ret = av_frame_get_buffer(frame, 32);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not allocate the video frame data\n");&#xA;            exit(1);&#xA;        }&#xA;        /* encode 1 second of video */&#xA;        for (i = 0; i &lt; 25; i&#x2B;&#x2B;) {&#xA;            fflush(stdout);&#xA;            /* make sure the frame data is writable */&#xA;            ret = av_frame_make_writable(frame);&#xA;            if (ret &lt; 0)&#xA;                exit(1);&#xA;            /* prepare a dummy image */&#xA;            /* Y */&#xA;            for (y = 0; y &lt; c->height; y&#x2B;&#x2B;) {&#xA;                for (x = 0; x &lt; c->width; x&#x2B;&#x2B;) {&#xA;                    frame->data[0][y * frame->linesize[0] &#x2B; x] = x &#x2B; y &#x2B; i * 3;&#xA;                }&#xA;            }&#xA;            /* Cb and Cr */&#xA;            for (y = 0; y &lt; c->height/2; y&#x2B;&#x2B;) {&#xA;                for (x = 0; x &lt; c->width/2; x&#x2B;&#x2B;) {&#xA;                    frame->data[1][y * frame->linesize[1] &#x2B; x] = 128 &#x2B; y &#x2B; i * 2;&#xA;                    frame->data[2][y * frame->linesize[2] &#x2B; x] = 64 &#x2B; x &#x2B; i * 5;&#xA;                }&#xA;            }&#xA;            frame->pts = i;&#xA;            /* encode the image */&#xA;            encode(c, frame, pkt, f);&#xA;        }&#xA;        /* flush the encoder */&#xA;        encode(c, NULL, pkt, f);&#xA;        /* add sequence end code to have a real MPEG file */&#xA;        if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == AV_CODEC_ID_MPEG2VIDEO)&#xA;            fwrite(endcode, 1, sizeof(endcode), f);&#xA;        fclose(f);&#xA;        avcodec_free_context(&amp;c);&#xA;        av_frame_free(&amp;frame);&#xA;        av_packet_free(&amp;pkt);&#xA;        return 0;&#xA;    }&#xA;</codec></output>

    &#xA;&#xA;

    The code fails at encode call and every avcodec_receive_packet call returns AVERROR(EAGAIN)

    &#xA;&#xA;

    What am i missing here ?

    &#xA;

  • Interlaced (1080i) video converted to deinterlaced (1080p) won't play in Quicktime or other players, except VLC

    24 avril 2020, par cozmonaut

    I'm trying to convert a 1080i ts video clip to 1080p mp4. I've found many different ffmpeg commands to do this, which all successfully convert to 1080p mp4, however, none of generated clips will open in Quicktime or any another other player, other than VLC. I've read about the need to have the correct color space (i.e. yuv420p) for Quicktime to work, and also that 10 bit files won't work (only 8 bit). However, when these things have been accounted for, the resulting video clips still won't open in Quicktime.

    &#xA;&#xA;

    &#xA;&#xA;

    Here are the commands I've tried.

    &#xA;&#xA;

        ffmpeg -i test_original_interlaced.ts -vf bwdif -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p -c:a aac -b:a 320k test_generated_progressive.mp4&#xA;&#xA;    ffmpeg -i test_original_interlaced.ts  -vf yadif -c:v libx264 -preset slow -crf 19 -c:a aac -b:a 256k test_generated_progressive.mp4&#xA;&#xA;    ffmpeg -i test_original_interlaced.ts  -vf yadif -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p -c:a aac -b:a 256k test_generated_progressive.mp4&#xA;&#xA;    ffmpeg -i test_original_interlaced.ts -vf yadif=parity=auto test_generated_progressive.mp4&#xA;

    &#xA;&#xA;

    &#xA;&#xA;

    Here are the 1080i ts details and link to the original video clip :

    &#xA;&#xA;

    ffmpeg version 4.2.1-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2000-2019 the FFmpeg developers&#xA;  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)&#xA;  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay&#xA;  libavutil      56. 31.100 / 56. 31.100&#xA;  libavcodec     58. 54.100 / 58. 54.100&#xA;  libavformat    58. 29.100 / 58. 29.100&#xA;  libavdevice    58.  8.100 / 58.  8.100&#xA;  libavfilter     7. 57.100 /  7. 57.100&#xA;  libswscale      5.  5.100 /  5.  5.100&#xA;  libswresample   3.  5.100 /  3.  5.100&#xA;  libpostproc    55.  5.100 / 55.  5.100&#xA;Input #0, mpegts, from &#x27;/Users/test_original_interlaced.ts&#x27;:&#xA;  Duration: 00:00:05.26, start: 1.400000, bitrate: 15183 kb/s&#xA;  Program 1 &#xA;    Metadata:&#xA;      service_name    : Service01&#xA;      service_provider: FFmpeg&#xA;    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc&#xA;    Stream #0:1[0x101](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s&#xA;

    &#xA;&#xA;

    Link to original video clip (10 MB) : https://www.dropbox.com/s/85tv3v91lflfpon/test_original_interlaced.ts?dl=0

    &#xA;&#xA;

    &#xA;&#xA;

    Here are the 1080p mp4 details and link to the generated video clip (that won't open in Quicktime) :

    &#xA;&#xA;

    ffmpeg version 4.2.1-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2000-2019 the FFmpeg developers&#xA;  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)&#xA;  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay&#xA;  libavutil      56. 31.100 / 56. 31.100&#xA;  libavcodec     58. 54.100 / 58. 54.100&#xA;  libavformat    58. 29.100 / 58. 29.100&#xA;  libavdevice    58.  8.100 / 58.  8.100&#xA;  libavfilter     7. 57.100 /  7. 57.100&#xA;  libswscale      5.  5.100 /  5.  5.100&#xA;  libswresample   3.  5.100 /  3.  5.100&#xA;  libpostproc    55.  5.100 / 55.  5.100&#xA;Guessed Channel Layout for Input Stream #0.1 : 5.1&#xA;Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;/Users/test_generated_progressive.mp4&#x27;:&#xA;  Metadata:&#xA;    major_brand     : isom&#xA;    minor_version   : 512&#xA;    compatible_brands: isomiso2avc1mp41&#xA;    encoder         : Lavf58.29.100&#xA;  Duration: 00:00:05.27, start: 0.000000, bitrate: 9873 kb/s&#xA;    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 9543 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 119.88 tbc (default)&#xA;    Metadata:&#xA;      handler_name    : VideoHandler&#xA;    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 319 kb/s (default)&#xA;    Metadata:&#xA;      handler_name    : SoundHandler&#xA;

    &#xA;&#xA;

    Link to generated video clip (6.5 MB) : https://www.dropbox.com/s/w744mdee5drvmya/test_generated_progressive.mp4?dl=0

    &#xA;&#xA;

    &#xA;&#xA;

    Any help would be greatly appreciated.

    &#xA;&#xA;

    Thank you.

    &#xA;

  • Creating GIF from QImages with ffmpeg

    21 mars 2020, par Sierra

    I would like to generate GIF from QImage, using ffmpeg - all of that programmatically (C++). I’m working with Qt 5.6 and the last build of ffmpeg (build git-0a9e781 (2016-06-10).

    I’m already able to convert these QImage in .mp4 and it works. I tried to use the same principle for the GIF, changing format pixel and codec. GIF is generated with two pictures (1 second each), in 15 FPS.

    ## INITIALIZATION
    #####################################################################

    // Filepath : "C:/Users/.../qt_temp.Jv7868.gif"  
    // Allocating an AVFormatContext for an output format...
    avformat_alloc_output_context2(formatContext, NULL, NULL, filepath);

    ...

    // Adding the video streams using the default format codecs and initializing the codecs.
    stream = avformat_new_stream(formatContext, *codec);

    AVCodecContext * codecContext = avcodec_alloc_context3(*codec);

    context->codec_id       = codecId;
    context->bit_rate       = 400000;
    ...
    context->pix_fmt        = AV_PIX_FMT_BGR8;

    ...

    // Opening the codec...
    avcodec_open2(codecContext, codec, NULL);

    ...

    frame = allocPicture(codecContext->width, codecContext->height, codecContext->pix_fmt);
    tmpFrame = allocPicture(codecContext->width, codecContext->height, AV_PIX_FMT_RGBA);

    ...

    avformat_write_header(formatContext, NULL);

    ## ADDING A NEW FRAME
    #####################################################################

    // Getting in parameter the QImage: newFrame(const QImage &amp; image)
    const qint32 width  = image.width();
    const qint32 height = image.height();

    // Converting QImage into AVFrame
    for (qint32 y = 0; y &lt; height; y++) {
       const uint8_t * scanline = image.scanLine(y);

       for (qint32 x = 0; x &lt; width * 4; x++) {
           tmpFrame->data[0][y * tmpFrame->linesize[0] + x] = scanline[x];
       }
    }

    ...

    // Scaling...
    if (codec->pix_fmt != AV_PIX_FMT_BGRA) {
       if (!swsCtx) {
           swsCtx = sws_getContext(codec->width, codec->height,
                                   AV_PIX_FMT_BGRA,
                                   codec->width, codec->height,
                                   codec->pix_fmt,
                                   SWS_BICUBIC, NULL, NULL, NULL);
       }

       sws_scale(swsCtx,
                 (const uint8_t * const *)tmpFrame->data,
                 tmpFrame->linesize,
                 0,
                 codec->height,
                 frame->data,
                 frame->linesize);
    }
    frame->pts = nextPts++;

    ...

    int gotPacket = 0;
    AVPacket packet = {0};

    av_init_packet(&amp;packet);
    avcodec_encode_video2(codec, &amp;packet, frame, &amp;gotPacket);

    if (gotPacket) {
       av_packet_rescale_ts(paket, *codec->time_base, stream->time_base);
       paket->stream_index = stream->index;

       av_interleaved_write_frame(formatContext, paket);
    }

    But when I’m trying to modify the video codec and pixel format to match with GIF specifications, I’m facing some issues.
    I tried several codecs such as AV_CODEC_ID_GIF and AV_CODEC_ID_RAWVIDEO but none of them seem to work. During the initialization phase, avcodec_open2() always returns such kind of errors :

    Specified pixel format rgb24 is invalid or not supported
    Could not open video codec:  gif

    EDIT 17/06/2016

    Digging a little bit more, avcodec_open2() returns -22 :

    #define EINVAL          22      /* Invalid argument */

    EDIT 22/06/2016

    Here are the flags used to compile ffmpeg :

    "FFmpeg/Libav configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib"

    Did I miss a crucial one for GIF ?

    EDIT 27/06/2016

    Thanks to Gwen, I have a first output : I setted the context->pix_fmt to AV_PIX_FMT_BGR8. Btw I’m still facing some issues with the generated GIF. It’s not playing and encoding appears to fail.

    GIF generated in command lines with ffmpeg (left) . . . GIF generated programmatically (right)
    Generated in command line with ffmpeg
    enter image description here

    It looks like some options are not defined... also may be a wrong conversion between QImage and AVFrame ? I updated the code above. It represents a lot of code, so I tried to stay short. Don’t hesitate to ask more details.

    End of EDIT

    I’m not really familiar with ffmpeg, any kind of help would be highly appreciated. Thank you.