[Ffmpeg-devel] Frame count/seeking

Todd Kirby ffmpeg.php
Sat Jul 2 02:31:06 CEST 2005


On 7/1/05, Kenneth Aafl?y <kenneth at aafloy.net> wrote:
> l?rdag 2. juli 2005, 01:47, skrev Ian Gowen:
> > Is there an easy way to determine the frame count of a file?
> > Right now what I'm doing is reading the whole file and keeping
> > a counter but needless to say that's slow; is there a better way?
> 
> If the format you are reading from has a parser that would be quicker!
> Still you
> 
> > Also, I'm a little fuzzy on how to interpret AVStream.time_base. How
> > do I get that in frames per second?
> 
> Let me see if I can figure out this:
> 
>  double rate = av_q2d(stream->r_frame_rate);

This has recently changed so If you need to be compatible with older
versions of ffmpeg do this:

#if LIBAVCODEC_BUILD > 4753
    rate = av_q2d(stream->r_frame_rate);
#else
    rate = stream->r_frame_rate / stream->r_frame_rate_base;
#endif





More information about the ffmpeg-devel mailing list