An MPEG-TS packet is 188 bytes: a 4-byte header, optionally followed by an adaptation field, then payload.


Header (4 Bytes / 32 Bits)

FieldBitsNotes
Sync Byte8Fixed 0x47, lets a decoder lock onto the stream.
Transport Error Indicator (TEI)11 = demodulator flagged an uncorrectable error.
Payload Unit Start Indicator (PUSI)11 = payload’s first byte starts a new PES/PSI unit; 0 = continuation.
Transport Priority11 = higher priority than packets with 0.
Packet Identifier (PID)13Identifies the payload’s stream (video, audio, PAT, PMT, …).
Transport Scrambling Control (TSC)200 unscrambled, 01 reserved, 10 even key, 11 odd key.
Adaptation Field Control200 reserved, 01 payload only, 10 adaptation field only, 11 both.
Continuity Counter4Increments per packet per PID, wraps 15→0; detects drops/reordering. Frozen when Adaptation Field Control is 00 or 10.

Adaptation Field

Present when Adaptation Field Control is 10 or 11. Variable length, carries timing/misc data.

FieldBitsNotes
Adaptation Field Length8Byte count of everything below this byte. 0 is valid (1-byte stuffing field).
Discontinuity Indicator11 = system time base discontinuity (seek, stream switch).
Random Access Indicator11 = packet enables random access (e.g. carries an I-frame).
Elementary Stream Priority Indicator11 = higher-priority payload.
PCR Flag11 = PCR field present.
OPCR Flag11 = OPCR field present.
Splicing Point Flag11 = splice countdown field present.
Transport Private Data Flag11 = private data bytes present.
Adaptation Field Extension Flag11 = extension present.
Optional fieldsvarPCR, OPCR, splice countdown, etc. — gated by the flags above.
Stuffing bytesvar0xFF padding to fill the declared length.

Optional Fields (Gated by Flags Above)

FieldFlagBitsNotes
PCRPCR Flag4842-bit timestamp packed into 6 bytes — see below.
OPCROPCR Flag48Same layout as PCR.
Splice CountdownSplicing Point Flag8Signed; TS packets remaining until the splice point.
Transport Private Data LengthTransport Private Data Flag8Byte length of the private data that follows.
Transport Private DataTransport Private Data FlagvarBroadcaster-defined payload.
Adaptation Field ExtensionAdaptation Field Extension FlagvarSee below.

PCR / OPCR Layout

A 42-bit value packed into 6 bytes as base + extension:

FieldBitsNotes
program_clock_reference_base33Count of a 90 kHz clock.
Reserved6Ignore; typically all 1s.
program_clock_reference_extension9Count of a 27 MHz clock, for sub-tick precision.
PCR (27 MHz) = base * 300 + extension
PCR (seconds) = PCR (27 MHz) / 27_000_000

Adaptation Field Extension

Present when Adaptation Field Extension Flag is 1.

FieldBitsNotes
Adaptation Field Extension Length8Byte count following this byte.
Legal Time Window (LTW) Flag11 = LTW fields present.
Piecewise Rate Flag11 = piecewise rate field present.
Seamless Splice Flag11 = seamless splice fields present.
Reserved5
FieldFlagBitsNotes
LTW Valid FlagLTW Flag11 = legal_time_window_offset is valid.
Legal Time Window OffsetLTW Flag15Used for video buffering verification.
Piecewise RatePiecewise Rate Flag22 (+2 reserved)Bitrate over a given segment.
Splice TypeSeamless Splice Flag4Splice/bitstream characteristics at the splice point.
DTS Next Access UnitSeamless Splice Flag36DTS of the first access unit after the splice point.