lavf: inspect more frames for fps when container time base is coarse
As per issue2629, most 23.976fps matroska H.264 files are incorrectly detected as 24fps, as the matroska timestamps usually have only millisecond precision. Fix that by doubling the amount of timestamps inspected for frame rate for streams that have coarse time base. This also fixes 29.970 detection in matroska. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit78431098f9) Tested with mplayer based on this report http://thread.gmane.org/gmane.comp.video.mplayer.user/66043/focus=66063 Signed-off-by: Reinhard Tartler <siretart@tauware.de> (cherry picked from commit7c152a458d)
This commit is contained in:
@@ -2205,12 +2205,20 @@ int av_find_stream_info(AVFormatContext *ic)
|
||||
|
||||
/* check if one codec still needs to be handled */
|
||||
for(i=0;i<ic->nb_streams;i++) {
|
||||
int fps_analyze_framecount = 20;
|
||||
|
||||
st = ic->streams[i];
|
||||
if (!has_codec_parameters(st->codec))
|
||||
break;
|
||||
/* if the timebase is coarse (like the usual millisecond precision
|
||||
of mkv), we need to analyze more frames to reliably arrive at
|
||||
the correct fps */
|
||||
if (av_q2d(st->time_base) > 0.0005)
|
||||
fps_analyze_framecount *= 2;
|
||||
/* variable fps and no guess at the real fps */
|
||||
if( tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num)
|
||||
&& duration_count[i]<20 && st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
&& duration_count[i] < fps_analyze_framecount
|
||||
&& st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
break;
|
||||
if(st->parser && st->parser->parser->split && !st->codec->extradata)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user