Recherche avancée

Médias (1)

Mot : - Tags -/Christian Nold

Autres articles (60)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Other interesting software

    13 avril 2011, par

    We don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
    The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
    We don’t know them, we didn’t try them, but you can take a peek.
    Videopress
    Website : http://videopress.com/
    License : GNU/GPL v2
    Source code : (...)

Sur d’autres sites (10586)

  • Encode buffer captured by OpenGL in C

    4 janvier 2020, par M. Ying

    I am trying to use OpenGL to capture the back buffer of my computer’s screen, and then H.264 encode the buffer using FFMPEG’s libavcodec library. The issue I’m having is that I would like to encode the video in AV_PIX_FMT_420P, but the back buffer capture function provided by OpenGL, glReadPixels(), only supports formats like GL_RGB. As you can see below, I try to use FFMPEG’s swscale() function to convert from RGB to YUV, but the following code crashes at the swscale() line. Any ideas on how I can encode the OpenGL backbuffer ?

    // CAPTURE BACK BUFFER USING OPENGL
       int width = 1280, height = 720;
       BYTE* pixels = (BYTE *) malloc(sizeof(BYTE));
       glReadPixels(0, 720, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);

    //CREATE FFMPEG VARIABLES
       avcodec_register_all();

       AVCodec *codec;
       AVCodecContext *context;
       struct SwsContext *sws;
       AVPacket packet;
       AVFrame *frame;

       codec = avcodec_find_encoder(AV_CODEC_ID_H264);
       context = avcodec_alloc_context3(encoder->codec);
       context->dct_algo = FF_DCT_FASTINT;
       context->bit_rate = 400000;
       context->width = width;
       context->height = height;
       context->time_base.num = 1;
       context->time_base.den = 30;
       context->gop_size = 1;
       context->max_b_frames = 1;
       context->pix_fmt = AV_PIX_FMT_YUV420P;

       avcodec_open2(context, codec, NULL);

    // CONVERT TO YUV AND ENCODE
       int frame_size = avpicture_get_size(AV_PIX_FMT_YUV420P, out_width, out_height);
       encoder->frame_buffer = malloc(frame_size);
       avpicture_fill((AVPicture *) encoder->frame, (uint8_t *) encoder->frame_buffer, AV_PIX_FMT_YUV420P, out_width, out_height);
       sws = sws_getContext(in_width, in_height, AV_PIX_FMT_RGB32, out_width, out_height, AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, 0, 0, 0);

       uint8_t *in_data[1] = {(uint8_t *) pixels};
       int in_linesize[1] = {width * 4};


    // PROGRAM CRASHES HERE


       sws_scale(encoder->sws, in_data, in_linesize, 0, encoder->in_height, encoder->frame->data, encoder->frame->linesize);

       av_free_packet(&packet);
       av_init_packet(&packet);
       int success;

       avcodec_encode_video2(context, &packet, frame, &success);
  • 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 & image)
    const qint32 width  = image.width();
    const qint32 height = image.height();

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

       for (qint32 x = 0; x < 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(&packet);
    avcodec_encode_video2(codec, &packet, frame, &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.

  • 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.

    



    



    Here are the commands I've tried.

    



        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

    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

    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

    ffmpeg -i test_original_interlaced.ts -vf yadif=parity=auto test_generated_progressive.mp4


    



    



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

    



    ffmpeg version 4.2.1-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  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
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mpegts, from '/Users/test_original_interlaced.ts':
  Duration: 00:00:05.26, start: 1.400000, bitrate: 15183 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    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
    Stream #0:1[0x101](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s


    



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

    



    



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

    



    ffmpeg version 4.2.1-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  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
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Guessed Channel Layout for Input Stream #0.1 : 5.1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/test_generated_progressive.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:05.27, start: 0.000000, bitrate: 9873 kb/s
    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)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 319 kb/s (default)
    Metadata:
      handler_name    : SoundHandler


    



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

    



    



    Any help would be greatly appreciated.

    



    Thank you.