[Ffmpeg-devel] problem with timestamps in a video file

Måns Rullgård mru
Fri Apr 21 21:33:47 CEST 2006

Vincent Torri <vtorri at univ-evry.fr> writes:

> Hello,
> I'm using gstreamer to read a file (xvid stream, no audio, in a AVI) :
> http://www.iecn.u-nancy.fr/~torri/files/gstreamer_test_seek/blood.avi
> Gstreamer uses in that case ffmpeg. My aim is to do exact seeking (i
> work on avisynth 3.0). But it seems that the gstreamer plugin has
> problems with that file.
> More precisely, when I seek to frame 0 (for example), the timestamp
> returned by gstreamer is 1.0/fps s., instead of 0 s.
> One of the gstreamer dev analysed the file :
> "[the file] has a decodable frame at time 0 but is delayed and
> outputted when the second frame is sent to the decoder. So the first
> frame to exit the decoder gets the timestamp of the second frame"
> it seems that ffmpeg does not manage the timestamps for us, and it
> might buffer/delay/drop an unknown number of frames (it's only
> suppositions), and so, the guess of timestamps is quite complicated.

Many codecs have a delay of a few frames from input to output.  This
is necessary if the coded order is not necessarily equal to the
display order (such as when B frames are used).  Even if no B frames
are used, it is necessary to delay the output when there is no
indication that there really are no B frames (low_delay in MPEG speak).

> so, here is the question :
> Is there a way to feed data+timestamp to the decoder and get a
> frame+corresponding timestamp back ?

You can use the codec_picture_number and display_picture_number fields
in AVFrame to track the decoding.

Keep in mind also that the AVI format has no notion of timestamps.

M?ns Rullg?rd
mru at inprovide.com

More information about the ffmpeg-devel mailing list