User Tools

Site Tools


transport_stream_analysis

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



Looking at the bits of the example TS Header tells us a few things about the packet we are analysing. Importantly we can see this packet has no (apparent) errors, the PID tells us it is a stuffing packet, there is no adaptation field and we have a continuity counter that helps us determine whether there are any missing packets.



In the above diagram it can be seen that the overall format of the TS packet is as follows:

TS Header → Adaptation Field → Data Payload

A PES packet is a TS packet that has had its TS and Adaptation components removed (so the payload basically) and the PES packet has a 32bit (4 Byte) PES header.


PCR PTS DTS


The PCR is a sample of the Encoders 27Mhz clock, the PCR comprises of 33bits + 9 bits.

The format of the 42-bit 27MHz clock is slightly peculiar in that the 33 MSBs count normally at a rate of 90kHz and the 9 LSBs count mod 300 (i.e.0-299). This strange arrangement allows a 27MHz clock, which is readily compatible with the 90kHz time stamps in the program material.

PCR is for the synchronization of the decoders clock, the 27Mhz clock in the Encoder is sampled, and this is used to synchronise the 27Mhz clock in the decoder. With the clocks in sync (so any error on the Encoder clock is also on the decoder clock) the timestamps in the PTS and DTS will still match the decoded PCR.

For DVB Transport Streams the a PCR needs to be present every 40mS (so every frame).

The DTS is the Decode Timestamp, while the encoding process GoP might be IBBP, the frames can not be decoded in that order, so encoder frames are reordered and time stamped in their Decode order.

Below is an example, the I frame must be decoded first, then P frame can then be decoded, once the I and P are decoded the B frames can then also be decoded. So the correct decode order is IPBB.



The PTS is the Presentations Timestamp, this is the order in which the frames must be displayed (presented) to the user (the screen)



So having PTS and DTS timestamps in the PES header allows the decoder to decode and display the frames in the correct order.

The PTS and DTS are 33bit, 90kHz versions of the clock.


Transport Stream Packet Description





Adaption Field Format Description




transport_stream_analysis.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1