Transport Stream Analysis

A Transport Stream packet is a fixed length packet, there are a few Transport Stream packet sizes to be aware of:

188 Transport Stream

192 Transport Stream + 4 bit Timecode (MT2S Blu Ray)

204 Transport Stream + FEC (DVB-T/C/S)

208 Transport Stream + FEC (ATSC 8-VSB, 208)

208 Transport Stream + Reed Solomon (ATSC)

Transport Stream Packets are the basic units of a Transport Stream, each TS packet starts with a Sync Byte (0x47) and this is used to identify each packet (so 0x47 shouldn’t be used elsewhere in the packet).
Each TS packet has a 32 bit header, shown below.
The TS Header above (also called the TS 4 Byte Prefix) is from a real TS packet, below is the TS header in Hex.

Name	Bits	Bin	Hex	Dec	Description
Sync Byte	8	01000111	0x47	Sync Byte
TS Error	1	0	0x00	Error indicator (0=No Error, 1=Error)
Start Indicator	1	0	0x00	1 means start of PES or PSI otherwise 0
Transport Priority	1	0	0x00	see table below
PID	13	1111111111111	1FFF	8191	PID is 8191 (1FFF) = stuffing packet
Scrambling	2	00	0x00	00 = not scrambled
Adaptation Field Exist	2	01	0x01	01 means no adaptation fields
CC Counter	4	1001	0x09	continuity counter
Total	32