id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc	blockedby	blocking	reproduced	analyzed
984	avio_alloc_context and callback on write	mrdebug		"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."	defect	closed	normal	avformat	unspecified	worksforme					0	0
