How Players Restore A/V Sync When Seeking VOB Files
When a media player seeks forward in a large VOB (Video Object) file, it recovers audio/video (A/V) synchronization by locating the nearest video keyframe, parsing embedded Presentation Time Stamps (PTS), discarding mismatched audio packets, and locking both streams to a central reference clock. Because VOB files are MPEG-2 Program Streams containing multiplexed elementary streams, the player must independently parse, align, and trim both audio and video data to restore a seamless presentation without introducing drift or distortion.
1. Jumping to the Nearest Keyframe (VOBU Alignment)
VOB files are divided into Video Object Units (VOBUs), each typically starting with a Navigation Pack (NAV pack) followed by an MPEG-2 Group of Pictures (GOP). Because video compression relies on temporal prediction (P-frames and B-frames), a player cannot resume video playback mid-GOP. When you seek forward:
- The player uses internal index tables or navigates via NAV pack offsets to locate the target byte position.
- It seeks forward or backward to the closest preceding I-frame (Intra-coded frame).
- Decoding begins at this I-frame, as it is the only frame capable of full reconstruction without reference to previous data.
2. Reading Timestamps: SCR, PTS, and DTS
MPEG-2 Program Streams rely on three timing indicators to manage synchronization:
- SCR (System Clock Reference): Governs the timing of data delivery into the demuxer buffers.
- DTS (Decode Time Stamp): Tells the decoder when to process an elementary packet.
- PTS (Presentation Time Stamp): Tells the player the exact time a decoded audio frame or video picture must be presented to the user.
Upon landing at the target VOBU, the demuxer parses the elementary stream headers to extract new PTS values for both video and audio. These timestamps dictate how far apart the two streams are relative to the target timeline.
3. Audio Packet Discarding and Flushing
Video decoding involves a variable delay because modern decoders buffer multiple frames to resolve temporal dependencies. Audio frames, typically formatted in AC-3, LPCM, or DTS within a VOB, decode instantaneously.
To prevent audio from playing ahead of the video:
- Buffer Flushing: The demuxer flushes existing hardware and software audio/video buffers immediately upon the seek command.
- Audio Pruning: The demuxer reads audio packets from the newly acquired stream but drops any packet whose PTS is earlier than the PTS of the first presentable I-frame.
- Pre-roll/Padding: If the audio stream starts slightly later than the video I-frame, the audio subsystem temporarily outputs silence until the audio PTS matches the current timeline.
4. Clock Master Arbitration and Resynchronization
Once both streams start outputting decoded data, the player regulates their speed using a clock synchronization method:
- Audio-as-Master (Standard): The human ear is far more sensitive to pitch changes, pops, and stutter than the eye is to dropped frames. Therefore, most players use the audio PTS clock as the primary timeline. The video renderer compares its own PTS against the audio clock. If video is behind, it drops intermediate non-reference frames (B-frames) to catch up; if video is ahead, it holds the current frame until the audio timeline matches.
- External System Clock: If audio is absent or discontinuous, the player matches both video PTS and audio PTS to an internal high-resolution monotonic system clock, dynamically adjusting presentation delays for both streams until the delta approaches zero.
Through this combination of GOP-aligned seeking, PTS realignment, buffer flushing, and master clock arbitration, the player eliminates drift and restores tight A/V synchronization within a fraction of a second.