How DGIndex Creates D2V Index Files from VOBs
DGIndex processes MPEG-2 video streams across contiguous VOB files to
produce a lightweight, plain-text index file with the .d2v
extension. Rather than demuxing or re-encoding the entire video track,
DGIndex scans the underlying MPEG structure, catalogs keyframe
locations, and records critical frame-level metadata. This resulting
index allows frameservers like AviSynth to access any frame with
frame-accurate precision during editing workflows without creating
massive intermediate files.
1. Parsing the MPEG-2 Program Stream
When a sequence of VOB files is loaded, DGIndex treats them as a single continuous byte stream. It parses the MPEG-2 Program Stream, filtering out audio tracks, sub-pictures, and private streams to focus on the video elementary stream (PES packets). It searches specifically for standard MPEG-2 start codes, including:
- Sequence Header (
00 00 01 B3): Defines the resolution, aspect ratio, frame rate, and bit rate. - Group of Pictures (GOP) Header
(
00 00 01 B8): Indicates the start of an independently decodable sequence of frames. - Picture Start Code (
00 00 01 00): Marks individual picture payloads (I, P, and B frames).
2. Recording Byte Offsets
Direct random access in MPEG-2 video is difficult because P-frames and B-frames rely on reference frames for decoding. DGIndex solves this by cataloging the exact byte offsets of every I-frame (keyframe) across the VOB files.
For every GOP encountered, DGIndex logs the file number in the sequence and the hexadecimal byte position where the GOP begins. If an editor requests a frame in the middle of a VOB sequence, the decoding filter uses these offsets to jump immediately to the nearest preceding I-frame, decode forward, and serve the requested frame instantly.
3. Cataloging Picture Flags and Telecine Information
A critical role of DGIndex is logging temporal and display flags embedded in the MPEG-2 Picture Coding Extension headers. For every frame, DGIndex extracts:
- Picture Coding Type: Whether the frame is an I-frame, P-frame, or B-frame.
- Top Field First (TFF): Indicates field dominance for interlaced content.
- Repeat First Field (RFF): Indicates whether a field is repeated to convert 24 fps film to 29.97 fps video (3:2 pulldown).
DGIndex encodes these attributes as hexadecimal matrix entries within
the .d2v file. This data informs video editors whether the
source is truly interlaced, progressive, or telecined, allowing for
automated inverse telecine (IVTC) without frame-matching errors.
4. Writing the .D2V Output
Once the scan is complete, DGIndex writes the collected metadata into
the .d2v text file. The file is structured into several
distinct parts:
- Header and Configuration: DGIndex version, stream type, and processing settings (e.g., field operation modes like "Honor Field Flags" or "Forced Film").
- File List: Absolute or relative file paths to all sequential VOB files referenced in the project.
- Stream Matrix: Formatted blocks of hexadecimal numbers representing each GOP, containing byte offsets followed by the per-frame flags.
5. Utilization in the Editing Pipeline
The finished .d2v file does not contain actual video
data; it serves entirely as an external address book. When an AviSynth
script calls MPEG2Source("video.d2v"), the decoder plugin
reads the .d2v file, references the original VOBs on disk,
reconstructs frames accurately via the logged byte offsets and flags,
and serves uncompressed video frames directly to editing software.