[FFmpeg-trac] #984(avformat:new): avio_alloc_context and callback on write

FFmpeg trac at avcodec.org
Mon Feb 6 22:49:44 CET 2012


#984: avio_alloc_context and callback on write
----------------------------------+---------------------------------------
             Reporter:  mrdebug   |                     Type:  defect
               Status:  new       |                 Priority:  critical
            Component:  avformat  |                  Version:  unspecified
             Keywords:            |               Blocked By:
             Blocking:            |  Reproduced by developer:  0
Analyzed by developer:  0         |
----------------------------------+---------------------------------------
 For my application is essential use the callbacks. I have understood how
 to use callback on decoding but not on encoding.


 If is right, on order to obtain an encoded file from a sequence of images
 the steps are:
 1) initialize AVOutputFormat
 2) initialize AVFormatContext and referred it to AVOutputFormat
 3) use avio_open for open the output file
 4) initialize AVStream
 5) initialize AVCodec
 6) using avcodec_encode_video, AVPacket and av_interleaved_write_frame is
 possible to store the inage into the output file.


 That works. I can produce webm, mp4 and mpg file. But now the goal is to
 modify the sequence in order to use callback on write event.


 I have modified the sequence like this


 0) AVIOContext= avio_alloc_context(pBuffer, BUFFERSIZE, 0, this, NULL,
 WritePacket, NULL);
 1) initialize AVOutputFormat
 2) initialize AVFormatContext and referred it to AVOutputFormat and
 AVIOContext
 "pAVFormatContext->oformat= pAVOutputFormat;"
 "pAVFormatContext->pb= pAVIOContext;"
 3) remove avio_open for open the output file
 4) initialize AVStream
 5) initialize AVCodec
 6) using avcodec_encode_video, AVPacket and av_interleaved_write_frame.


 but does not work with all codecs. For example works using mpeg or webm
 but not with mp4 (x264) The WritePacket callback is always called but the
 produced mp4 file is not readable from mplayer or cvlc. The webm or mpg
 files work well instead.

-- 
Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/984>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list