[Libav-user] Seeking, timestamps, AVFrame, AVStream

Robert Krüger krueger at lesspain.de
Tue Sep 17 10:54:46 CEST 2013


On Mon, Sep 16, 2013 at 9:49 PM, James Board <jpboard2 at yahoo.com> wrote:
>>> Anyway, it sounds like pts and best_effort_timestamp are really frame
>>> numbers
>>
>>No, they are not. It is the case if timebase = 1/framerate but that is
>>not guaranteed at all and should be seen as a special case, unless for
>>some reason you know all your files are that way (and they typically
>>aren't).
>
> Okay.  My files all come from the same source.  So if I check to see
> if timebase = 1/framerate, and if it is, then I can use pts or
> best_effort_timestamp as the frame numbers (assuming stream.start_time
> is zero).
>
> Why would timebase be anything other than 1/framerate?  I thought timebase
> was in fact defined as 1/framerate.  That's what avcodec.h says.

Timebase simply defines the maximum granularity of your timestamps. If
for some reason (e.g. to synchronize frames with content from other
tracks in the same file) there can be cases where it needs to be finer
than 1/frame rate. If you just learn how to calculate with it (see the
formula in my earlier mail), you don't have to rely on the assumption
that PTS == frame number and it is not really more work. Good luck!


More information about the Libav-user mailing list