Opened 12 years ago

Closed 12 years ago

#1180 closed defect (fixed)

video cutting/extraction leads to various a/v sync (when possible)

Reported by: Clément Bœsch Owned by:
Priority: important Component: ffmpeg
Version: git-master Keywords: desync regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Using a random AVI (http://samples.ffmpeg.org/avi/GoneNutty.avi) and trying to extract a scene leads to various a/v sync issues:

% ./ffmpeg -i ~/samples/GoneNutty.avi -ss 120 -c copy -y cut.avi
ffmpeg version N-39647-g1d13032 Copyright (c) 2000-2012 the FFmpeg developers
  built on Apr  9 2012 17:52:37 with gcc 4.7.0 20120324 (prerelease)
  configuration: --enable-libfreetype --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-x11grab --enable-libopenjpeg --enable-libass --enable-libmodplug
  libavutil      51. 45.100 / 51. 45.100
  libavcodec     54. 14.100 / 54. 14.100
  libavformat    54.  3.100 / 54.  3.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 67.101 /  2. 67.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 10.100 /  0. 10.100
  libpostproc    52.  0.100 / 52.  0.100
[mpeg4 @ 0x1aed720] Invalid and inefficient vfw-avi packed B frames detected
Input #0, avi, from '/home/ubitux/samples/GoneNutty.avi':
  Metadata:
    encoder         : Nandub v1.0rc2
  Duration: 00:04:38.84, start: 0.000000, bitrate: 1345 kb/s
    Stream #0:0: Video: mpeg4 (DX50 / 0x30355844), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 25 fps, 25 tbr, 25 tbn, 30k tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, s16, 192 kb/s
Output #0, avi, to 'cut.avi':
  Metadata:
    ISFT            : Lavf54.3.100
    Stream #0:0: Video: mpeg4 (DX50 / 0x30355844), yuv420p, 640x352 [SAR 1:1 DAR 20:11], q=2-31, 25 fps, 25 tbn, 25 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 3879 fps=0.0 q=-1.0 Lsize=   23751kB time=00:02:38.84 bitrate=1224.9kbits/s    
video:19808kB audio:3723kB global headers:0kB muxing overhead 0.935748%

Playback results with different players:

  • ffplay: invalid frame rate, playback mostly broken
  • MPlayer: no video is displayed for a few seconds, and then video starts (with -correct-pts the video is freezed for a while)
  • VLC: samples rate seems insanely high, no video at first, then the video starts, and sounds is still way too fast
  • mplayer2: seems to actually deal with it pretty well

Even though mplayer2 seems to handle it, I believe the file is broken and something should be fixed.

Note: specifying -ss before the input doesn't work:

./ffmpeg -ss 120 -i ~/samples/GoneNutty.avi -c copy -y cut2.avi
ffmpeg version N-39647-g1d13032 Copyright (c) 2000-2012 the FFmpeg developers
  built on Apr  9 2012 17:52:37 with gcc 4.7.0 20120324 (prerelease)
  configuration: --enable-libfreetype --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-x11grab --enable-libopenjpeg --enable-libass --enable-libmodplug
  libavutil      51. 45.100 / 51. 45.100
  libavcodec     54. 14.100 / 54. 14.100
  libavformat    54.  3.100 / 54.  3.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 67.101 /  2. 67.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 10.100 /  0. 10.100
  libpostproc    52.  0.100 / 52.  0.100
[mpeg4 @ 0x2857720] Invalid and inefficient vfw-avi packed B frames detected
Input #0, avi, from '/home/ubitux/samples/GoneNutty.avi':
  Metadata:
    encoder         : Nandub v1.0rc2
  Duration: 00:04:38.84, start: 0.000000, bitrate: 1345 kb/s
    Stream #0:0: Video: mpeg4 (DX50 / 0x30355844), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 25 fps, 25 tbr, 25 tbn, 30k tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, s16, 192 kb/s
Output #0, avi, to 'cut2.avi':
  Metadata:
    ISFT            : Lavf54.3.100
    Stream #0:0: Video: mpeg4 (DX50 / 0x30355844), yuv420p, 640x352 [SAR 1:1 DAR 20:11], q=2-31, 25 fps, 25 tbn, 25 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[avi @ 0x2858fe0] Application provided invalid, non monotonically increasing dts to muxer in stream 1: -14 >= -14
av_interleaved_write_frame(): Invalid argument

Change History (4)

in reply to:  description comment:1 by Clément Bœsch, 12 years ago

[...]

Playback results with different players:

  • ffplay: invalid frame rate, playback mostly broken
  • MPlayer: no video is displayed for a few seconds, and then video starts (with -correct-pts the video is freezed for a while)
  • VLC: samples rate seems insanely high, no video at first, then the video starts, and sounds is still way too fast
  • mplayer2: seems to actually deal with it pretty well

Even though mplayer2 seems to handle it, I believe the file is broken and something should be fixed.

Actually I was wrong about mplayer2; the sound is shifted. So no player seems to deal well with the output file.

comment:2 by Carl Eugen Hoyos, 12 years ago

Component: undeterminedFFmpeg
Keywords: desync regression added
Priority: normalimportant
Status: newopen
Version: unspecifiedgit-master

Regression since 492cc1, reproducible with

ffmpeg -i GoneNutty.avi -ss 120 -acodec copy cut.avi
Last edited 12 years ago by Carl Eugen Hoyos (previous) (diff)

comment:3 by Clément Bœsch, 12 years ago

Indeed, thanks for tracking down the origin of the issue. I relayed the issue to Anton, he might come up with a better solution than reverting the commit.

On the other hand, reverting it doesn't solve the second error I mentioned (with -ss as input option):

[...]
[avi @ 0x2858fe0] Application provided invalid, non monotonically increasing dts to muxer in stream 1: -14 >= -14
av_interleaved_write_frame(): Invalid argument

Also, it doesn't solve a similar issue I have with a random MKV: http://samples.ffmpeg.org/Matroska/ppd.mkv

Playback is out of sync again after something like:

./ffmpeg -i ppd.mkv -ss 150 -c copy -y out.mkv
Last edited 12 years ago by Clément Bœsch (previous) (diff)

comment:4 by Michael Niedermayer, 12 years ago

Reproduced by developer: set
Resolution: fixed
Status: openclosed

Should be fixed, and it seems you need -fflags +genpts for the -ss case currently

Note: See TracTickets for help on using tickets.