[Libav-user] Getting frame duration when decoding

Robert Krüger krueger at lesspain.de
Mon Jul 8 14:04:26 CEST 2013

On Mon, Jul 8, 2013 at 1:20 PM, Leonid Mokruschin <lyon at digispot.ru> wrote:
> Hi Vahid:
> perhaps you need to take into account pStream->codec.time_base and
> pStream->codec.ticks_per_frame. I believe that pStream->time_base matches to
> frame rate for interleaved video streams, whereas pStream->codec.time_base
> matches to field rate. E.g. for 25fps interleaved stream you will get
> time_base=1/25 but codec.time_base=1/50 and codec.ticks_per_frame==2.

No, there are cases where it is this way but there are many where the
stream time base is not the inverse of the frame rate. If your code
needs to deal with more or less arbitrary input files, this will not

Vahid, the best IMHO would be if you documented cases where the
formula above did not work and maybe add the output of ffprobe -i
<input file> -show_format -show_streams and then maybe the first few
frames/packets of ffprobe -i <input file> -show_packets -show_frames
(best only include video by using -select_streams 0, if video is
stream 0 in your case). That should give people here a better chance
to see if something is wrong with the values or if you are could do
something better. Maybe you have to resort to some sort of heuristics
based on statistics you put together.

More information about the Libav-user mailing list