Fixes detection of some TV sample as 24.5 FPS. With the patch applied, it's detected as 25 FPS. --- libavformat/utils.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/libavformat/utils.c b/libavformat/utils.c index fbd8b58ac2..778a82aeee 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3903,6 +3903,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st->info->codec_info_duration) { int best_fps = 0; double best_error = 0.01; + AVRational codec_frame_rate = av_inv_q(avctx->time_base); if (st->info->codec_info_duration >= INT64_MAX / st->time_base.num / 2|| st->info->codec_info_duration_fields >= INT64_MAX / st->time_base.den || @@ -3924,6 +3925,27 @@ FF_ENABLE_DEPRECATION_WARNINGS best_fps = std_fps.num; } } + if (avctx->ticks_per_frame > 0) + codec_frame_rate.num /= avctx->ticks_per_frame; + for (j = 0; j < MAX_STD_TIMEBASES; j++) { + AVRational std_fps = { get_std_framerate(j), 12 * 1001 }; + double error = fabs(av_q2d(st->avg_frame_rate) / + av_q2d(std_fps) - 1); + + if (error < best_error) { + best_error = error; + best_fps = std_fps.num; + } + + if (codec_frame_rate.num > 0 && codec_frame_rate.den > 0) { + error = fabs(av_q2d(codec_frame_rate) / + av_q2d(std_fps) - 1); + if (error < best_error) { + best_error = error; + best_fps = std_fps.num; + } + } + } if (best_fps) av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den, best_fps, 12 * 1001, INT_MAX); -- 2.11.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel