[Ffmpeg-devel] losing frame after a seek (not aproblem because this frame isn't a key frame)

Munier Nicolas Nicolas.Munier
Fri Apr 21 09:58:02 CEST 2006

Hi everybody,


I first pose this question in ffmpeg-user list and they tell me it will be best suited here.


I am a newbie using ffmpeg libraries. I am trying to build an application which will retrieve each frame of a video independently of its encoding.

I use a method similar to what Martin B?hme (thanks to him for his tutorial) describes in its example.


My first problem was that in order to identify the video stream and the codec, it uses some video stream packet and then the first frame retrieved is not the first frame of the video (at least not for mpeg4 like encoding). As the first frame is a key frame and was not decoded I was carrying errors in my frames until the next intra-only key frame.


To solve this problem I perform a seek to come back at the beginning of the video stream using av_seek_frame.

It seems to work for most of my video except those who are divX or Xvid. For those I retrieve the first frame without problem but I lose randomly some of the next frames. (At least ten in the next 50 frames). It comes back in order after a certain number of frames but I carry some errors (due to false predictions) for a long stretch due to the loss of a key frame (that's what first warns me).


Does anyone know what can cause this (bug?) and what can I do to solve this problem.


Thanks in advance,




PS: I'd be happy to give some more precisions if you need.

More information about the ffmpeg-devel mailing list