Audio, video, subtitles and data are carried as packetised elementary streams. Each
elementary stream is cut into PES packets, and each PES packet is spread over the
payloads of transport packets of one PID: the packet that begins it has
payload_unit_start_indicator 1 and the PES start code at the start of its payload.
A PES packet for video usually has PES_packet_length 0, which means it runs to the next one.
PES packet header
| Bits | Name | Meaning |
|---|---|---|
| 24 | packet_start_code_prefix | 000001. |
| 8 | stream_id | See the table below. |
| 16 | PES_packet_length | Bytes after this field; 0 for an unbounded video packet in a transport stream. |
| The rest is present for every stream_id except program_stream_map (BC), padding_stream (BE), private_stream_2 (BF), ECM (F0), EMM (F1), program_stream_directory (FF), DSMCC_stream (F2) and H.222.1 type E (F8), which carry data straight after the length. | ||
| 2 | marker | 10. |
| 2 | PES_scrambling_control | 00 not scrambled; 01 to 11 user defined. |
| 1 | PES_priority | Higher priority. |
| 1 | data_alignment_indicator | The payload starts with an access unit or syncword. |
| 1 | copyright | Material is copyrighted. |
| 1 | original_or_copy | 1 original. |
| 2 | PTS_DTS_flags | 00 none; 10 PTS; 11 PTS and DTS; 01 forbidden. |
| 1 each | ESCR_flag, ES_rate_flag, DSM_trick_mode_flag, additional_copy_info_flag, PES_CRC_flag, PES_extension_flag | Which of the optional fields follow. |
| 8 | PES_header_data_length | Bytes of optional fields and stuffing before the payload. |
| 40 | PTS, DTS | 4-bit prefix (0010 for PTS alone, 0011 and 0001 when both), then the 33-bit time in three parts of 3, 15 and 15 bits, each followed by a marker bit. 90 kHz. |
| 48 | ESCR | 2 reserved, ESCR_base (33 bits in three parts), ESCR_extension (9), markers. 27 MHz: base × 300 + extension. |
| 24 | ES_rate | Marker, 22 bits in units of 50 bytes a second, marker. |
| 8 | DSM_trick_mode | trick_mode_control (3): 000 fast forward, 001 slow motion, 010 freeze frame, 011 fast reverse, 100 slow reverse; then field_id, intra_slice_refresh and frequency_truncation, or rep_cntrl. |
| 8 | additional_copy_info | Marker and 7 bits. |
| 16 | previous_PES_packet_CRC | CRC of the previous PES packet's data. |
| varies | PES extension | Flags for PES_private_data (128 bits), pack_header_field, program_packet_sequence_counter (counter, MPEG1/MPEG2 identifier, original stuffing length), P-STD_buffer (scale and size) and PES_extension_flag_2 with a length, stream_id_extension (used when stream_id is FD) or TREF (a 33-bit time reference). |
| n | stuffing | FF bytes, up to 32. |
The pack header carried in a PES extension has pack_start_code, system_clock_reference (33-bit base and 9-bit extension), program_mux_rate (22 bits, units of 50 bytes a second) and pack_stuffing_length; the explorer decodes it.
stream_id values
| stream_id | Stream |
|---|---|
BC | program_stream_map |
BD | private_stream_1 (AC-3, DTS, DVB subtitles and teletext in PES private data, and others) |
BE | padding_stream |
BF | private_stream_2 |
C0 to DF | audio stream number (MPEG audio, AAC) |
E0 to EF | video stream number (MPEG-2, H.264, HEVC and others) |
F0, F1 | ECM_stream, EMM_stream |
F2 | DSMCC_stream |
F3 | ISO/IEC 13522 stream |
F4 to F8 | ITU-T H.222.1 types A to E |
F9 | ancillary_stream |
FA, FB | ISO/IEC 14496-1 SL-packetized and FlexMux streams |
FC | metadata stream |
FD | extended_stream_id: the real id is stream_id_extension in the PES extension (00 IPMP control information, 01 IPMP, 30 to 3F ISO/IEC 14496-17 text) |
FE | reserved data stream |
FF | program_stream_directory |
What the explorer does
- Every PES header is shown field by field in the packet that starts it; the elementary stream bytes after it are listed as units (see Elementary stream headers).
- The PES tab lists every PES packet of the chosen PIDs in the window with its length, PTS, DTS, the difference between them and the step from the previous PTS.
- The Elementary streams tab can hand each PID's stream over as a file of its own, read from the start of the whole file in windows, so a stream of any size can be extracted and opened with the matching viewer (.mp3, .aac, .ac3, .dts).
- A packet marked scrambled is not read past its header.
- What a PES carries is named by the PMT. When no PMT names a PID (a capture that starts after the PMT, or a stream without one), the explorer guesses from the stream_id and the first payload bytes:
C0toDFwith ADTS, LATM, MPEG audio or AC-3 sync words;E0toEFwith a start code that begins an MPEG-2 sequence, an H.264 sequence or access unit, or an HEVC parameter set;BDwith data_identifier80and private_stream_idFF(an ARIB caption). The label says it is a guess. - The PMT can also be wrong about the framing: when it announces AAC in ADTS and the payload is LATM (or the other way round) the label follows the data and says what the PMT announced.
- The PES payloads of private_stream_1 are read by the codec the PMT names: Blu-ray LPCM frames (each starts with a 4-byte header), Opus access units (a control header with trims before each packet), ARIB caption data groups (data_identifier
80), DVB subtitles and teletext; see Elementary stream headers.
Not described
Known, not yet covered
- Viewer: the program stream map (stream_id BC) and the program stream directory are shown as bytes after the length; PES packets of other stream_id values without a header are shown the same way.
- Viewer: the TREF and extension-2 fields beyond stream_id_extension are shown as reserved bytes.