What does non-monotonically increasing dts mean in FFmpeg?

Hi Komal,

To understand this warning, we need to understand what are DTS and PTS values first. When a player or software tries to decode and play the video, both audio and video streams have information about how fast and when you are supposed to play them inside of them. Audio streams have a sample rate, and video streams have a frame-per-second value. However, if we simply synced the video by counting frames and multiplying by frame rate, there is a chance that it will go out of sync with the audio.

Let’s explore the ideas behind PTS (Presentation Timestamp) and DTS (Decoding Timestamp) and how important they are to video playback. Comprehending these timestamps is essential to understanding the alert and guaranteeing that transcoding and video playing function properly.

1. Identifying PTS and DTS

Two important timestamps connected to video frames are the DTS (Decoding Timestamp) and PTS (Presentation Timestamp). They are essential in guaranteeing that the audio and video streams are correctly synced when being played back.

DTS helps video decoders preserve the proper frame order by indicating when a video frame has to be decoded. PTS allows for synchronized playing of audio and video by defining when a frame should be shown to the viewer.

2. Video and Audio Syncing

Maintaining synchronization between the audio and visual streams is essential for a flawless viewing experience. This implies that the timeline of the movie must be followed, with audio and video frames displayed simultaneously.

But there’s a chance that the sample rate of audio and the frame rate of video won’t always coincide. Counting frames and multiplying the result by the frame rate alone may eventually cause synchronization problems. This problem is solved with DTS and PTS.

3. DTS and PTS’s Roles

The secret to having exact control over when each audio and video frame is presented and decoded is to use PTS and DTS timestamps. They are essential for preserving synchronization while playing back.

While PTS directs the appropriate timing of the presentation of these frames to viewers, DTS helps the video decoder decide when to decode each video frame.

The decoding process may be hampered and video and audio synchronization problems may arise if the DTS values are not in a monotonically rising order. The presence of DTS values that deviate from the intended order is indicated by the warning message.

4. Managing DTS that isn’t monotonic

It is necessary to either adjust the DTS values or utilize the -fflags +genpts option in FFmpeg to resolve the warning message and guarantee seamless video transcoding and playback. With the use of this option, precise PTS values dependent on frame order can be generated.

When DTS and PTS values are aligned properly, audio and video stay synchronized, providing a smooth and error-free viewing experience.

Effective video processing and transcoding require an understanding of the roles played by DTS and PTS in video playback and synchronization, particularly when working with user-generated content. You may ensure the dependable operation of your video processing pipeline and the provision of top-notch material to your viewers by taking care of non-monotonic DTS values.

Checkout these threads for more: