How PGCDemux Extracts Streams Using DVD PGCs
This article explains how PGCDemux separates video, audio, and subtitle streams from DVDs by utilizing Program Chains (PGCs) instead of raw VOB files. While raw VOB files simply serve as physical containers split into arbitrary 1 GB chunks, PGCDemux reads DVD navigation structures to identify the true logical playback flow. By the end of this guide, you will understand how PGCDemux parses IFO metadata, traverses cell playback tables, and extracts continuous, synchronized elementary streams without the errors inherent in raw file copying.
The Problem with Raw VOB Files
DVD-Video data is physically stored in Video Object (VOB) files, capped at 1 GB due to legacy file system limitations (UDF/ISO 9660). These VOBs are container files holding multiplexed MPEG-2 Program Streams.
Extracting directly from raw VOBs presents significant problems:
- Interleaving: A single set of VOB files frequently contains multiple camera angles, different cuts of a film (seamless branching), or extra features interleaved together.
- Non-Linear Playback: The physical order of video blocks inside a VOB rarely matches the chronological sequence of a specific presentation.
- Layer/Boundary Breaks: Physical file breaks can introduce timestamp resets, audio-video sync drift, and orphaned frames.
The Role of Program Chains (PGCs)
A Program Chain (PGC) is the DVD specification’s logical unit of playback. Instead of referencing physical file offsets, a DVD player executes instructions mapped to a PGC. A single PGC outlines an uninterrupted viewing experience—such as the main feature, an alternate ending, or an individual episode of a television series—by chaining together smaller playback segments called "Cells."
How PGCDemux Accesses PGC Data via IFO Files
PGCDemux relies fundamentally on the DVD's Information files
(.IFO), specifically VTS_XX_0.IFO (Video Title
Set information). The IFO file functions as a roadmap for the
corresponding VOB set.
- Header Parsing: PGCDemux reads the IFO to locate
the Program Chain Information Table (
VTS_PGCI). - PGC Selection: The user selects a specific PGC index within a Title Set.
- Cell Position Mapping: PGCDemux reads the PGC’s
playback control table, which lists every Cell assigned to that chain in
chronological order. Each entry defines:
- VOB ID: The specific object identifier assigned to the content.
- Cell ID: The individual segment within that VOB ID.
- Sector Addresses: The exact starting and ending Logical Block Addresses (LBAs) on the disc where the cell physically resides.
Extracting Streams at the Packet Level
Once the cell list is compiled, PGCDemux systematically processes the VOB files according to the sector addresses mapped in the IFO, ignoring data that does not belong to the selected PGC:
- Filtering by Sector: PGCDemux reads sectors (2,048-byte DVD packs) directly from the VOBs based on the PGC's LBA map. Unreferenced sectors—such as alternate angles or unused scenes—are entirely skipped.
- Reading Navigation Packs (NV_PCK): DVD sectors begin with navigation packs containing Presentation Time Stamps (PTS) and System Clock Reference (SCR) values. PGCDemux uses these to monitor playback timing across cell boundaries.
- Demultiplexing Elementary Streams: Within the
targeted cells, PGCDemux analyzes the Packetized Elementary Stream (PES)
headers and separates the data based on stream IDs:
- Video: Extracted from stream ID
0xE0into raw.m2vfiles. - Audio: Extracted from private stream IDs (e.g.,
0xBDfor AC-3 or DTS;0xC0–0xDFfor MPEG audio) into.ac3,.dts, or.mpafiles. - Subtitles: Extracted from private stream substream
IDs (
0x20–0x3F) into raw subtitle files (.sup) along with timing indices.
- Video: Extracted from stream ID
- Handling Audio Delay: PGCDemux evaluates the difference between the initial audio PTS and video PTS at the beginning of the PGC, writing the delay value (in milliseconds) directly into the generated audio filename to preserve synchronization during subsequent authoring or encoding.
By traversing the logical PGC path rather than parsing raw container boundaries, PGCDemux ensures that the extracted elementary streams contain only the desired cut of the media, maintain perfect audio-to-video synchronization, and completely exclude extraneous multiplexed data.