[Ffmpeg-devel] avcodec_flush_buffers when reading 2 videos ?

Raphael HUCK raphaelh
Mon Dec 19 17:15:07 CET 2005


Hi,

I've made a program which reads a video with libav(codec/format), and it 
works fine.

BUT when I try to read read 2 videos, ie open the first file, read it, 
close it, free everything, and then the same with a second file, it crashes.

I've seen in "ffplay.c" :

	SDL_LockMutex(is->video_decoder_mutex);
         avcodec_flush_buffers(&ic->streams[video_index]->codec);
         SDL_UnlockMutex(is->video_decoder_mutex);

So I looked up the code for the flush function in "libavcodec/utils.c" :

	/**
	 * Flush buffers, should be called when seeking or when 		
	 * swicthing to a different stream.
	 */
	void avcodec_flush_buffers(AVCodecContext *avctx)
	{
	    if(avctx->codec->flush)
	        avctx->codec->flush(avctx);
	}


Is there a trick to read 2 videos one after the other ?
At what time do I need to call the flush function ?
Do I need to use a mutex while calling the flush function ?

Thanks in advance,

--Raphael HUCK





More information about the ffmpeg-devel mailing list