diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-14 18:53:05 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-14 19:20:23 +0200 |
commit | 45bd0d15f453fbd52d5e47f34860ac32ca2a9b16 (patch) | |
tree | 24e7ad5c9891ea7c4ffcb18496c6197856875eca /libavformat/utils.c | |
parent | 572781b25f98f99f2255404810ac33168bf28482 (diff) | |
download | ffmpeg-45bd0d15f453fbd52d5e47f34860ac32ca2a9b16.tar.gz |
lavf: fix fps detection with PAFF H.264
Fixes Ticket1065
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 745dcaa8d0..a20849c713 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2685,7 +2685,10 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) av_log(ic, AV_LOG_WARNING, "max_analyze_duration %d reached at %"PRId64"\n", ic->max_analyze_duration, t); break; } - st->info->codec_info_duration += pkt->duration; + if (pkt->duration) { + st->info->codec_info_duration += pkt->duration; + st->info->codec_info_duration_fields += st->parser && st->codec->ticks_per_frame==2 ? st->parser->repeat_pict + 1 : 2; + } } #if FF_API_R_FRAME_RATE { @@ -2796,13 +2799,13 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) } /* estimate average framerate if not set by demuxer */ - if (st->codec_info_nb_frames>2 && !st->avg_frame_rate.num && st->info->codec_info_duration) { + if (st->info->codec_info_duration_fields && !st->avg_frame_rate.num && st->info->codec_info_duration) { int best_fps = 0; double best_error = 0.01; av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den, - (st->codec_info_nb_frames-2)*(int64_t)st->time_base.den, - st->info->codec_info_duration*(int64_t)st->time_base.num, 60000); + st->info->codec_info_duration_fields*(int64_t)st->time_base.den, + st->info->codec_info_duration*2*(int64_t)st->time_base.num, 60000); /* round guessed framerate to a "standard" framerate if it's * within 1% of the original estimate*/ |