Recherche avancée

Médias (91)

Autres articles (35)

  • Modifier la date de publication

    21 juin 2013, par

    Comment changer la date de publication d’un média ?
    Il faut au préalable rajouter un champ "Date de publication" dans le masque de formulaire adéquat :
    Administrer > Configuration des masques de formulaires > Sélectionner "Un média"
    Dans la rubrique "Champs à ajouter, cocher "Date de publication "
    Cliquer en bas de la page sur Enregistrer

  • Contribute to translation

    13 avril 2011

    You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
    To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
    MediaSPIP is currently available in French and English (...)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    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 (7595)

  • FFMPEG preset is not found ? Linux Cent OS 6

    25 août 2012, par Darius

    I ran this command

    ffmpeg -i v-16418145218d8d7abdaabec46beb22ecffd2f5d1625.flv -y -acodec aac -ac 2 -ab 160k -vcodec libx264 -vpre iPod640 -vpre slow -f mp4 -threads 0 OUTPUT.mp4

    Got this response :

    [flv @ 0x10ff670]Estimating duration from bitrate, this may be inaccurate

    Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1)
    Input #0, flv, from 'v-16418145218d8d7abdaabec46beb22ecffd2f5d1625.flv':
     Metadata:
       duration        : 14
       width           : 320
       height          : 240
       videodatarate   : 500
       framerate       : 25
       videocodecid    : 2
       audiodatarate   : 0
       audiosamplerate : 22050
       audiosamplesize : 16
       stereo          : true
       audiocodecid    : 2
       filesize        : 912970
     Duration: 00:00:13.92, start: 0.000000, bitrate: 576 kb/s
       Stream #0.0: Video: flv, yuv420p, 320x240, 512 kb/s, 25 tbr, 1k tbn, 1k tbc
       Stream #0.1: Audio: mp3, 22050 Hz, 2 channels, s16, 64 kb/s
    File for preset 'iPod640' not found

    But after doing a find, this is what I found.

    /usr/share/ffmpeg/libx264-ipod320.ffpreset
    /usr/share/ffmpeg/libx264-ipod640.ffpreset **** ITS HERE ******
    /usr/share/ffmpeg/libx264-lossless_fast.ffpreset
    /usr/share/ffmpeg/libx264-lossless_max.ffpreset
    /usr/share/ffmpeg/libx264-lossless_medium.ffpreset
    /usr/share/ffmpeg/libx264-lossless_slow.ffpreset
    /usr/share/ffmpeg/libx264-lossless_slower.ffpreset
    /usr/share/ffmpeg/libx264-lossless_ultrafast.ffpreset
    /usr/share/ffmpeg/libx264-main.ffpreset
    /usr/share/ffmpeg/libx264-max.ffpreset
    /usr/share/ffmpeg/libx264-medium.ffpreset
    /usr/share/ffmpeg/libx264-medium_firstpass.ffpreset
    /usr/share/ffmpeg/libx264-normal.ffpreset
    /usr/share/ffmpeg/libx264-placebo.ffpreset
    /usr/share/ffmpeg/libx264-placebo_firstpass.ffpreset
    /usr/share/ffmpeg/libx264-slow.ffpreset
    /usr/share/ffmpeg/libx264-slow_firstpass.ffpreset
    /usr/share/ffmpeg/libx264-slower.ffpreset

    I alos tried with -vpre libx264-ipod640 and still no luck. I get preset libx264-ipod640 is not found.... Do i have to enable presets somehow ? ffmpeg — enable presets ? or something ?

    ** EDIT : My ffmpeg version info **

    FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
     built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
     configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
     libavutil     50.15. 1 / 50.15. 1
     libavcodec    52.72. 2 / 52.72. 2
     libavformat   52.64. 2 / 52.64. 2
     libavdevice   52. 2. 0 / 52. 2. 0
     libavfilter    1.19. 0 /  1.19. 0
     libswscale     0.11. 0 /  0.11. 0
     libpostproc   51. 2. 0 / 51. 2. 0
    FFmpeg 0.6.5
    libavutil     50.15. 1 / 50.15. 1
    libavcodec    52.72. 2 / 52.72. 2
    libavformat   52.64. 2 / 52.64. 2
    libavdevice   52. 2. 0 / 52. 2. 0
    libavfilter    1.19. 0 /  1.19. 0
    libswscale     0.11. 0 /  0.11. 0
    libpostproc   51. 2. 0 / 51. 2. 0
  • How to make that video module can generate readable files for the module JW Player ?

    4 janvier 2015, par Dvex

    I use Drupal 7.x with Video Module, Video Pressets for FFMPEG and JW Player.
    I install FFMPEG with this Guide : https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu in Ubuntu 14.04

    I’m using jQuery 1.8

    I downloaded the files that the JW Player module requires and renamed some files, as the guide tells me.

    I set the video module so you can use FFMPEG and established the necessary pressets (FLV, MP4 and WebM) for any browser (web and mobile).

    I changed the default settings of these pressets. I put check the option : Force one-pass Encoding. Because if not me error message :

    PHPVideoToolkit error: Execute error. It was not possible to encode "/var/www/html/sites/default/files/private/videos/original/reel para web en loop_2.mp4" as FFmpeg returned an error. Note, however the error was encountered on the second pass of the encoding process and the first pass appear to go fine. The error is with the video codec of the input file. FFmpeg reports the error to be "Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height".

    /usr/bin/ffmpeg -i '/var/www/html/sites/default/files/private/videos/original/reel para web en loop_2.mp4' -strict experimental -vcodec 'h264' -acodec 'aac' -vprofile 'baseline' -ac '2' -pass '1' -passlogfile '/tmp/1420389438-54a96c3eda9fc-multipass'  -y /tmp/1420389438-54a96c3eda8c1.mp4
    ffmpeg version 1.2.6-7:1.2.6-1~trusty1 Copyright (c) 2000-2014 the FFmpeg developers
     built on Apr 26 2014 18:52:58 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
     configuration: --arch=amd64 --disable-stripping --enable-avresample --enable-pthreads --enable-runtime-cpudetect --extra-version='7:1.2.6-1~trusty1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
     libavutil      52. 18.100 / 52. 18.100
     libavcodec     54. 92.100 / 54. 92.100
     libavformat    54. 63.104 / 54. 63.104
     libavdevice    53.  5.103 / 53.  5.103
     libavfilter     3. 42.103 /  3. 42.103
     libswscale      2.  2.100 /  2.  2.100
     libswresample   0. 17.102 /  0. 17.102
     libpostproc    52.  2.100 / 52.  2.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/html/sites/default/files/private/videos/original/reel para web en loop_2.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42mp41
       creation_time   : 2013-09-12 17:30:22
     Duration: 00:00:39.32, start: 0.000000, bitrate: 3190 kb/s
       Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x480 [SAR 40:33 DAR 20:11], 2991 kb/s, 29.97 fps, 29.97 tbr, 29970 tbn, 59.94 tbc
       Metadata:
         creation_time   : 2013-09-12 17:30:22
         handler_name    : Mainconcept MP4 Video Media Handler
       Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s
       Metadata:
         creation_time   : 2013-09-12 17:30:22
         handler_name    : Mainconcept MP4 Sound Media Handler
    [libx264 @ 0x164dec0] using SAR=40/33
    [libx264 @ 0x164dec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    [libx264 @ 0x164dec0] profile Constrained Baseline, level 3.0
    [libx264 @ 0x164dec0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to '/tmp/1420389438-54a96c3eda8c1.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42mp41
       encoder         : Lavf54.63.104
       Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 720x480 [SAR 40:33 DAR 20:11], q=-1--1, pass 1, 11988 tbn, 29.97 tbc
       Metadata:
         creation_time   : 2013-09-12 17:30:22
         handler_name    : Mainconcept MP4 Video Media Handler
       Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s
       Metadata:
         creation_time   : 2013-09-12 17:30:22
         handler_name    : Mainconcept MP4 Sound Media Handler
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 -> libx264)
     Stream #0:1 -> #0:1 (aac -> aac)
    Press [q] to stop, [?] for help
    frame=   88 fps=0.0 q=29.0 size=     483kB time=00:00:02.96 bitrate=1335.6kbits/s dup=1 drop=0    
    frame=  190 fps=189 q=29.0 size=    1916kB time=00:00:06.33 bitrate=2477.6kbits/s dup=1 drop=0    
    frame=  289 fps=192 q=29.0 size=    3001kB time=00:00:09.64 bitrate=2549.5kbits/s dup=1 drop=0    
    frame=  395 fps=196 q=29.0 size=    3732kB time=00:00:13.31 bitrate=2296.7kbits/s dup=1 drop=0    
    frame=  495 fps=197 q=29.0 size=    4481kB time=00:00:16.66 bitrate=2203.1kbits/s dup=1 drop=0    
    frame=  591 fps=196 q=29.0 size=    5152kB time=00:00:19.98 bitrate=2111.4kbits/s dup=1 drop=0    
    frame=  690 fps=196 q=29.0 size=    6329kB time=00:00:23.01 bitrate=2252.4kbits/s dup=1 drop=0    
    frame=  790 fps=197 q=29.0 size=    7184kB time=00:00:26.32 bitrate=2235.6kbits/s dup=1 drop=0    
    frame=  890 fps=197 q=29.0 size=    8532kB time=00:00:29.73 bitrate=2350.3kbits/s dup=1 drop=0    
    frame= 1000 fps=199 q=29.0 size=    9398kB time=00:00:33.42 bitrate=2303.0kbits/s dup=1 drop=0    
    frame= 1106 fps=200 q=29.0 size=   10423kB time=00:00:37.01 bitrate=2306.8kbits/s dup=1 drop=0    
    frame= 1178 fps=199 q=-1.0 Lsize=   11404kB time=00:00:39.31 bitrate=2376.1kbits/s dup=1 drop=0
    video:10752kB audio:618kB subtitle:0 global headers:0kB muxing overhead 0.302603%
    [libx264 @ 0x164dec0] frame I:87    Avg QP:24.23  size: 21823
    [libx264 @ 0x164dec0] frame P:1091  Avg QP:25.90  size:  8351
    [libx264 @ 0x164dec0] mb I  I16..4: 50.9%  0.0% 49.1%
    [libx264 @ 0x164dec0] mb P  I16..4: 14.8%  0.0%  0.0%  P16..4: 51.3%  0.0%  0.0%  0.0%  0.0%    skip:33.9%
    [libx264 @ 0x164dec0] coded y,uvDC,uvAC intra: 43.9% 38.7% 10.2% inter: 23.0% 14.4% 0.8%
    [libx264 @ 0x164dec0] i16 v,h,dc,p: 31% 39% 19% 11%
    [libx264 @ 0x164dec0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 44% 14%  5%  4%  4%  4%  4%  4%
    [libx264 @ 0x164dec0] i8c dc,h,v,p: 57% 22% 17%  4%
    [libx264 @ 0x164dec0] kb/s:2240.77
    /usr/bin/ffmpeg -i '/var/www/html/sites/default/files/private/videos/original/reel para web en loop_2.mp4' -strict experimental -vcodec 'h264' -acodec 'aac' -vprofile 'baseline' -ac '2' -pass '2' -passlogfile '/tmp/1420389438-54a96c3eda9fc-multipass'  -y /tmp/1420389438-54a96c3eda8c1.mp4
    ffmpeg version 1.2.6-7:1.2.6-1~trusty1 Copyright (c) 2000-2014 the FFmpeg developers
     built on Apr 26 2014 18:52:58 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
     configuration: --arch=amd64 --disable-stripping --enable-avresample --enable-pthreads --enable-runtime-cpudetect --extra-version='7:1.2.6-1~trusty1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
     libavutil      52. 18.100 / 52. 18.100
     libavcodec     54. 92.100 / 54. 92.100
     libavformat    54. 63.104 / 54. 63.104
     libavdevice    53.  5.103 / 53.  5.103
     libavfilter     3. 42.103 /  3. 42.103
     libswscale      2.  2.100 /  2.  2.100
     libswresample   0. 17.102 /  0. 17.102
     libpostproc    52.  2.100 / 52.  2.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/html/sites/default/files/private/videos/original/reel para web en loop_2.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42mp41
       creation_time   : 2013-09-12 17:30:22
     Duration: 00:00:39.32, start: 0.000000, bitrate: 3190 kb/s
       Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x480 [SAR 40:33 DAR 20:11], 2991 kb/s, 29.97 fps, 29.97 tbr, 29970 tbn, 59.94 tbc
       Metadata:
         creation_time   : 2013-09-12 17:30:22
         handler_name    : Mainconcept MP4 Video Media Handler
       Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s
       Metadata:
         creation_time   : 2013-09-12 17:30:22
         handler_name    : Mainconcept MP4 Sound Media Handler
    [libx264 @ 0x161eec0] using SAR=40/33
    [libx264 @ 0x161eec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    [libx264 @ 0x161eec0] constant rate-factor is incompatible with 2pass.
    Output #0, mp4, to '/tmp/1420389438-54a96c3eda8c1.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42mp41
       Stream #0:0(eng): Video: h264, yuv420p, 720x480 [SAR 40:33 DAR 20:11], q=-1--1, pass 2, 90k tbn, 29.97 tbc
       Metadata:
         creation_time   : 2013-09-12 17:30:22
         handler_name    : Mainconcept MP4 Video Media Handler
       Stream #0:1(eng): Audio: none, 48000 Hz, stereo, fltp, 128 kb/s
       Metadata:
         creation_time   : 2013-09-12 17:30:22
         handler_name    : Mainconcept MP4 Sound Media Handler
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 -> libx264)
     Stream #0:1 -> #0:1 (aac -> aac)
    Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

    When I save a node and add its corresponding video, the module generates the 3 files with their respective formats. But when thrown at the JW Player module, only plays FLV in every browser.
    But not the MP4 or WebM.

    I checked the log and status report and all I get in order.

    So I assume that the MP4 and WebM formats generated are not what the JW Player waiting.

    Does anyone have the solution to this problem ? I tried to recompile FFMPEG with more codecs but it does not solve the problem.

    This is my FFMPEG Configuration :

    ffmpeg version 1.2.6-1~trusty1 Copyright (c) 2000-2014 the FFmpeg developers
     built on Apr 26 2014 18:52:58 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
     configuration: --arch=amd64 --disable-stripping --enable-avresample --enable-pthreads --enable-runtime-cpudetect --extra-version='7:1.2.6-1~trusty1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  • using libav instead of ffmpeg

    21 janvier 2015, par n00bie

    I want to streaming video over http, i am using ogg(theora + vorbis), now i have sender and receiver, and i can run them using command line :

    Sender :

    ffmpeg -f video4linux2 -s 320x240 -i /dev/mycam -codec:v libtheora -qscale:v 5 -f ogg http://127.0.0.1:8080

    Receiver :

    sudo gst-launch-0.10 tcpserversrc port = 8080 ! oggdemux ! theoradec ! autovideosink

    Now, sender sends both audio and video, but receiver plays only video.

    It works perfect, but now i want not to use ffmpeg and use only libav* instead.

    Here’s my class for streaming :

    class VCORE_LIBRARY_EXPORT VVideoWriter : private boost::noncopyable
    {
    public:
       VVideoWriter( );
       ~VVideoWriter( );

       bool openFile( const std::string& name,
                      int fps, int videoBitrate, int width, int height,
                      int audioSampleRate, bool stereo, int audioBitrate );
       void close( );

       bool writeVideoFrame( const uint8_t* image, int64_t timestamp );
       bool writeAudioFrame( const int16_t* data, int64_t timestamp  );

       int audioFrameSize( ) const;

    private:
       AVFrame *m_videoFrame;
       AVFrame *m_audioFrame;

       AVFormatContext *m_context;
       AVStream *m_videoStream;
       AVStream *m_audioStream;

       int64_t m_startTime;
    };

    Initialization :

    bool VVideoWriter::openFile( const std::string& name,
                                int fps, int videoBitrate, int width, int height,
                                int audioSampleRate, bool stereo, int audioBitrate )
    {
            if( ! m_context )
            {
               // initalize the AV context
               m_context = avformat_alloc_context( );
               assert( m_context );

               // get the output format
               m_context->oformat = av_guess_format( "ogg", name.c_str( ), nullptr );
               if( m_context->oformat )
               {
                   strcpy( m_context->filename, name.c_str( ) );

                   auto codecID = AV_CODEC_ID_THEORA;
                   auto codec = avcodec_find_encoder( codecID );

                   if( codec )
                   {
                       m_videoStream = avformat_new_stream( m_context, codec );
                       assert( m_videoStream );

                       // initalize codec
                       auto codecContext = m_videoStream->codec;
                       bool globalHeader = m_context->oformat->flags & AVFMT_GLOBALHEADER;
                       if( globalHeader )
                           codecContext->flags |= CODEC_FLAG_GLOBAL_HEADER;
                       codecContext->codec_id = codecID;
                       codecContext->codec_type = AVMEDIA_TYPE_VIDEO;
                       codecContext->width = width;
                       codecContext->height = height;
                       codecContext->time_base.den = fps;
                       codecContext->time_base.num = 1;
                       codecContext->bit_rate = videoBitrate;
                       codecContext->pix_fmt = PIX_FMT_YUV420P;
                       codecContext->flags |= CODEC_FLAG_QSCALE;
                       codecContext->global_quality = FF_QP2LAMBDA * 5;

                       int res = avcodec_open2( codecContext, codec, nullptr );

                       if( res >= 0 )
                       {
                           auto codecID = AV_CODEC_ID_VORBIS;
                           auto codec = avcodec_find_encoder( codecID );

                           if( codec )
                           {
                               m_audioStream = avformat_new_stream( m_context, codec );
                               assert( m_audioStream );
                               // initalize codec
                               auto codecContext = m_audioStream->codec;

                               bool globalHeader = m_context->oformat->flags & AVFMT_GLOBALHEADER;
                               if( globalHeader )
                                   codecContext->flags |= CODEC_FLAG_GLOBAL_HEADER;
                               codecContext->codec_id = codecID;
                               codecContext->codec_type = AVMEDIA_TYPE_AUDIO;
                               codecContext->sample_fmt = AV_SAMPLE_FMT_FLTP;
                               codecContext->bit_rate = audioBitrate;
                               codecContext->sample_rate = audioSampleRate;
                               codecContext->channels = stereo ? 2 : 1;
                               codecContext->channel_layout = stereo ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;

                               res = avcodec_open2( codecContext, codec, nullptr );

                               if( res >= 0 )
                               {
                                   // try to open the file
                                   if( avio_open( &m_context->pb, m_context->filename, AVIO_FLAG_WRITE ) >= 0 )
                                   {
                                       m_audioFrame->nb_samples = codecContext->frame_size;
                                       m_audioFrame->format = codecContext->sample_fmt;
                                       m_audioFrame->channel_layout = codecContext->channel_layout;

                                       boost::posix_time::ptime time_t_epoch( boost::gregorian::date( 1970, 1, 1 ) );
                                       m_context->start_time_realtime = ( boost::posix_time::microsec_clock::universal_time( ) - time_t_epoch ).total_microseconds( );
                                       m_startTime = -1;

                                       // write the header
                                       if( avformat_write_header( m_context, nullptr ) >= 0 )
                                       {
                                           return true;
                                       }
                                       else std::cerr << "VVideoWriter: failed to write video header" << std::endl;
                                   }
                                   else std::cerr << "VVideoWriter: failed to open video file " << name << std::endl;
                               }
                               else std::cerr << "VVideoWriter: failed to initialize audio codec" << std::endl;
                           }
                           else std::cerr << "VVideoWriter: requested audio codec is not supported" << std::endl;
                       }
                       else std::cerr << "VVideoWriter: failed to initialize video codec" << std::endl;
                   }
                   else std::cerr << "VVideoWriter: requested video codec is not supported" << std::endl;
               }
               else std::cerr << "VVideoWriter: requested video format is not supported" << std::endl;

               avformat_free_context( m_context );
               m_context = nullptr;
               m_videoStream = nullptr;
               m_audioStream = nullptr;
           }
           return false;
    }

    Writing video :

    bool VVideoWriter::writeVideoFrame( const uint8_t* image, int64_t timestamp )
    {
       if( m_context ) {
           auto codecContext = m_videoStream->codec;
           avpicture_fill( reinterpret_cast( m_videoFrame ),
                           const_cast( image ),
                           codecContext->pix_fmt, codecContext->width, codecContext->height );

           AVPacket pkt;
           av_init_packet( & pkt );
           pkt.data = nullptr;
           pkt.size = 0;
           int gotPacket = 0;
           if( ! avcodec_encode_video2( codecContext, &pkt, m_videoFrame, & gotPacket ) ) {
               if( gotPacket == 1 ) {
                   pkt.stream_index = m_videoStream->index;
                   int res;
                   {
                       pkt.pts = AV_NOPTS_VALUE;
                       pkt.dts = AV_NOPTS_VALUE;
                       pkt.stream_index = m_videoStream->index;
                       res = av_write_frame( m_context, &pkt );
                   }
                   av_free_packet( & pkt );
                   return res >= 0;
               }
               assert( ! pkt.size );
               return true;
           }
       }
       return false;
    }

    Writing audio (now i write test dummy audio) :

    bool VVideoWriter::writeAudioFrame( const int16_t* data, int64_t timestamp )
    {
       if( m_context ) {
           auto codecContext = m_audioStream->codec;

           int buffer_size = av_samples_get_buffer_size(nullptr, codecContext->channels, codecContext->frame_size, codecContext->sample_fmt, 0);

           float *samples = (float*)av_malloc(buffer_size);

           for (int i = 0; i < buffer_size / sizeof(float); i++)
               samples[i] = 1000. * sin((double)i/2.);

           int ret = avcodec_fill_audio_frame( m_audioFrame, codecContext->channels, codecContext->sample_fmt, (const uint8_t*)samples, buffer_size, 0);

           assert( ret >= 0 );
           (void)(ret);

           AVPacket pkt;
           av_init_packet( & pkt );
           pkt.data = nullptr;
           pkt.size = 0;
           int gotPacket = 0;
           if( ! avcodec_encode_audio2( codecContext, &pkt, m_audioFrame, & gotPacket ) ) {
               if( gotPacket == 1 ) {
                   pkt.stream_index = m_audioStream->index;
                   int res;
                   {
                       pkt.pts = AV_NOPTS_VALUE;
                       pkt.dts = AV_NOPTS_VALUE;
                       pkt.stream_index = m_audioStream->index;
                       res = av_write_frame( m_context, &pkt );
                   }
                   av_free_packet( & pkt );
                   return res >= 0;
               }
               assert( ! pkt.size );
               return true;
           }
           return false;
       }
       return false;
    }

    Here’s test example (i send video from webcam and dummy audio) :

    class TestVVideoWriter : public sigslot::has_slots<>
    {
    public:
       TestVVideoWriter( ) :
           m_fileOpened( false )
       {
       }

       void onCapturedFrame( cricket::VideoCapturer*, const cricket::CapturedFrame* capturedFrame )
       {
           if( m_fileOpened ) {
               m_writer.writeVideoFrame( reinterpret_cast<const>( capturedFrame->data ),
                                         capturedFrame->time_stamp / 1000 );
               m_writer.writeAudioFrame( nullptr , 0 );


           } else {
                 m_fileOpened = m_writer.openFile( "http://127.0.0.1:8080",
                                                   15, 40000, capturedFrame->width, capturedFrame->height,
                                                   16000, false, 64000 );
           }
       }

    public:
       vcore::VVideoWriter m_writer;
       bool m_fileOpened;
    };

    TestVVideoWriter testWriter;

    BOOST_AUTO_TEST_SUITE(TEST_VIDEO_WRITER)

    BOOST_AUTO_TEST_CASE(testWritingVideo)
    {
       cricket::LinuxDeviceManager deviceManager;
       std::vector devs;
       if( deviceManager.GetVideoCaptureDevices( &amp;devs ) ) {
           if( devs.size( ) ) {
               boost::shared_ptr camera( deviceManager.CreateVideoCapturer( devs[ 0 ] ) );
               if( camera ) {
                   cricket::VideoFormat format( 320, 240, cricket::VideoFormat::FpsToInterval( 30 ),
                                                camera->GetSupportedFormats( )->front( ).fourcc );
                   cricket::VideoFormat best;
                   if( camera->GetBestCaptureFormat( format, &amp;best ) ) {
                       camera->SignalFrameCaptured.connect( &amp;testWriter, &amp;TestVVideoWriter::onCapturedFrame );
                       if( camera->Start( best ) != cricket::CS_FAILED ) {
                           boost::this_thread::sleep( boost::posix_time::seconds( 10 ) );
                           return;
                       }
                   }
               }
           }
       }
       std::cerr &lt;&lt; "Problem has occured with camera" &lt;&lt; std::endl;
    }

    BOOST_AUTO_TEST_SUITE_END() // TEST_VIDEO_WRITER
    </const>

    But, in this case, gstreamer start playing video only when my test program stop executing (after 10 seconds in this case). It does not suit me, i want gstreamer start playing immediately after starting my test program.

    Could someone help me ?

    P.S. Sorry for my English.