β Continuity Counter
The MPEG transport stream continuity counter is a 4-bit value in each TS packet header. For packets that carry payload on the same PID, the value is expected to increase by 1 modulo 16. This counter is used to detect transport-level packet loss, duplication, or reordering. A continuity counter break usually means one or more TS packets were lost, repeated, or arrived out of sequence.

What This Test Doesβ
The Continuity Counter test scans MPEG-TS packets and checks whether the continuity counter sequence is valid for each PID.
The test:
- Tracks continuity separately for each PID.
- Checks only packets that contain payload.
- Ignores null packets on PID
0x1FFF. - Uses the first payload packet on each PID as the starting reference.
- Reports an error when the next payload packet on the same PID does not match the expected continuity counter value.
When an error is detected, the application records the PID and the expected and actual counter values.
Discontinuity Indicator Handling
The detector still records a continuity counter mismatch even when the transport packet sets the adaptation-field discontinuity_indicator.
During result evaluation, the finding is downgraded to a warning if the recorded mismatch and the recorded discontinuity_indicator refer to the same PID and the same packet index.
If the mismatch is not covered by a matching discontinuity_indicator, the test remains a failure.
β Pass Criteriaβ
The test passes when no continuity counter errors are detected in the file.
Application result message:
No continuity counter breaks were detected.
Warning Criteriaβ
The test reports a warning when all detected continuity counter mismatches are covered by a matching discontinuity_indicator.
Application result message:
<n> continuity counter mismatch was detected, and discontinuity_indicator was set. This is a legal situation.
β Fail Criteriaβ
The test fails when one or more continuity counter errors are detected without a matching discontinuity_indicator.
Typical causes include:
- Missing TS packets
- Duplicate TS packets
- Packet reordering within the same PID
Application result message:
<n> continuity counter errors were detected.
Per-error details are reported in the form:
continuity counter error on PID 0x####: expected X, got Y
Exampleβ
Here a chart that shows a file with the corrupted Continuity Counters.

Test fileβ
- mpegts-cc-error.ts
Corrupted packets: [263, 527, 790, 1054]
- Packet 263: CC 8 -> 13
- Packet 527: CC 4 -> 9
- Packet 790: CC 15 -> 4
- Packet 1054: CC 11 -> 0