↔️ PCR-PTS-KLV Span Consistency
This test answers a different question from PCR-PTS Drift: do the PCR, applicable PTS timelines, and KLV precision timestamps cover the same amount of time? A large span mismatch is a strong sign that clocks advance at different rates, which can make a file stall, end early, seek incorrectly, or fail to play normally.
What this test checks
The validator reads the complete inspected MPEG-TS data and:
- selects the PMT-declared PCR PID
- records the first and last PCR values and converts them from the 27 MHz clock to seconds
- groups every applicable PTS-bearing PES sample by PID and records its first and last 90 kHz PTS values
- groups decoded MISB precision timestamps by every declared KLV PID and records the first and last Unix-microsecond values
- compares each PTS and KLV timestamp span with
PCR span = last PCR - first PCR, with 33-bit wrap handling for PCR and PTS - treats KLV transport correctly: a
SYNC_KLVPID has both a PTS span and a KLV timestamp span, while anASYNC_KLVPID has only a KLV timestamp span and any PES PTS-like value on that PID is ignored
The result message always prints the raw first and last clock values, their values in seconds to three decimal places, and the available spans. PCR and PTS raw values use their transport clock units; KLV raw values are Unix microseconds. This makes duration problems visible even when the rule passes.
At least two PCR or PTS samples are required to calculate those clock spans. Every declared KLV PID is included, and its coverage is measured from the first available KLV timestamp to the last. If KLV starts late, stops early, or is absent, the resulting shorter or unavailable coverage is a warning because continuous KLV insertion is not required.
Tolerance
The allowed span difference is the larger of:
- Minimum tolerance:
100 msby default - Relative tolerance:
1%of the PCR span by default
In formula form:
allowed difference = max(absolute tolerance, PCR span × relative tolerance)
This avoids false failures caused by one frame of endpoint uncertainty in short files while still scaling sensibly for longer recordings. Both values are editable in Validation Rules.
✅ Pass criteria
The test passes when every applicable PTS span and every KLV timestamp span is within the allowed difference from the PCR span.
⚠️ Warning criteria
The test reports a warning when:
- a KLV timestamp span is shorter than the PCR span beyond tolerance
- KLV timestamp coverage starts late, stops early, or is unavailable
- a non-video, non-KLV PTS timeline differs from PCR while every video PTS timeline remains within tolerance
A shorter KLV span is not an error because a stream is not required to insert KLV continuously or at the exact PCR endpoints.
❌ Fail criteria
The test fails when at least one video PTS timeline has:
abs(timeline span - PCR span) > allowed difference
It also fails when KLV time runs backward or its span is longer than the PCR span beyond tolerance. The test location points to the last sample of the first failing video or KLV timeline when that location is available.
Chart
The horizontal duration chart shows one stream PCR reference followed by one row per PID:
- blue is the single PCR span reference
- green is a consistent PTS span
- purple is a consistent KLV timestamp span
- orange is a shorter or unavailable KLV span warning
- red is any inconsistent span
- a synchronous KLV PID's PTS and KLV bars are thinner, close together, and share the same PID row
- an asynchronous KLV PID has only a KLV timestamp bar
- the detail rows below the chart print first/last clock values, seconds, span delta, percentage, and allowed difference
In this example, PCR covers about 24.950 seconds while video PID 1001 covers only about 8.167 seconds. Synchronous KLV PID 65 has closely grouped PTS and KLV bars. Asynchronous KLV PID 66 has only an orange, shorter KLV bar, which is a warning. The shorter red video PTS bar remains a failing duration mismatch.
Relationship to PCR-PTS Drift
Use both rules:
- PCR-PTS Drift finds local or gradual divergence at individual video samples using an interpolated PCR timeline.
- PCR-PTS-KLV Span Consistency gives a file-level duration and rate sanity check across PCR, applicable PTS timelines, and every KLV PID's precision timestamps.
A stream can reveal a useful clue in one chart even when the other cannot calculate enough local points, so the tests intentionally remain separate.