How to Fix Non-monotonous DTS in FFmpeg
The “Non-monotonous DTS (Decoding Time Stamp) in output stream” error in FFmpeg occurs when the timestamps of your input file’s video or audio frames are out of order, duplicate, or corrupted. This article explains why this issue happens and provides direct, practical command-line solutions to fix or bypass these timestamp errors to ensure successful file processing.
Why This Error Occurs
Decoding Time Stamps (DTS) dictate the order in which a media player
decodes video frames. For a video to play correctly, these timestamps
must strictly increase over time (monotonically). When you copy streams
without re-encoding (-c copy), FFmpeg transfers the
original, broken timestamps directly to the output. If the destination
container (like MP4 or MKV) detects a timestamp that is equal to or less
than the previous one, it triggers the “non-monotonous DTS” warning or
error.
Solution 1: Regenerate Timestamps
The most common fix is to force FFmpeg to regenerate the missing or
broken timestamps during the demuxing process using the
genpts flag.
ffmpeg -fflags +genpts -i input.mp4 -c copy output.mp4Solution 2: Force Re-encoding
Using -c copy (stream copying) preserves the broken
timestamps of the source file. Re-encoding the video and audio forces
FFmpeg to decode the file and write completely new, valid timestamps for
the output stream.
ffmpeg -i input.mp4 -c:v libx264 -c:a aac output.mp4Solution 3: Use Wallclock Timestamps
If you are dealing with live streams, RTSP feeds, or heavily corrupted files where the source timestamps are completely unusable, you can tell FFmpeg to discard the input timestamps and generate new ones based on the system clock.
ffmpeg -use_wallclock_as_timestamps 1 -i input.mp4 -c copy output.mp4Solution 4: Ignore Input DTS
If the output file plays fine despite the warnings, you can tell FFmpeg to ignore the original input DTS. This allows the multiplexer to resolve conflicts automatically.
ffmpeg -fflags +igndts -i input.mp4 -c copy output.mp4Solution 5: Apply Bitstream Filters for Audio
If the DTS error is specifically related to the audio stream (common with AAC or ADTS streams), applying a bitstream filter can correct the packet headers and resolve the timestamp conflict.
ffmpeg -i input.mp4 -c:v copy -c:a copy -bsf:a aac_adtstoasc output.mp4