Metadata Access Unit Length Validation
This structural test validates metadata access-unit (AU) wrappers around KLV in
MPEG-TS. It applies to synchronous KLV (stream_type 0x15) and to asynchronous
KLV (0x06) when that stream retains the AU wrapper. Traditional asynchronous
RP 217 carriage, which puts KLV directly in PES, and raw KLV are not applicable.
Why synchronous metadata has an AU cell lengthβ
The standardized MPEG synchronous metadata transport uses the generic
Metadata_AU_cell wrapper defined by H.222.0 section 2.12.4. Its length field
exists because it is part of that wrapper, not because synchronization itself
requires a second length. The wrapper lets MPEG-2 Systems recognize metadata AU
boundaries and associate them with the PES presentation timestamp (PTS). It is
not KLV-specific: it identifies the metadata service,
marks complete or fragmented AUs and random-access points, and provides a
sequence_number for detecting lost cells. Its AU_cell_data_length specifies
exactly how many bytes belong to that cell:
PES (PTS = t)
ββ Metadata_AU_cell
metadata_service_id Β· sequence_number Β· fragment/other flags
AU_cell_data_length
KLV bytes (or a fragment of them)
The wrapper lets the MPEG layer align PES packets with metadata AUs, including when an AU spans multiple cells. This test checks the cell's declared length against the bytes available and the reconstructed KLV packet boundaries.
Why asynchronous KLV does not use itβ
Traditional asynchronous carriage (SMPTE RP 217) places KLV in a
private_stream_1 PES payload without a metadata AU wrapper or a metadata PES
PTS. The MPEG layer carries private bytes; the KLV layer finds packet boundaries
using its own Key | BER Length | Value structure:
PES private_stream_1
ββ KLV: Key | BER Length | Value
The BER length already tells a KLV parser how many value bytes follow. Traditional RP 217 carriage has no MPEG AU wrapper to supply a cell length, and its metadata is multiplexed near the relevant video without its own PES PTS.
An Async With Sync AU stream is the exception to the usual async layout: it is asynchronous at the PES and signaling level, but retains the synchronous AU wrapper. The wrapper checks on this page therefore apply to it as well.
| Validation | Sync or Async With Sync AU | Async RP 217 |
|---|---|---|
AU_cell_data_length | β | N/A |
| AU fragmentation flags | β | N/A |
| AU sequence number | β | N/A |
| KLV BER length | β | β |
| PES length | β | β |
These are separate layers of validation. Wrapped KLV has two lengths with
different jobs:
AU_cell_data_length frames a cell for MPEG-2 Systems, while the KLV BER length
frames a KLV packet for the KLV parser. The cell and its fragmentation are the
transport-wrapper checks; KLV BER and PES length also matter for unwrapped
asynchronous carriage. This test uses KLV packet boundaries to detect inconsistent
AU lengths, but PES Length Validation is a separate rule.
The test reassembles PES payloads, checks each five-byte AU header and its declared
cell data length, and reconstructs fragmented AUs before checking their KLV keys,
BER lengths, and packet boundaries. Multiple cells and multiple KLV packets are
supported. Fragment values 11, 10, 00, and 01 denote complete, first,
intermediate, and last cells respectively (H.222.0 section 2.12.4).
β Pass conditionβ
For a stream with an AU wrapper, the test passes when every cell has a complete, valid header, its declared data length fits the PES payload, fragment chains and cell sequence are consistent, and each reconstructed AU ends on a complete KLV packet boundary. Multiple cells per PES and multiple KLV packets per AU are valid.
β Fail conditionβ
The test fails when it finds one or more of these problems:
- a truncated or invalid AU header, or a cell length that exceeds the remaining PES payload;
- a missing cell, an orphan continuation, or an incomplete fragment chain;
- an AU length that cuts through a KLV key, BER length, or value, or leaves bytes outside a complete KLV packet.
After a malformed length, validation resumes at a new PES boundary instead of searching arbitrary bytes for another header. Incomplete continuations are suppressed until a new first or complete cell is available. Streams without an AU wrapper are reported as not applicable.
Findings include PID, zero-based TS packet number, the byte offset of that TS packet, the precise AU header offset, and declared/required lengths when known. The chart shows PCR-derived time with an approximation marker when interpolated; missing timing is displayed as unavailable. For fragmented AUs, the location is the first cell and the diagnostic uses the reconstructed data length.
This test is independent of PES Length Validation: a correct outer PES length does not establish that its metadata cells are correctly framed. For example:
Metadata AU cell length is inconsistent with the enclosed KLV packet: declared 14 bytes; KLV packet requires 270 bytes.