Opened 3 years ago

Last modified 3 years ago

#9211 new defect

MPEG2 decoder timebase resets cause FFmpeg to lock up during concat or the output video to stutter

Reported by: nab622 Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by nab622)

I believe this is the same thing that is reported here:
https://ffmpeg.org/pipermail/ffmpeg-devel/2018-March/226706.html

In many MPEG2 (DVD) videos, the timebase resets during playback. FFmpeg gets confused by this, and behaves unpredictably. Most notably, during a "-i concat:VTS_01_1.VOB|VTS_01_2.VOB|VTS_01_3.VOB" operation, some videos will cause FFmpeg to get stuck in an infinite loop, generating thousands of "NON-MONOTONOUS DTS" and "Buffer underflow" messages per second.

If I instead chunk the video up so the timebase resets are separate inputs (Using dvd2concat), FFmpeg will work, but the output video will stutter at every join between the inputs, sometimes for several seconds, which is unacceptable.

I have tried -fflags +genpts, but it did not fix the problem.

Is there any way arbitrary timebase resets can be properly handled? It seems to be part of the MPEG2 standard, and the link at the top of this issue has code attached that claims to handle it. Even if it can just be added as an optional switch, that would mean the world to anyone processing DVD videos.

EDIT:
I cannot publicly provide the source video, since I am testing this on commercial DVDs. However, I can provide the FFmpeg commands, the concat scripts, and a screen recorded video showing the problem. If you do need a video to test with, please message me privately or email me.

Screen recorded video showing the problem, start to finish:
https://www.youtube.com/watch?v=H8qFeB-NtHY

FFmpeg logs, commands, and concat files:
https://box.dogi.us/s/nazdxGZqkqPQiw8

FFmpeg command for pass 1 in the video (Introduced stuttering at every chapter break):
ffmpeg -y -ignore_unknown -protocol_whitelist subfile,file,concat -f concat -safe 0 -v 9 -loglevel 99 -i '/home/public/Desktop/Nextgen/Title 1.concat' -map 0 -c copy -f dvd '/home/public/Desktop/Nextgen/Test_oldConcat.vob'

FFmpeg command for pass 2 in the video (FFmpeg stuck in infinite loop, operation never completed):
ffmpeg -y -ignore_unknown -protocol_whitelist subfile,file,concat -f concat -safe 0 -v 9 -loglevel 99 -i '/home/public/Desktop/Nextgen/Title 1.concat_new' -map 0 -c copy -f dvd '/home/public/Desktop/Nextgen/Test_newConcat.vob'

Change History (3)

comment:1 by nab622, 3 years ago

Summary: MPEG2 decoder timebase resets cause FFmpeg to lock up during concat or the output video stutterMPEG2 decoder timebase resets cause FFmpeg to lock up during concat or the output video to stutter

comment:2 by Carl Eugen Hoyos, 3 years ago

Component: ffmpegundetermined
Keywords: MPEG2 timebase discontinuity removed
Version: 4.3.2unspecified

Please test current FFmpeg git head and provide the command line you tested together with the complete, uncut console output and the necessary input files to make this a valid ticket.

comment:3 by nab622, 3 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.