aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@sandy.tauware.de>2011-04-30 08:18:32 +0200
committerReinhard Tartler <siretart@sandy.tauware.de>2011-04-30 08:18:32 +0200
commit9848e1be2d288747b7f39743ed81481780a7ca47 (patch)
treed01ed1413ef2f4611a10d81775b491941a1e9c83
parent66ebf37c735158e060c5acf8df62391b8b6182ef (diff)
downloadffmpeg-9848e1be2d288747b7f39743ed81481780a7ca47.tar.gz
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 commit 78431098f9e306ebe27e7698d0ae539e3df2afe9) 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 commit 7c152a458d3fb0a2fb1aef1f05bfee90fe70697e)
-rw-r--r--libavformat/utils.c10
-rw-r--r--tests/ref/fate/cscd414
2 files changed, 216 insertions, 208 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6224a35d4d..b73d98473f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -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;
diff --git a/tests/ref/fate/cscd b/tests/ref/fate/cscd
index 75a7725c18..8b89e80a10 100644
--- a/tests/ref/fate/cscd
+++ b/tests/ref/fate/cscd
@@ -1,208 +1,208 @@
0, 0, 270000, 0xf90015d8
-0, 2880, 270000, 0xf90015d8
-0, 5760, 270000, 0xf90015d8
-0, 8640, 270000, 0xf90015d8
-0, 11520, 270000, 0xf90015d8
-0, 14400, 270000, 0xf90015d8
-0, 17280, 270000, 0xf90015d8
-0, 20160, 270000, 0xf90015d8
-0, 23040, 270000, 0xf90015d8
-0, 25920, 270000, 0xf90015d8
-0, 28800, 270000, 0xf90015d8
-0, 31680, 270000, 0xf90015d8
-0, 34560, 270000, 0xf90015d8
-0, 37440, 270000, 0xf90015d8
-0, 40320, 270000, 0xf90015d8
-0, 43200, 270000, 0xf90015d8
-0, 46080, 270000, 0xf90015d8
-0, 48960, 270000, 0xf90015d8
-0, 51840, 270000, 0xf90015d8
-0, 54720, 270000, 0xf90015d8
-0, 57600, 270000, 0xf90015d8
-0, 60480, 270000, 0xf90015d8
-0, 63360, 270000, 0xf90015d8
-0, 66240, 270000, 0xf90015d8
-0, 69120, 270000, 0xf90015d8
-0, 72000, 270000, 0xf90015d8
-0, 74880, 270000, 0xf90015d8
-0, 77760, 270000, 0xf90015d8
-0, 80640, 270000, 0xf90015d8
-0, 83520, 270000, 0xf90015d8
-0, 86400, 270000, 0xf90015d8
-0, 89280, 270000, 0xf90015d8
-0, 92160, 270000, 0xf90015d8
-0, 95040, 270000, 0xf90015d8
-0, 97920, 270000, 0xf90015d8
-0, 100800, 270000, 0xf90015d8
-0, 103680, 270000, 0xf90015d8
-0, 106560, 270000, 0xf90015d8
-0, 109440, 270000, 0xf90015d8
-0, 112320, 270000, 0x1f9c15d8
-0, 115200, 270000, 0x436f15d8
-0, 118080, 270000, 0xe90115d8
-0, 120960, 270000, 0xe90115d8
-0, 123840, 270000, 0x8ea215d8
-0, 126720, 270000, 0x424015d8
-0, 129600, 270000, 0x0ce315d8
-0, 132480, 270000, 0x14bc15d8
-0, 135360, 270000, 0x2a9215d8
-0, 138240, 270000, 0x233f15d8
-0, 141120, 270000, 0x764b15d8
-0, 144000, 270000, 0xf76115d8
-0, 146880, 270000, 0xbbe015d8
-0, 149760, 270000, 0x95af15d8
-0, 152640, 270000, 0x324815d8
-0, 155520, 270000, 0x311915d8
-0, 158400, 270000, 0x090ef191
-0, 161280, 270000, 0xd88974dc
-0, 164160, 270000, 0xfa7f58df
-0, 167040, 270000, 0x78f849c3
-0, 169920, 270000, 0xae174892
-0, 172800, 270000, 0x9d4e2332
-0, 175680, 270000, 0x874b09b4
-0, 178560, 270000, 0x4069fed6
-0, 181440, 270000, 0x4069fed6
-0, 184320, 270000, 0x4069fed6
-0, 187200, 270000, 0x4069fed6
-0, 190080, 270000, 0x4069fed6
-0, 192960, 270000, 0x4069fed6
-0, 195840, 270000, 0x4069fed6
-0, 198720, 270000, 0x4069fed6
-0, 201600, 270000, 0x4069fed6
-0, 204480, 270000, 0x4069fed6
-0, 207360, 270000, 0x4069fed6
-0, 210240, 270000, 0x773db046
-0, 213120, 270000, 0x773db046
-0, 216000, 270000, 0x773db046
-0, 218880, 270000, 0x773db046
-0, 221760, 270000, 0x773db046
-0, 224640, 270000, 0x773db046
-0, 227520, 270000, 0x773db046
-0, 230400, 270000, 0x773db046
-0, 233280, 270000, 0x773db046
-0, 236160, 270000, 0x773db046
-0, 239040, 270000, 0x773db046
-0, 241920, 270000, 0x773db046
-0, 244800, 270000, 0x773db046
-0, 247680, 270000, 0x773db046
-0, 250560, 270000, 0x773db046
-0, 253440, 270000, 0x773db046
-0, 256320, 270000, 0x773db046
-0, 259200, 270000, 0x17b9aec9
-0, 262080, 270000, 0x622fad4c
-0, 264960, 270000, 0xdaea3aef
-0, 267840, 270000, 0x61bb10e3
-0, 270720, 270000, 0xfc37ee0c
-0, 273600, 270000, 0x50dbd01e
-0, 276480, 270000, 0xcd66c27c
-0, 279360, 270000, 0xd13f1e4f
-0, 282240, 270000, 0xa4a2dbf5
-0, 285120, 270000, 0xf302c9ab
-0, 288000, 270000, 0x4479f7fe
-0, 290880, 270000, 0x1afe92c8
-0, 293760, 270000, 0x3007f4c3
-0, 296640, 270000, 0x5834c096
-0, 299520, 270000, 0x40109126
-0, 302400, 270000, 0x0a7b8882
-0, 305280, 270000, 0x15b8635d
-0, 308160, 270000, 0xeaa5598e
-0, 311040, 270000, 0x0b7b5489
-0, 313920, 270000, 0x0b7b5489
-0, 316800, 270000, 0x0b7b5489
-0, 319680, 270000, 0x0b7b5489
-0, 322560, 270000, 0x8f0e6eaa
-0, 325440, 270000, 0xc46fc0f2
-0, 328320, 270000, 0xadd7e605
-0, 331200, 270000, 0x9d23a056
-0, 334080, 270000, 0x365afa63
-0, 336960, 270000, 0x6ac3bda2
-0, 339840, 270000, 0x14f5daf2
-0, 342720, 270000, 0x4b3afb6a
-0, 345600, 270000, 0x1a3302e3
-0, 348480, 270000, 0x1a3302e3
-0, 351360, 270000, 0x1a3302e3
-0, 354240, 270000, 0x1a3302e3
-0, 357120, 270000, 0xc15526e2
-0, 360000, 270000, 0x3dd73006
-0, 362880, 270000, 0x60abb5bc
-0, 365760, 270000, 0xb960c27c
-0, 368640, 270000, 0x8fa4c01c
-0, 371520, 270000, 0x8fa4c01c
-0, 374400, 270000, 0x8fa4c01c
-0, 377280, 270000, 0xb20dcc38
-0, 380160, 270000, 0x03c6ad3c
-0, 383040, 270000, 0xe550b194
-0, 385920, 270000, 0xe550b194
-0, 388800, 270000, 0xe550b194
-0, 391680, 270000, 0xe550b194
-0, 394560, 270000, 0xe550b194
-0, 397440, 270000, 0xe550b194
-0, 400320, 270000, 0xe550b194
-0, 403200, 270000, 0xe550b194
-0, 406080, 270000, 0xe550b194
-0, 408960, 270000, 0xe550b194
-0, 411840, 270000, 0xe550b194
-0, 414720, 270000, 0xe550b194
-0, 417600, 270000, 0xe550b194
-0, 420480, 270000, 0xe550b194
-0, 423360, 270000, 0x4550a014
-0, 426240, 270000, 0xaf639da8
-0, 429120, 270000, 0xe4229da8
-0, 432000, 270000, 0x315d9da8
-0, 434880, 270000, 0x7e899da8
-0, 437760, 270000, 0x99b9a8a0
-0, 440640, 270000, 0x4588ac2a
-0, 443520, 270000, 0x1e79ae6e
-0, 446400, 270000, 0xa003cb14
-0, 449280, 270000, 0x03ef1bb8
-0, 452160, 270000, 0x3b3f30fc
-0, 455040, 270000, 0x4dad3525
-0, 457920, 270000, 0x5b600c12
-0, 460800, 270000, 0x75a1fab3
-0, 463680, 270000, 0xc9f7d9ad
-0, 466560, 270000, 0x9eaec58d
-0, 469440, 270000, 0xb91bc3e8
-0, 472320, 270000, 0x77bdbbfb
-0, 475200, 270000, 0x77bdbbfb
-0, 478080, 270000, 0x77bdbbfb
-0, 480960, 270000, 0x77bdbbfb
-0, 483840, 270000, 0x77bdbbfb
-0, 486720, 270000, 0x77bdbbfb
-0, 489600, 270000, 0x3d54eac2
-0, 492480, 270000, 0x3d54eac2
-0, 495360, 270000, 0x3d54eac2
-0, 498240, 270000, 0x3d54eac2
-0, 501120, 270000, 0x3d54eac2
-0, 504000, 270000, 0x3d54eac2
-0, 506880, 270000, 0x3d54eac2
-0, 509760, 270000, 0x3d54eac2
-0, 512640, 270000, 0x3d54eac2
-0, 515520, 270000, 0x3d54eac2
-0, 518400, 270000, 0x3d54eac2
-0, 521280, 270000, 0x3d54eac2
-0, 524160, 270000, 0x3d54eac2
-0, 527040, 270000, 0x3d54eac2
-0, 529920, 270000, 0x3d54eac2
-0, 532800, 270000, 0x3d54eac2
-0, 535680, 270000, 0x3d54eac2
-0, 538560, 270000, 0x3d54eac2
-0, 541440, 270000, 0x3d54eac2
-0, 544320, 270000, 0x5f3609ba
-0, 547200, 270000, 0x80921b0c
-0, 550080, 270000, 0x80921b0c
-0, 552960, 270000, 0x80921b0c
-0, 555840, 270000, 0x80921b0c
-0, 558720, 270000, 0x80921b0c
-0, 561600, 270000, 0x80921b0c
-0, 564480, 270000, 0x80921b0c
-0, 567360, 270000, 0x80921b0c
-0, 570240, 270000, 0x80921b0c
-0, 573120, 270000, 0x80921b0c
-0, 576000, 270000, 0x80921b0c
-0, 578880, 270000, 0x80921b0c
-0, 581760, 270000, 0x80921b0c
-0, 584640, 270000, 0x80921b0c
-0, 587520, 270000, 0x80921b0c
-0, 590400, 270000, 0x80921b0c
-0, 593280, 270000, 0xf0e626a8
-0, 596160, 270000, 0xf0e626a8
+0, 2865, 270000, 0xf90015d8
+0, 5729, 270000, 0xf90015d8
+0, 8594, 270000, 0xf90015d8
+0, 11459, 270000, 0xf90015d8
+0, 14324, 270000, 0xf90015d8
+0, 17188, 270000, 0xf90015d8
+0, 20053, 270000, 0xf90015d8
+0, 22918, 270000, 0xf90015d8
+0, 25782, 270000, 0xf90015d8
+0, 28647, 270000, 0xf90015d8
+0, 31512, 270000, 0xf90015d8
+0, 34377, 270000, 0xf90015d8
+0, 37241, 270000, 0xf90015d8
+0, 40106, 270000, 0xf90015d8
+0, 42971, 270000, 0xf90015d8
+0, 45836, 270000, 0xf90015d8
+0, 48700, 270000, 0xf90015d8
+0, 51565, 270000, 0xf90015d8
+0, 54430, 270000, 0xf90015d8
+0, 57294, 270000, 0xf90015d8
+0, 60159, 270000, 0xf90015d8
+0, 63024, 270000, 0xf90015d8
+0, 65889, 270000, 0xf90015d8
+0, 68753, 270000, 0xf90015d8
+0, 71618, 270000, 0xf90015d8
+0, 74483, 270000, 0xf90015d8
+0, 77347, 270000, 0xf90015d8
+0, 80212, 270000, 0xf90015d8
+0, 83077, 270000, 0xf90015d8
+0, 85942, 270000, 0xf90015d8
+0, 88806, 270000, 0xf90015d8
+0, 91671, 270000, 0xf90015d8
+0, 94536, 270000, 0xf90015d8
+0, 97401, 270000, 0xf90015d8
+0, 100265, 270000, 0xf90015d8
+0, 103130, 270000, 0xf90015d8
+0, 105995, 270000, 0xf90015d8
+0, 108859, 270000, 0xf90015d8
+0, 111724, 270000, 0x1f9c15d8
+0, 114589, 270000, 0x436f15d8
+0, 117454, 270000, 0xe90115d8
+0, 120318, 270000, 0xe90115d8
+0, 123183, 270000, 0x8ea215d8
+0, 126048, 270000, 0x424015d8
+0, 128912, 270000, 0x0ce315d8
+0, 131777, 270000, 0x14bc15d8
+0, 134642, 270000, 0x2a9215d8
+0, 137507, 270000, 0x233f15d8
+0, 140371, 270000, 0x764b15d8
+0, 143236, 270000, 0xf76115d8
+0, 146101, 270000, 0xbbe015d8
+0, 148966, 270000, 0x95af15d8
+0, 151830, 270000, 0x324815d8
+0, 154695, 270000, 0x311915d8
+0, 157560, 270000, 0x090ef191
+0, 160424, 270000, 0xd88974dc
+0, 163289, 270000, 0xfa7f58df
+0, 166154, 270000, 0x78f849c3
+0, 169019, 270000, 0xae174892
+0, 171883, 270000, 0x9d4e2332
+0, 174748, 270000, 0x874b09b4
+0, 177613, 270000, 0x4069fed6
+0, 180477, 270000, 0x4069fed6
+0, 183342, 270000, 0x4069fed6
+0, 186207, 270000, 0x4069fed6
+0, 189072, 270000, 0x4069fed6
+0, 191936, 270000, 0x4069fed6
+0, 194801, 270000, 0x4069fed6
+0, 197666, 270000, 0x4069fed6
+0, 200531, 270000, 0x4069fed6
+0, 203395, 270000, 0x4069fed6
+0, 206260, 270000, 0x4069fed6
+0, 209125, 270000, 0x773db046
+0, 211989, 270000, 0x773db046
+0, 214854, 270000, 0x773db046
+0, 217719, 270000, 0x773db046
+0, 220584, 270000, 0x773db046
+0, 223448, 270000, 0x773db046
+0, 226313, 270000, 0x773db046
+0, 229178, 270000, 0x773db046
+0, 232042, 270000, 0x773db046
+0, 234907, 270000, 0x773db046
+0, 237772, 270000, 0x773db046
+0, 240637, 270000, 0x773db046
+0, 243501, 270000, 0x773db046
+0, 246366, 270000, 0x773db046
+0, 249231, 270000, 0x773db046
+0, 252095, 270000, 0x773db046
+0, 254960, 270000, 0x773db046
+0, 257825, 270000, 0x17b9aec9
+0, 260690, 270000, 0x622fad4c
+0, 263554, 270000, 0xdaea3aef
+0, 266419, 270000, 0x61bb10e3
+0, 269284, 270000, 0xfc37ee0c
+0, 272149, 270000, 0x50dbd01e
+0, 275013, 270000, 0xcd66c27c
+0, 277878, 270000, 0xd13f1e4f
+0, 280743, 270000, 0xa4a2dbf5
+0, 283607, 270000, 0xf302c9ab
+0, 286472, 270000, 0x4479f7fe
+0, 289337, 270000, 0x1afe92c8
+0, 292202, 270000, 0x3007f4c3
+0, 295066, 270000, 0x5834c096
+0, 297931, 270000, 0x40109126
+0, 300796, 270000, 0x0a7b8882
+0, 303660, 270000, 0x15b8635d
+0, 306525, 270000, 0xeaa5598e
+0, 309390, 270000, 0x0b7b5489
+0, 312255, 270000, 0x0b7b5489
+0, 315119, 270000, 0x0b7b5489
+0, 317984, 270000, 0x0b7b5489
+0, 320849, 270000, 0x8f0e6eaa
+0, 323714, 270000, 0xc46fc0f2
+0, 326578, 270000, 0xadd7e605
+0, 329443, 270000, 0x9d23a056
+0, 332308, 270000, 0x365afa63
+0, 335172, 270000, 0x6ac3bda2
+0, 338037, 270000, 0x14f5daf2
+0, 340902, 270000, 0x4b3afb6a
+0, 343767, 270000, 0x1a3302e3
+0, 346631, 270000, 0x1a3302e3
+0, 349496, 270000, 0x1a3302e3
+0, 352361, 270000, 0x1a3302e3
+0, 355225, 270000, 0xc15526e2
+0, 358090, 270000, 0x3dd73006
+0, 360955, 270000, 0x60abb5bc
+0, 363820, 270000, 0xb960c27c
+0, 366684, 270000, 0x8fa4c01c
+0, 369549, 270000, 0x8fa4c01c
+0, 372414, 270000, 0x8fa4c01c
+0, 375279, 270000, 0xb20dcc38
+0, 378143, 270000, 0x03c6ad3c
+0, 381008, 270000, 0xe550b194
+0, 383873, 270000, 0xe550b194
+0, 386737, 270000, 0xe550b194
+0, 389602, 270000, 0xe550b194
+0, 392467, 270000, 0xe550b194
+0, 395332, 270000, 0xe550b194
+0, 398196, 270000, 0xe550b194
+0, 401061, 270000, 0xe550b194
+0, 403926, 270000, 0xe550b194
+0, 406790, 270000, 0xe550b194
+0, 409655, 270000, 0xe550b194
+0, 412520, 270000, 0xe550b194
+0, 415385, 270000, 0xe550b194
+0, 418249, 270000, 0xe550b194
+0, 421114, 270000, 0x4550a014
+0, 423979, 270000, 0xaf639da8
+0, 426844, 270000, 0xe4229da8
+0, 429708, 270000, 0x315d9da8
+0, 432573, 270000, 0x7e899da8
+0, 435438, 270000, 0x99b9a8a0
+0, 438302, 270000, 0x4588ac2a
+0, 441167, 270000, 0x1e79ae6e
+0, 444032, 270000, 0xa003cb14
+0, 446897, 270000, 0x03ef1bb8
+0, 449761, 270000, 0x3b3f30fc
+0, 452626, 270000, 0x4dad3525
+0, 455491, 270000, 0x5b600c12
+0, 458355, 270000, 0x75a1fab3
+0, 461220, 270000, 0xc9f7d9ad
+0, 464085, 270000, 0x9eaec58d
+0, 466950, 270000, 0xb91bc3e8
+0, 469814, 270000, 0x77bdbbfb
+0, 472679, 270000, 0x77bdbbfb
+0, 475544, 270000, 0x77bdbbfb
+0, 478408, 270000, 0x77bdbbfb
+0, 481273, 270000, 0x77bdbbfb
+0, 484138, 270000, 0x77bdbbfb
+0, 487003, 270000, 0x3d54eac2
+0, 489867, 270000, 0x3d54eac2
+0, 492732, 270000, 0x3d54eac2
+0, 495597, 270000, 0x3d54eac2
+0, 498462, 270000, 0x3d54eac2
+0, 501326, 270000, 0x3d54eac2
+0, 504191, 270000, 0x3d54eac2
+0, 507056, 270000, 0x3d54eac2
+0, 509920, 270000, 0x3d54eac2
+0, 512785, 270000, 0x3d54eac2
+0, 515650, 270000, 0x3d54eac2
+0, 518515, 270000, 0x3d54eac2
+0, 521379, 270000, 0x3d54eac2
+0, 524244, 270000, 0x3d54eac2
+0, 527109, 270000, 0x3d54eac2
+0, 529973, 270000, 0x3d54eac2
+0, 532838, 270000, 0x3d54eac2
+0, 535703, 270000, 0x3d54eac2
+0, 538568, 270000, 0x3d54eac2
+0, 541432, 270000, 0x5f3609ba
+0, 544297, 270000, 0x80921b0c
+0, 547162, 270000, 0x80921b0c
+0, 550027, 270000, 0x80921b0c
+0, 552891, 270000, 0x80921b0c
+0, 555756, 270000, 0x80921b0c
+0, 558621, 270000, 0x80921b0c
+0, 561485, 270000, 0x80921b0c
+0, 564350, 270000, 0x80921b0c
+0, 567215, 270000, 0x80921b0c
+0, 570080, 270000, 0x80921b0c
+0, 572944, 270000, 0x80921b0c
+0, 575809, 270000, 0x80921b0c
+0, 578674, 270000, 0x80921b0c
+0, 581538, 270000, 0x80921b0c
+0, 584403, 270000, 0x80921b0c
+0, 587268, 270000, 0x80921b0c
+0, 590133, 270000, 0xf0e626a8
+0, 592997, 270000, 0xf0e626a8