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

Robert Krüger krueger at lesspain.de
Mon Sep 16 18:21:01 CEST 2013


On Mon, Sep 16, 2013 at 4:19 PM, James Board <jpboard2 at yahoo.com> wrote:
>>Try looking at the documentation in the header files, in this case
>>avcodec.h. It should help you quite a bit.
>
> 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.

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,
decoding timestamp etc. are and this is not meant to diss you but
honest advice. You will not get far without that.

> previously discussing the inaccuracy of floating-point numbers and how I
> wanted
> to use frame numbers in editing, everyone said I should be using timestamps.
> Then I complained that timestamps were specified by floating-point numbers
> which aren't accurate.  Then Nicolas George said something like the
> timestamps
> stored internally were exact.  So where are those timestamps stored?
>
> When I asked how to calculate a timestamp as a function of the frame number,
> the answer was I can't do that.  Instead, I should merely read the
> timestamp.  Okay,
> I'm taking the advice.  Where do I read the timestamp from?  Is it stored in
> AVFrame, AVPacket, the stream, the CodecContext?   It it
> best_effort_timestamp?

yes, use best_effort_timestamp and multiply it by the corresponding
stream's time base.

BTW: If you really, really know that a stream has a constant frame
rate, you can indeed calculate the timestamp based the frame number.
You take into account that a stream's presentation time stamps might
not start at 0, though (check AVStream.start_time for that).

HTH


More information about the Libav-user mailing list