Baud
All protocols

MPEG-TS

188-byte packets that interleave video, audio and tables into one stream.

A TS packet carrying the PAT

The 4-byte header, then the table of contents with a CRC computed for real.

MPEG-TS packet carrying a PAT · first 21 of 188 bytesthen 0xFF stuffing up to 188 bytes0816470100011140010000000000000000100001000000000000000000000000B0101100000D0000110100000000000100000001C1110000010000000000000000000000000000000100000001F01111000000000000002A00101010B1101100010400000100B210110010Sync bytePIDS…A…Con…Pointer f…Table IDR…Section lengthTransport stream IDR…Versi…Section n…Last sect…Program numberRe…PMT P…CRC-32Click a field to inspect it

Whole frame

A 4-byte header (sync, flags, PID, counter) and then the payload: here the table of contents. The rest of the 188 bytes is 0xFF filler.

FieldOffsetExample valueMeaning
Sync byteByte 00x47Always 0x47 ('G'). Every TS packet is exactly 188 bytes, so a receiver finds packet boundaries by checking that 0x47 repeats every 188 bytes. That is how it recovers after a glitch.
Transport errorByte 1, bit 70Set by a demodulator that could not correct errors in this packet. Decoders skip it.
Payload unit startByte 1, bit 611 = a new PES packet or table section begins in this packet's payload (the first byte is then a pointer_field for tables). It marks where a frame or table starts.
Transport priorityByte 1, bit 501 = more important than other packets with the same PID. Rarely used.
PIDBytes 1–20x0000 = PATPacket Identifier: which stream this packet belongs to. Many streams (video, several audios, subtitles, tables) are interleaved in one TS and told apart only by PID. PID 0 is always the PAT, the table of contents.
ScramblingByte 3, bits 7–600Encryption flag for pay TV. 00 = not scrambled.
Adaptation fieldByte 3, bits 5–401 = payload only01 = payload only, 10 = adaptation field only, 11 = both. The adaptation field carries the PCR clock and stuffing.
Continuity counterByte 3, bits 3–00Counts 0–15 for each PID, +1 per packet that has a payload. A skipped number tells the receiver that packets of this PID were lost.
Pointer fieldByte 40Present because PUSI = 1 on a table: how many bytes to skip before the section starts. 0 = right away.
Table IDByte 50x00 = PAT0x00 = PAT (Program Association Table), 0x02 = PMT, 0x42 = SDT...
Syntax indicatorByte 6, bit 711 = the long section syntax, with a CRC.
ZeroByte 6, bit 60Always 0 in PSI tables.
ReservedByte 6, bits 5–411Set to 1 1.
Section lengthBytes 6–713Bytes after this field up to the end of the CRC: 5 (fixed part) + 4 (one program) + 4 (CRC) = 13.
Transport stream IDByte 8–91An ID for this whole multiplex.
ReservedByte 10, bits 7–611Set to 1 1.
VersionByte 10, bits 5–10Increments whenever the table's content changes, so receivers know to re-read it.
Current/nextByte 10, bit 011 = this table is the one in effect now.
Section numberByte 110Which piece of a multi-section table this is.
Last sectionByte 120The last piece's number. 0 = the table fits in one section.
Program numberByte 13–141A program (a channel: its video + audio). Number 1 here.
ReservedByte 15, bits 7–5111Set to 1 1 1.
PMT PIDBytes 15–160x1000Where to find the Program Map Table of program 1: packets with this PID. The PMT then lists the PIDs of the video and audio streams. So decoding starts at PID 0 → PMT PID → video PID.
CRC-32Byte 17–200x2AB104B2A CRC-32/MPEG-2 over the section (polynomial 0x04C11DB7, initial value 0xFFFFFFFF, no reflection). Computed for real here: 0x2AB104B2. A receiver discards a table whose CRC does not match.

Overview

MPEG transport stream (TS) was built for broadcasting over lossy links. Everything is cut into fixed 188-byte packets, each starting with 0x47 and labelled with a PID. Video, several audio tracks, subtitles and the tables that describe them travel interleaved in one stream, and a receiver can join at any moment.

Tables (PAT, PMT) tell the decoder which PIDs are video and audio. The media itself is wrapped in PES packets with timestamps, then split across TS packets. Digital TV, Blu-ray, IPTV and HLS segments all use it.

Key facts

Packet size
188 bytes (204 with FEC)
Header
4 bytes, sync 0x47
PID
13 bits (8,192 streams)
Clock
PCR 27 MHz, PTS 90 kHz
Tables
PAT, PMT, SDT, ... + CRC-32
Standard
ISO/IEC 13818-1

A video frame in a PES packet

The PES header with a presentation timestamp, then the start of H.264 data.

A video frame's PES header · 20 bytesslice data follows, spread over many TS packets0816000000000000000000000100000001E01110000000000000000000000000801000000080100000000500000101210010000100000000000500000101BF10111111210010000100000000000000000000000000000001000000010900001001F011110000Start code prefixStream IDPES packet lengthM…PES fl…P…Other …Header da…PTSH.264 start codeNAL headerAUD dataClick a field to inspect it

Whole frame

Before each compressed frame sits a PES header with the one thing the player needs most: its presentation time. The PES packet is then chopped into 184-byte pieces and wrapped in TS packets.

FieldOffsetExample valueMeaning
Start code prefixByte 0–200 00 0100 00 01 can't occur inside properly escaped video data, so a decoder can find the start of a PES packet by scanning for it.
Stream IDByte 30xE0 = video stream 0What kind of elementary stream: 0xE0–0xEF video, 0xC0–0xDF audio.
PES packet lengthByte 4–50 (unbounded)Bytes that follow. 0 is allowed for video and means 'unbounded': the packet ends where the next one starts (a whole frame is often bigger than 65,535 bytes).
MarkerByte 6, bits 7–610Always 10.
PES flagsByte 6, bits 5–0000000Scrambling (2 bits), priority, data alignment, copyright, original: all 0 here.
PTS/DTS flagsByte 7, bits 7–610 = PTS only10 = a PTS is present (without DTS); 11 = both; 00 = neither. Frames in order need only a PTS; B-frames also need a DTS because decode order differs from display order.
Other flagsByte 7, bits 5–0000000ESCR, ES rate, trick mode, copy info, CRC, extension: all absent.
Header data lengthByte 85Bytes of optional header fields before the payload: just the 5-byte PTS.
PTSByte 9–1390000 = 1.000 sPresentation Time Stamp: when to show this frame, in 90 kHz ticks, 33 bits wide, spread over 5 bytes with a marker bit after each group. Here 90000 ticks = 1.000 s. 33 bits at 90 kHz wrap after about 26.5 hours.
H.264 start codeByte 14–1700 00 00 01The compressed video begins here. In an H.264 byte stream every NAL unit starts with 00 00 00 01.
NAL headerByte 180x09 = AUDforbidden_zero 0, nal_ref_idc 0, type 9 = Access Unit Delimiter: 'a new frame starts'.
AUD dataByte 190xF0primary_pic_type 7 (any slice type) plus the rbsp stop bit.

Where you meet it

  • Digital TV broadcast (DVB, ATSC, ISDB)
  • IPTV and contribution links, often over UDP or SRT (7 TS packets = 1,316 bytes fit one datagram)
  • HLS segments (.ts files) and Blu-ray discs (M2TS)

Watch out for

  • Overhead is high on small streams: stuffing and 4 header bytes per 188.
  • A continuity-counter jump is how receivers detect loss; it also fires on legitimate duplicates, which are allowed once.
  • PTS wraps every ~26.5 hours: long recordings must handle the rollover.

Standards

  • ISO/IEC 13818-1 (MPEG-2 Systems)
  • ITU-T H.264 Annex B

Related protocols