DTS vs PTS in VOB Video Packets Explained
In DVD VOB (Video Object) files, accurate video synchronization relies on two critical markers embedded within the stream: the Decoding Time Stamp (DTS) and the Presentation Time Stamp (PTS). While the PTS dictates the exact moment a decoded video frame must appear on the screen, the DTS specifies the precise moment the compressed frame data must be processed by the decoder. This article explains the technical differences between DTS and PTS within VOB packets, why bidirectional frame compression makes both timestamps necessary, and how hardware decoders use them to prevent playback stutter and visual artifacts.
The Fundamental Difference: Decode Order vs. Display Order
A VOB file is based on the MPEG-2 Program Stream format. Inside this format, video data is segmented into Packetized Elementary Stream (PES) packets. Each packet header can contain timing information to ensure the audio and video remain in sync:
- Presentation Time Stamp (PTS): Instructs the display engine when to present the fully decoded frame to the viewer.
- Decoding Time Stamp (DTS): Instructs the hardware or software decoder when to retrieve the compressed bitstream from the decoder buffer and convert it into uncompressed pixel data.
In basic video streams where frames are displayed in the exact order they are decoded, DTS and PTS are identical. However, in modern compression schemes, the order in which frames are decoded frequently deviates from the order in which they must be displayed.
The Role of B-Frames in VOB Files
The divergence between DTS and PTS in VOB files is driven entirely by the use of bidirectional predictive frames, known as B-frames. MPEG-2 video relies on three primary frame types:
- I-Frames (Intra-coded): Standalone images that do not require any reference frames to decode.
- P-Frames (Predicted): Compressed images that reference previous I-frames or P-frames.
- B-Frames (Bidirectional): Highly compressed frames that require data from both a preceding reference frame and a future reference frame to decode properly.
Because a B-frame needs data from a future frame to be reconstructed, the decoder must receive and decode that future frame before it can decode and display the intermediate B-frame.
For example, consider a display sequence of frames: I1 - B2 - B3 - P4.
To render B2 and B3, the decoder must
already have both I1 and P4 decoded and stored
in memory. Consequently, the stream reorders the delivery of the packets
so the transmission and decode order becomes: I1 - P4 - B2 -
B3.
In this scenario:
P4has a DTS indicating it must be decoded second.P4has a PTS indicating it must not be displayed until afterB2andB3have been shown.
Timestamp Handling in the VOB/PES Header
Inside the PES header of a VOB packet, flags indicate whether timestamps are present. Because carrying two 33-bit timestamps inside every single packet would introduce unnecessary overhead, MPEG-2 utilizes a conditional structure:
- PTS Only (Flag
10): If a frame's DTS is identical to its PTS (common with I-frames and P-frames in streams without B-frames, or standard audio packets), only the PTS is transmitted. The decoder assumesDTS = PTS. - Both PTS and DTS (Flag
11): When decode time and presentation time diverge due to frame reordering, both values are explicitly written into the PES header. - No Timestamps (Flag
00): Used when intermediate packets belong to a frame whose timestamps were already established in a preceding packet.
Buffer Management
Beyond establishing playback order, DTS is critical for MPEG-2 buffer management (the Video Buffer Verifier, or VBV). The DTS tells the decoder precisely when to pull data out of the buffer, preventing buffer underflows (where the decoder has no data to display) and buffer overflows (where incoming data exceeds available memory). Once the frame is decoded at the time indicated by the DTS, it sits in a frame store buffer until the clock reaches the PTS, at which point it is instantly pushed to the display.