[Libav-user] newbie question: what is the appropriate/best way to obtain frame_rate from a video and how to control it when decoding video?

Michael Chisholm chisholm at mitre.org
Mon Dec 19 19:18:54 CET 2011


I've struggled myself with this.  There are a lot more framerate-related 
fields than that lying around.  The ones I know of (in ffmpeg 0.6.3) are 
(stream=AVStream, cc=AVCodecContext):

stream->time_base
stream->r_frame_rate
stream->avg_frame_rate
cc->time_base
cc->ticks_per_frame

(you'd think you could maybe derive framerate from the last)  I am no 
expert, but my guess is that not all containers contain a framerate 
field somewhere for tools to read.  So libav* tries to estimate one from 
timing information.  E.g. in my app I can read from a udp multicast 
network stream, and even for the same stream, each time I run the app, 
it shows a slightly different framerate (as shown by dump_format). 
Maybe because it sees a different subsequence of timestamps, or the 
relative distribution in time of those timestamps might be slightly 
different, ... I don't know.  In my app, I settled on 
stream->avg_frame_rate for my purposes.

As far as controlling it, I'm not sure what you mean... did you just 
want to decode at the frame rate of the stream, or somehow manipulate 
the the video to change its framerate?

Andy

On 12/19/2011 1:25 AM, Yingzhou Zhang wrote:
> hey there.
>
> I have googled a little bit,found 2 way
> 1:AVFormatContext->streams->time_base.num/den?
> 2:AVCodecContext->  streams->r_frame_rate?
>
> However the output of the 2 ways are not the same??
>
> Could you tell me what is the exact way to get frame_rate and how to
> control it when decoding video?
>
> Thanks a lot
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user



More information about the Libav-user mailing list