[FFmpeg-user] What is a good way to calculate the frame rate of a video file using ffmpeg?

Li codingpotatolinda at gmail.com
Wed Sep 25 22:13:18 CEST 2013


I find two possible ways:

(Option 1) inVStruct.inVideoStream->r_frame_rate.num /
inVStruct.inVideoStream->r_frame_rate.den

[comment:] correct for some videos. Not always correct. it is libavformats
guess, not exact. (see
http://ffmpeg.org/pipermail/ffmpeg-devel/2005-May/003079.html )

(Option 2) (double) inVStruct.inCodecContext->time_base.den /
inVStruct.inCodecContext->time_base.num /
inVStruct.inCodecContext->ticks_per_frame);

[comment:] correct for some videos. Not always correct.

Please recommend one for all video files.
Thanks!


More information about the ffmpeg-user mailing list