Gus Wirth <[email protected]> added the comment:

Subversion revision r20458 breaks playback of certain mp4 files. Specifically,
the recalculation of the dts_shift cause a mis-calculation of the frame rates.

This relates directly to issue 2246.

A sample file called r20458-breaks-mp4-playback.mp4 has been uploaded to the
ftp site in a directory called r20458-breaks-mp4-playback.

Description:

Revision 20458 changed the calculation of the dts shift. When certain mp4
files are played, the wrong frame rate is calculated and the program emits
'too many video packets in the buffer' messages.

If I revert a portion of the patch, playback is fixed.

Initial analysis before the patch:

-------begin---------------
[gus@falcon ffmpeg-trunk]$ ./ffmpeg -v 9 -loglevel 99 -i
../r20458-breaks-mp4-playback.mp4
FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jan 21 2011 10:53:47 with gcc 4.5.1 20100924 (Red Hat 4.5.1-4)
  configuration: --prefix=/usr --enable-debug=3 --disable-stripping
--disable-indevs --disable-outdev=audio_beos --disable-outdev=oss
  libavutil     50.36. 0 / 50.36. 0
  libavcore      0.16. 1 /  0.16. 1
  libavcodec    52.108. 0 / 52.108. 0
  libavformat   52.93. 0 / 52.93. 0
  libavdevice   52. 2. 3 / 52. 2. 3
  libavfilter    1.74. 0 /  1.74. 0
  libswscale     0.12. 0 /  0.12. 0
[NULL @ 0xa5374c0] Probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xa5374c0] ISO: File Type Major Brand: isom
[h264 @ 0xa53a540] no picture
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xa5374c0] Probe buffer size limit 5000000 reached

Seems stream 0 codec frame rate differs from container frame rate: 47.95
(5994/125) -> 119.88 (120000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../r20458-breaks-mp4-playback.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isom
    creation_time   : 2011-01-03 03:34:30
  Duration: 00:23:24.54, start: 0.041708, bitrate: 58 kb/s
    Stream #0.0(und), 987, 1/360000: Video: h264, yuv420p, 848x480 [PAR 1:1 DAR
53:30], 125/5994, 1005 kb/s, 24.01 fps, 119.88 tbr, 360k tbn, 47.95 tbc
    Metadata:
      creation_time   : 2011-01-03 03:34:30
    Stream #0.1(und), 0, 1/48000: Audio: aac, stereo, s16, 127 kb/s
    Metadata:
      creation_time   : 2011-01-03 03:34:32
At least one output file must be specified
----------end-----------------------

Analysis after applying the patch:

-------begin---------------
[gus@falcon ffmpeg-trunk]$ ./ffmpeg -v 9 -loglevel 99 -i
../r20458-breaks-mp4-playback.mp4
FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jan 21 2011 11:10:48 with gcc 4.5.1 20100924 (Red Hat 4.5.1-4)
  configuration: --prefix=/usr --enable-debug=3 --disable-stripping
--disable-indevs --disable-outdev=audio_beos --disable-outdev=oss
  libavutil     50.36. 0 / 50.36. 0
  libavcore      0.16. 1 /  0.16. 1
  libavcodec    52.108. 0 / 52.108. 0
  libavformat   52.93. 0 / 52.93. 0
  libavdevice   52. 2. 3 / 52. 2. 3
  libavfilter    1.74. 0 /  1.74. 0
  libswscale     0.12. 0 /  0.12. 0
[NULL @ 0x8fda4c0] Probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x8fda4c0] ISO: File Type Major Brand: isom
[h264 @ 0x8fdd540] no picture
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x8fda4c0] All info found

Seems stream 0 codec frame rate differs from container frame rate: 47.95
(5994/125) -> 23.98 (24000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../r20458-breaks-mp4-playback.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isom
    creation_time   : 2011-01-03 03:34:30
  Duration: 00:23:24.54, start: 0.000000, bitrate: 58 kb/s
    Stream #0.0(und), 21, 1/360000: Video: h264, yuv420p, 848x480 [PAR 1:1 DAR
53:30], 125/5994, 1005 kb/s, 24.01 fps, 23.98 tbr, 360k tbn, 47.95 tbc
    Metadata:
      creation_time   : 2011-01-03 03:34:30
    Stream #0.1(und), 24, 1/48000: Audio: aac, 48000 Hz, stereo, s16, 127 kb/s
    Metadata:
      creation_time   : 2011-01-03 03:34:32
At least one output file must be specified
-------end---------------

Here's the actual patch:
Index: libavformat/mov.c
===================================================================
--- libavformat/mov.c   (revision 26402)
+++ libavformat/mov.c   (working copy)
@@ -1493,8 +1493,6 @@
 
         sc->ctts_data[i].count   = count;
         sc->ctts_data[i].duration= duration;
-        if (duration < 0)
-            sc->dts_shift = FFMAX(sc->dts_shift, -duration);
     }
 
     dprintf(c->fc, "dts shift %d\n", sc->dts_shift);

________________________________________________
FFmpeg issue tracker <[email protected]>
<https://roundup.ffmpeg.org/issue2246>
________________________________________________
Index: libavformat/mov.c
===================================================================
--- libavformat/mov.c	(revision 26402)
+++ libavformat/mov.c	(working copy)
@@ -1493,8 +1493,6 @@
 
         sc->ctts_data[i].count   = count;
         sc->ctts_data[i].duration= duration;
-        if (duration < 0)
-            sc->dts_shift = FFMAX(sc->dts_shift, -duration);
     }
 
     dprintf(c->fc, "dts shift %d\n", sc->dts_shift);

Reply via email to