Theory 101:

A Basic Guide to Transport Streams

Transport Stream Structure
Video Structure


A transport stream needs timing information to make sure Video and Audio are shown at the right time and in sync.
The most important timecodes are:
The basic unit of a timecode is the Tick and there are 90 000 Ticks in a second.

Programme Clock Reference (PCR)

The Programme Clock Reference (PCR) is a reference clock the decoder can use to keep track of all timing information and keep streams in sync.
If the PTS or DTS timestamps are corrupted, the decoder can use the PCR to recreate the corrupted timestamps.
The PCR always increments linearly so can also be used to seek video.
For greater accuracy, the PCR has an extension which increases the resolution to 27MHz (instead of 90KHz for PTS and DTS)
There can be a PCR present for each Programme (PMT) or there can be one PCR for the entire Transport stream. In this case, the PCR is usually carried on a separate PID, commonly 0x1FFE or 0x1FE.
The PCR can also be present on the Video PID for a Programme (PMT) or on the audio PID in the case of a radio programme.
The PMT points to the PID which carries the PCR timestamps.
The PCR is essential for correct decoding of the Transport Stream

Presentation Time Stamp (PTS)

The PTS tells the decoder when to display or present a frame in the stream.
The PTS is present for elementary streams such as Video, Audio & Subtitles.

Decode Time Stamp (DTS)

The DTS tells the decoder when to decode a frame in the stream.
The DTS is present for elementary streams such as Video, Audio & Subtitles.
The DTS is slightly ahead of the PTS to allow the decoder time to decode the frame before the decoder needs to present it.