A transport stream is made of 188-byte packets, all fields big-endian. ITU-T H.222.0 (ISO/IEC 13818-1) is the definition; its text was not read for this reference, so the adaptation extension fields below are given from memory of it.
Packet header
| Bits | Name | Meaning |
|---|---|---|
| 8 | sync_byte | 47. |
| 1 | transport_error_indicator | The demodulator could not correct the packet. |
| 1 | payload_unit_start_indicator | A new payload unit starts in this packet: a PES packet, or a section, for which the payload begins with a pointer field. |
| 1 | transport_priority | Higher priority among packets of the same PID. |
| 13 | PID | Which stream or table the payload belongs to. |
| 2 | transport_scrambling_control | See below. |
| 2 | adaptation_field_control | See below. |
| 4 | continuity_counter | Increments per PID on each packet that has a payload. |
| Scrambling control | Meaning |
|---|---|
00 | Not scrambled |
01 | Reserved in MPEG; its other uses depend on the system |
10 | Scrambled with the even key (DVB-CSA) |
11 | Scrambled with the odd key (DVB-CSA) |
| Adaptation field control | Meaning |
|---|---|
00 | Reserved |
01 | Payload only |
10 | Adaptation field only |
11 | Adaptation field followed by payload |
When a packet carries sections and payload_unit_start_indicator is set, the
first payload byte is a pointer_field: the number of bytes before the next
section starts. Packets with PES payload have no pointer field.
Reserved PIDs
| PID | Use |
|---|---|
0000 | Program Association Table |
0001 | Conditional Access Table |
0002 | Transport Stream Description Table |
0003 | IPMP control information |
0004 to 000F | Reserved |
0010 to 001F | Used by DVB for metadata: NIT, SDT, EIT, TDT |
0020 to 1FFA | Program Map Tables and elementary streams |
1FFB | DigiCipher 2 and ATSC metadata (MGT) |
1FFF | Null packets, used as padding |
Adaptation field
| Bits | Name | Meaning |
|---|---|---|
| 8 | adaptation_field_length | Bytes following this field. |
| 1 | discontinuity_indicator | The clock or continuity counter is discontinuous. |
| 1 | random_access_indicator | The stream can be entered here. |
| 1 | elementary_stream_priority_indicator | Higher-priority elementary stream data. |
| 1 | PCR_flag | A PCR is present. |
| 1 | OPCR_flag | An OPCR is present. |
| 1 | splicing_point_flag | A splice countdown is present. |
| 1 | transport_private_data_flag | Private data is present. |
| 1 | adaptation_field_extension_flag | An extension is present. |
| 48 | PCR | If flagged. 33-bit base, 6 reserved bits, 9-bit extension. PCR = base × 300 + extension, in 27 MHz. |
| 48 | OPCR | If flagged. The same layout. |
| 8 | splice_countdown | If flagged. Signed; packets left until the splice point. |
| 8 | transport_private_data_length | If flagged. Bytes of private data following. |
| n | private data | Private bytes. |
| varies | adaptation extension | If flagged. See below. |
| varies | stuffing | FF bytes to the end of the field. |
| Bits | Adaptation extension |
|---|---|
| 8 | adaptation_field_extension_length |
| 1 | ltw_flag |
| 1 | piecewise_rate_flag |
| 1 | seamless_splice_flag |
| 5 | reserved |
| 16 | If ltw: ltw_valid_flag (1), ltw_offset (15), the legal time window |
| 24 | If piecewise: reserved (2), piecewise_rate (22) |
| 40 | If splice: splice_type (4), DTS_next_AU (33 bits with 3 marker bits) |
M2TS and MTS
Blu-ray, AVCHD and HDV .m2ts and .mts files prefix each
packet with a 4-byte TP_extra_header, making 192 bytes.
| Bits | Name | Meaning |
|---|---|---|
| 2 | copy_permission_indicator | Copy protection state. |
| 30 | arrival_time_stamp | 27 MHz arrival time of the packet. |
Worked example
The header 47 40 00 10 decodes as sync 47; next
0100 0000 0000 0000 sets payload_unit_start_indicator and gives PID 0, the
PAT; last 0001 0000 means not scrambled, payload only, continuity counter
0.