Opened 3 weeks ago

Last modified 3 weeks ago

#11374 new defect

Deprecated -fflags shortest option may still be useful

Reported by: Wallboy Owned by:
Priority: normal Component: ffmpeg
Version: 7.1 Keywords: concat concatenate demuxer shortest timestamp dts
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

I use ffmpeg and the concat demuxer to concatenate multiple mp4 files together, but was having issues with "Application provided invalid, non monotonically increasing dts to muxer" errors that would occur when the next file was opened.

I was able to solve this error in almost all cases by pre-processing the input files by simply doing a streamcopy and specifying -fflags +shortest. I also tried using -shortest, but this would still result in the timestamp errors.

I noticed the warning message that the -fflags shortest option is deprecated and will be removed at some point in the future. I can see the commit for deprecation here: https://github.com/FFmpeg/FFmpeg/commit/85e075587dcca5e07c89b5c2f1081d773ce4d997 which seems to imply it's being removed because it was assumed it was never used practically anywhere, or what bugs it actually solved.

How to reproduce:

I have provided three sample test files: test_no_shortest.mp4, test_shortest.mp4, and test_mux_shortest.mp4 which were all created with the following three ffmpeg commands respectively:

ffmpeg -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 -f lavfi -i "sine=f=1000:d=10" -af "volume=0:enable=gt(mod(t\,1)\, 0.1)" -c:v libx264 -crf 23 -pix_fmt yuv420p -t 10 test_no_shortest.mp4
ffmpeg -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 -f lavfi -i "sine=f=1000:d=10" -af "volume=0:enable=gt(mod(t\,1)\, 0.1)" -c:v libx264 -crf 23 -pix_fmt yuv420p -t 10 -shortest test_shortest.mp4
ffmpeg -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 -f lavfi -i "sine=f=1000:d=10" -af "volume=0:enable=gt(mod(t\,1)\, 0.1)" -c:v libx264 -crf 23 -pix_fmt yuv420p -t 10 -fflags +shortest test_mux_shortest.mp4

The following ffmpeg command can then be used to reproduce the problem:

ffmpeg -stream_loop -1 -i ffconcat.txt -c copy -f null -

where the contents of the ffconcat.txt are simply:

ffconcat version 1.0

file test_no_shortest.mp4
file test_no_shortest.mp4

Notice the Application provided invalid, non monotonically increasing dts to muxer errors.

Now simply update the ffconcat.txt file and change each file line to test_shortest.mp4 (which used the -shortest option) and run the ffmpeg command again. The errors are still present.

Finally update ffconcat.txt file and change to test_mux_shortest.mp4 (which used the -fflags +shortest option) and re-run the ffmpeg command. The errors are gone!

Now I don't know why -fflags +shortest is fixing the issue in this case, but I have not figured out any other way to not have these errors without using this format flag on many of my input files.

Attachments (4)

test_no_shortest.mp4 (170.3 KB ) - added by Wallboy 3 weeks ago.
Test video without using any shortest flags
test_shortest.mp4 (170.3 KB ) - added by Wallboy 3 weeks ago.
Test video using the "-shortest" flag
test_mux_shortest.mp4 (170.3 KB ) - added by Wallboy 3 weeks ago.
Test video using the "-fflags +shortest" option
ffconcat.txt (78 bytes ) - added by Wallboy 3 weeks ago.
ffconcat file

Download all attachments as: .zip

Change History (5)

by Wallboy, 3 weeks ago

Attachment: test_no_shortest.mp4 added

Test video without using any shortest flags

by Wallboy, 3 weeks ago

Attachment: test_shortest.mp4 added

Test video using the "-shortest" flag

by Wallboy, 3 weeks ago

Attachment: test_mux_shortest.mp4 added

Test video using the "-fflags +shortest" option

by Wallboy, 3 weeks ago

Attachment: ffconcat.txt added

ffconcat file

comment:1 by Wallboy, 3 weeks ago

Component: undeterminedffmpeg
Version: unspecified7.1
Note: See TracTickets for help on using tickets.