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

Robert Krüger krueger at lesspain.de
Mon Sep 16 20:46:04 CEST 2013


On Mon, Sep 16, 2013 at 6:50 PM, James Board <jpboard2 at yahoo.com> wrote:
>>> Yes, I looked at avcodec.h and could not find what I wanted.  When I was
>>
>>You wrote:
>>
>>    pts
>>    pkt_pts
>>    pkt_dts
>>    coded_picture_number
>>    display_picture_number
>>    best_effort_timestamp (the name of this one really worries me)
>>    pkt_pos
>>    pkt_duration
>>What do those all mean?  Can I use those to figure out which frame this is?
>>
>>All of these are documented there. That's why I thought you hadn't
>>looked at the docs.
>
> Actually, none of them (except pts) are defined there.  Most aren't
> even mentioned.  But they are mentioned in AVFrame.h

Sorry my mistake. With latest source code, what I am talking about
i.e. docs for the struct AVFrame, is in frame.h and there they are
documented.

>
>
>>My gut feeling is that the biggest problem is that you probably need
>>to read up on some basics, so the docs (which are quite OK IMHO) make
>>sense to you, so you know what a timebase, presentation timestamp,
>
> Yes, I definitely prefer reading docs then asking for help.  But what docs
> are you talking about?  I'm not aware of anything other than the source
> code.
>
> 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).

> (not time values) and to get the actual time value, you multiple them by the
> time base.  Is that correct?  I'm actually starting with frame numbers and I
> don't really need the time values, per se.  Can I merely use the pts or
> best_effort_timestamp and assume they equal the frame number?

No, in the case of CFR you can compute the frame number like so
frameNum = (best_effort_timestamp - stream.start_time)*timebase*fps,
e.g. let's say you have a timebaste of 1/1000, a start_time of 200, a
frame pts of 600 and 25 FPS, so the frame number will be
(600-200)/1000*25 = 10, i.e. the 10th frame will have a pts of 600.

>
> Also, will the libs do anything behind the scenes to duplicate frames for
> whatever reason (like to meet some CFR rate)?  I don't want that.

No, you will just get frame after frame with their time stamps. What
you're talking about happens in the ffmpeg CL tool but IIRC someone
else already mentioned that in one of your threads.

HTH


More information about the Libav-user mailing list