How to Fix: ffmpeg gives error DTS out of order and Non-monotonous DTS in output stream
FFmpeg concatenation error with DTS out of order and non-monotonous. Solution involves re-encoding audio.
📋 Table of Contents
FFmpeg concatenation error: DTS out of order and non-monotonous DTS in output stream
This issue affects users trying to concatenate multiple MP4 videos into one using ffmpeg, resulting in audio-only or corrupted video files.
💡 Why You Are Getting This Error
- The primary cause of this error is the use of the `-c copy` option with concat demuxer. This option tells ffmpeg not to reencode the input file, but it can lead to issues when concatenating multiple files with different audio and video codecs.
- Another potential cause is the incorrect ordering of files in the input.txt file. If the files are not ordered chronologically, ffmpeg may get confused about the correct order of events.
🛠️ Step-by-Step Verified Fixes
Reorder files and use -c:v copy
- Step 1: Sort the input files in chronological order based on their timestamps.
- Step 2: Modify the concat file to reflect the new ordering (e.g., `file '/raw/01 - Introduction.mp4'` becomes `file '/raw/02 - Background Material.mp4' ... file '/raw/01 - Introduction.mp4'`).
- Step 3: Run ffmpeg with the `-c:v copy` option to reencode only the video, while keeping the audio intact.
Use -async 1 and -reconnect 1
- Step 1: Add the `-async 1` option to force ffmpeg to wait for the previous stream to finish before starting the next one.
- Step 2: Add the `-reconnect 1` option to tell ffmpeg to reconnect any dropped packets.
🎯 Final Words
To resolve this issue, try reordering your input files and using the `-c:v copy` option. Alternatively, you can use the `async` and `reconnect` options. If you're still experiencing issues, refer to the official ffmpeg documentation for more information on concat demuxer settings.
❓ Frequently Asked Questions
🛠️ Related Fixes
How to Fix: Pc crashes shortly after launching game (rainbow
Fix Pc crashes shortly after launching game (rainbow six siege). Compl
How to Fix: Installing an APK on a locked down phone
Installing an APK on a locked down phone: Try using a rooted device, e
How to Fix: New PC build- no signal and no clue
Fix New PC build- no signal and no clue. Complete troubleshooting guid