Recherche avancée

Médias (1)

Mot : - Tags -/getid3

Autres articles (53)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

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

Sur d’autres sites (4791)

  • How Can I capture and record a live stream using ffmpeg ? (Without any encoding or transcoding)

    25 février 2015, par Sina Davani

    How Can I capture and record a live stream using ffmpeg ? (Without any encoding or transcoding)

    I have a program written using ffmpeg. It captures a live stream and then plays it on the display (a simple video player).
    What I need now is the ability to save the input stream in a file on the disk so it could be played later using a standard video player.
    Can anyone please give me a simple example that would show how it is done ? When I am writing the captured packets from the input stream directly in to a file ; at the end the file is corrupted and it is unusable. I did try to set the header for the file ; but that didn’t work either.

  • libavcodec : how to encode with h264 codec ,with mp4 container using controllable frame rate and bitrate(through c code)

    26 mai 2016, par musimbate

    I am trying to record the screen of a pc and encode the recorded frames using h264 encoder
    and wrap them into a mp4 container.I want to do this because this super user link http://superuser.com/questions/300897/what-is-a-codec-e-g-divx-and-how-does-it-differ-from-a-file-format-e-g-mp/300997#300997 suggests it allows good trade-off between size and quality of the output file.

    The application I am working on should allow users to record a few hours of video and have the minimum output file size with decent quality.

    The code I have cooked up so far allows me to record and save .mpg(container) files with the mpeg1video encoder

    Running :

    ffmpeg -i test.mpg

    on the output file gives the following output :

    [mpegvideo @ 028c7400] Estimating duration from bitrate, this may be inaccurate
    Input #0, mpegvideo, from 'test.mpg':
     Duration: 00:00:00.29, bitrate: 104857 kb/s
       Stream #0:0: Video: mpeg1video, yuv420p(tv), 1366x768 [SAR 1:1 DAR 683:384], 104857 kb/s, 25 fps, 25 tbr, 1200k tbn, 25 tbc

    I have these settings for my output :

    const char * filename="test.mpg";
       int codec_id= AV_CODEC_ID_MPEG1VIDEO;
       AVCodec *codec11;
       AVCodecContext *outContext= NULL;
       int got_output;
       FILE *f;
       AVPacket pkt;
       uint8_t endcode[] = { 0, 0, 1, 0xb7 };

       /* put sample parameters */
       outContext->bit_rate = 400000;
       /* resolution must be a multiple of two */
       outContext->width=pCodecCtx->width;
       outContext->height=pCodecCtx->height;
       /* frames per second */
       outContext->time_base.num=1;
       outContext->time_base.den=25;
       /* emit one intra frame every ten frames
        * check frame pict_type before passing frame
        * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
        * then gop_size is ignored and the output of encoder
        * will always be I frame irrespective to gop_size
        */
       outContext->gop_size = 10;
       outContext->max_b_frames = 1;
       outContext->pix_fmt = AV_PIX_FMT_YUV420P;

    When I change int codec_id= AV_CODEC_ID_MPEG1VIDEO to int codec_id= AV_CODEC_ID_H264 i get a file that does not play with vlc.

    I have read that writing the

    uint8_t endcode[] = { 0, 0, 1, 0xb7 };

    array at the end of your file when finished encoding makes your file a legitimate mpeg file.It is written like this :

    fwrite(endcode, 1, sizeof(endcode), f);
       fclose(f);

    in my code. Should I do the same thing when I change my encoder to AV_CODEC_ID_H264 ?

    I am capturing using gdi input like this :

    AVDictionary* options = NULL;
       //Set some options
       //grabbing frame rate
       av_dict_set(&options,"framerate","30",0);
       AVInputFormat *ifmt=av_find_input_format("gdigrab");
       if(avformat_open_input(&pFormatCtx,"desktop",ifmt,&options)!=0){
           printf("Couldn't open input stream.\n");
           return -1;
           }

    I want to be able to modify my grabbing rate to optimize for the outptut file size
    but When I change it to 20 for example I get a video that plays so fast.How do
    I get a video that plays with normal speed with frames captured at 20 fps or any
    lower frame rate value ?

    While recording I get the following output on the standard error output :

    [gdigrab @ 00cdb8e0] Capturing whole desktop as 1366x768x32 at (0,0)
    Input #0, gdigrab, from '(null)':
     Duration: N/A, start: 1420718663.655713, bitrate: 1006131 kb/s
       Stream #0:0: Video: bmp, bgra, 1366x768, 1006131 kb/s, 29.97 tbr, 1000k tbn, 29.97 tbc
    [swscaler @ 00d24120] Warning: data is not aligned! This can lead to a speedloss
    [mpeg1video @ 00cdd160] AVFrame.format is not set
    [mpeg1video @ 00cdd160] AVFrame.width or height is not set
    [mpeg1video @ 00cdd160] AVFrame.format is not set
    [mpeg1video @ 00cdd160] AVFrame.width or height is not set
    [mpeg1video @ 00cdd160] AVFrame.format is not set

    How do I get rid of this error in my code ?

    In summary :
    1) How do I encode h264 video wrapped into mp4 container ?

    2) How do I capture at lower frame rates and still play
    the encoded video at normal speed ?

    3) How do I set the format(and which format—depends on the codec ?)
    and width and height info on the frames I write ?

    The code I am using in its entirety is shown below

    extern "C"
    {
    #include "libavcodec/avcodec.h"
    #include "libavformat/avformat.h"
    #include "libswscale/swscale.h"
    #include "libavdevice/avdevice.h"


    #include <libavutil></libavutil>opt.h>
    #include <libavutil></libavutil>channel_layout.h>
    #include <libavutil></libavutil>common.h>
    #include <libavutil></libavutil>imgutils.h>
    #include <libavutil></libavutil>mathematics.h>
    #include <libavutil></libavutil>samplefmt.h>
    //SDL
    #include "SDL.h"
    #include "SDL_thread.h"
    }

    //Output YUV420P
    #define OUTPUT_YUV420P 0
    //'1' Use Dshow
    //'0' Use GDIgrab
    #define USE_DSHOW 0

    int main(int argc, char* argv[])
    {

       //1.WE HAVE THE FORMAT CONTEXT
       //THIS IS FROM THE DESKTOP GRAB STREAM.
       AVFormatContext *pFormatCtx;
       int             i, videoindex;
       AVCodecContext  *pCodecCtx;
       AVCodec         *pCodec;

       av_register_all();
       avformat_network_init();

       //ASSIGN STH TO THE FORMAT CONTEXT.
       pFormatCtx = avformat_alloc_context();

       //Register Device
       avdevice_register_all();
       //Windows
    #ifdef _WIN32
    #if USE_DSHOW
       //Use dshow
       //
       //Need to Install screen-capture-recorder
       //screen-capture-recorder
       //Website: http://sourceforge.net/projects/screencapturer/
       //
       AVInputFormat *ifmt=av_find_input_format("dshow");
       //if(avformat_open_input(&amp;pFormatCtx,"video=screen-capture-recorder",ifmt,NULL)!=0){
       if(avformat_open_input(&amp;pFormatCtx,"video=UScreenCapture",ifmt,NULL)!=0){
           printf("Couldn't open input stream.\n");
           return -1;
       }
    #else
       //Use gdigrab
       AVDictionary* options = NULL;
       //Set some options
       //grabbing frame rate
       av_dict_set(&amp;options,"framerate","30",0);
       //The distance from the left edge of the screen or desktop
       //av_dict_set(&amp;options,"offset_x","20",0);
       //The distance from the top edge of the screen or desktop
       //av_dict_set(&amp;options,"offset_y","40",0);
       //Video frame size. The default is to capture the full screen
       //av_dict_set(&amp;options,"video_size","640x480",0);
       AVInputFormat *ifmt=av_find_input_format("gdigrab");
       if(avformat_open_input(&amp;pFormatCtx,"desktop",ifmt,&amp;options)!=0){
           printf("Couldn't open input stream.\n");
           return -1;
       }

    #endif
    #endif//FOR THE WIN32 THING.

       if(avformat_find_stream_info(pFormatCtx,NULL)&lt;0)
       {
           printf("Couldn't find stream information.\n");
           return -1;
       }
       videoindex=-1;
       for(i=0; inb_streams; i++)
           if(pFormatCtx->streams[i]->codec->codec_type
                   ==AVMEDIA_TYPE_VIDEO)
           {
               videoindex=i;
               break;
           }
       if(videoindex==-1)
       {
           printf("Didn't find a video stream.\n");
           return -1;
       }
       pCodecCtx=pFormatCtx->streams[videoindex]->codec;
       pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
       if(pCodec==NULL)
       {
           printf("Codec not found.\n");
           return -1;
       }
       if(avcodec_open2(pCodecCtx, pCodec,NULL)&lt;0)
       {
           printf("Could not open codec.\n");
           return -1;
       }

       //THIS IS WHERE YOU CONTROL THE FORMAT(THROUGH FRAMES).
       AVFrame *pFrame;

       pFrame=av_frame_alloc();

       int ret, got_picture;

       AVPacket *packet=(AVPacket *)av_malloc(sizeof(AVPacket));

       //TRY TO INIT THE PACKET HERE
        av_init_packet(packet);


       //Output Information-----------------------------
       printf("File Information---------------------\n");
       av_dump_format(pFormatCtx,0,NULL,0);
       printf("-------------------------------------------------\n");


    //&lt;&lt;--FOR WRITING MPG FILES
       //&lt;&lt;--START:PREPARE TO WRITE YOUR MPG FILE.

       const char * filename="test.mpg";
       int codec_id= AV_CODEC_ID_MPEG1VIDEO;



       AVCodec *codec11;
       AVCodecContext *outContext= NULL;
       int got_output;
       FILE *f;
       AVPacket pkt;
       uint8_t endcode[] = { 0, 0, 1, 0xb7 };

       printf("Encode video file %s\n", filename);

       /* find the mpeg1 video encoder */
       codec11 = avcodec_find_encoder((AVCodecID)codec_id);
       if (!codec11) {
           fprintf(stderr, "Codec not found\n");
           exit(1);
       }

       outContext = avcodec_alloc_context3(codec11);
       if (!outContext) {
           fprintf(stderr, "Could not allocate video codec context\n");
           exit(1);
       }

       /* put sample parameters */
       outContext->bit_rate = 400000;
       /* resolution must be a multiple of two */

       outContext->width=pCodecCtx->width;
       outContext->height=pCodecCtx->height;


       /* frames per second */
       outContext->time_base.num=1;
       outContext->time_base.den=25;

       /* emit one intra frame every ten frames
        * check frame pict_type before passing frame
        * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
        * then gop_size is ignored and the output of encoder
        * will always be I frame irrespective to gop_size
        */
       outContext->gop_size = 10;
       outContext->max_b_frames = 1;
       outContext->pix_fmt = AV_PIX_FMT_YUV420P;

       if (codec_id == AV_CODEC_ID_H264)
           av_opt_set(outContext->priv_data, "preset", "slow", 0);

       /* open it */
       if (avcodec_open2(outContext, codec11, NULL) &lt; 0) {
           fprintf(stderr, "Could not open codec\n");
           exit(1);
       }

       f = fopen(filename, "wb");
       if (!f) {
           fprintf(stderr, "Could not open %s\n", filename);
           exit(1);
       }


       AVFrame *outframe = av_frame_alloc();
       int nbytes = avpicture_get_size(outContext->pix_fmt,
                                      outContext->width,
                                      outContext->height);

       uint8_t* outbuffer = (uint8_t*)av_malloc(nbytes);

      //ASSOCIATE THE FRAME TO THE ALLOCATED BUFFER.
       avpicture_fill((AVPicture*)outframe, outbuffer,
                      AV_PIX_FMT_YUV420P,
                      outContext->width, outContext->height);

       SwsContext* swsCtx_ ;
       swsCtx_= sws_getContext(pCodecCtx->width,
                               pCodecCtx->height,
                               pCodecCtx->pix_fmt,
                               outContext->width, outContext->height,
                               outContext->pix_fmt,
                               SWS_BICUBIC, NULL, NULL, NULL);


       //HERE WE START PULLING PACKETS FROM THE SPECIFIED FORMAT CONTEXT.
       while(av_read_frame(pFormatCtx, packet)>=0)
       {
           if(packet->stream_index==videoindex)
           {
               ret= avcodec_decode_video2(pCodecCtx,
                                            pFrame,
                                            &amp;got_picture,packet );
               if(ret &lt; 0)
               {
                   printf("Decode Error.\n");
                   return -1;
               }
               if(got_picture)
               {

               sws_scale(swsCtx_, pFrame->data, pFrame->linesize,
                     0, pCodecCtx->height, outframe->data,
                     outframe->linesize);


               av_init_packet(&amp;pkt);
               pkt.data = NULL;    // packet data will be allocated by the encoder
               pkt.size = 0;


               ret = avcodec_encode_video2(outContext, &amp;pkt, outframe, &amp;got_output);
               if (ret &lt; 0) {
                  fprintf(stderr, "Error encoding frame\n");
                  exit(1);
                 }

               if (got_output) {
                   printf("Write frame %3d (size=%5d)\n", i, pkt.size);
                   fwrite(pkt.data, 1, pkt.size, f);
                   av_free_packet(&amp;pkt);
                  }

               }
           }

           av_free_packet(packet);
       }//THE LOOP TO PULL PACKETS FROM THE FORMAT CONTEXT ENDS HERE.



       //
       /* get the delayed frames */
       for (got_output = 1; got_output; i++) {
           //fflush(stdout);

           ret = avcodec_encode_video2(outContext, &amp;pkt, NULL, &amp;got_output);
           if (ret &lt; 0) {
               fprintf(stderr, "Error encoding frame\n");
               exit(1);
           }

           if (got_output) {
               printf("Write frame %3d (size=%5d)\n", i, pkt.size);
               fwrite(pkt.data, 1, pkt.size, f);
               av_free_packet(&amp;pkt);
           }
       }



       /* add sequence end code to have a real mpeg file */
       fwrite(endcode, 1, sizeof(endcode), f);
       fclose(f);

       avcodec_close(outContext);
       av_free(outContext);
       //av_freep(&amp;frame->data[0]);
       //av_frame_free(&amp;frame);

       //THIS WAS ADDED LATER
       av_free(outbuffer);

       avcodec_close(pCodecCtx);
       avformat_close_input(&amp;pFormatCtx);

       return 0;
    }

    Thank you for your time.

  • 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&amp; 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&amp; 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 &amp; 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 &amp; 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( &amp;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 &lt;&lt; "VVideoWriter: failed to write video header" &lt;&lt; std::endl;
                                   }
                                   else std::cerr &lt;&lt; "VVideoWriter: failed to open video file " &lt;&lt; name &lt;&lt; std::endl;
                               }
                               else std::cerr &lt;&lt; "VVideoWriter: failed to initialize audio codec" &lt;&lt; std::endl;
                           }
                           else std::cerr &lt;&lt; "VVideoWriter: requested audio codec is not supported" &lt;&lt; std::endl;
                       }
                       else std::cerr &lt;&lt; "VVideoWriter: failed to initialize video codec" &lt;&lt; std::endl;
                   }
                   else std::cerr &lt;&lt; "VVideoWriter: requested video codec is not supported" &lt;&lt; std::endl;
               }
               else std::cerr &lt;&lt; "VVideoWriter: requested video format is not supported" &lt;&lt; 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( &amp; pkt );
           pkt.data = nullptr;
           pkt.size = 0;
           int gotPacket = 0;
           if( ! avcodec_encode_video2( codecContext, &amp;pkt, m_videoFrame, &amp; 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, &amp;pkt );
                   }
                   av_free_packet( &amp; 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 &lt; 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( &amp; pkt );
           pkt.data = nullptr;
           pkt.size = 0;
           int gotPacket = 0;
           if( ! avcodec_encode_audio2( codecContext, &amp;pkt, m_audioFrame, &amp; 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, &amp;pkt );
                   }
                   av_free_packet( &amp; 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&lt;>
    {
    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.