diff options
author | wm4 <nfxjfg@googlemail.com> | 2017-05-23 13:36:38 +0200 |
---|---|---|
committer | wm4 <nfxjfg@googlemail.com> | 2017-06-07 11:08:06 +0200 |
commit | 66cf78e932956eaa7d5a9dab8766efbfc1431e55 (patch) | |
tree | 6fb2a32d50643c5b00d5c7a149d2bba21a7f8142 /libavformat/utils.c | |
parent | 34c52005605d68f7cd1957b169b6732c7d2447d9 (diff) | |
download | ffmpeg-66cf78e932956eaa7d5a9dab8766efbfc1431e55.tar.gz |
lavf: consider codec framerate for framerate detection
Fixes detection of some TV sample as 24.5 FPS. With the patch applied,
it's detected as 25 FPS.
This is enabled for mpegts only.
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index c641377385..38d247c6cd 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3904,6 +3904,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st->info->codec_info_duration) { int best_fps = 0; double best_error = 0.01; + AVRational codec_frame_rate = avctx->framerate; 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,15 @@ FF_ENABLE_DEPRECATION_WARNINGS best_error = error; best_fps = std_fps.num; } + + if (ic->internal->prefer_codec_framerate && 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, |