MPEG-2 Transport Stream

From MultimediaWiki
Jump to navigation Jump to search

Transport stream (TS) is a format specified in MPEG-2 Part 1, Systems (ISO/IEC standard 13818-1). Its design goal is to allow multiplexing of digital video and audio and to synchronize the output. Transport stream offers features for error correction for transportation over unreliable media, and is used in broadcast applications such as DVB and ATSC.

Some Important Elements of a Transport Stream

Packet

A packet is the basic unit of data in a transport stream. It consists of a sync byte, whose value is 0x47, followed by three one-bit flags and a 13-bit PID. This is followed by a 4-bit continuity counter, which usually increments with each subsequent packet of a frame, and can be used to detect missing packets. Additional optional transport fields, whose presence may be signalled in the optional adaptation field, may follow. The rest of the packet consists of payload. Packets are most often 188 bytes in length, but some transport streams consist of 204-byte packets which end in 16 bytes of Reed-Solomon error correction data. The 188-byte packet size was originally chosen for compatibility with ATM systems[1].

PID

Each table or elementary stream in a transport stream is identified by a 13-bit PID. A demultiplexer extracts elementary streams from the transport stream in part by looking for packets identified by the same PID. In most applications, Time-division multiplexing will be used to decide how often a particular PID appears in the transport stream.

Programs

Transport stream has a concept of programs, which are groups of one or more PIDs that are related to each other. For instance, a transport stream used in digital television might contain three programs, to represent three television channels. Suppose each channel consists of one video stream, one or two audio streams, and any necessary metadata. A receiver wishing to tune to a particular "channel" merely has to decode the payload of the PIDs associated with its program. It can discard the contents of all other PIDs.

PAT

PAT stands for Program Association Table. The PAT lists PIDs for all PMTs in the stream. Packets containing PAT information always have PID 0x0.

PMT

Program Map Tables, or PMTs, contain information about programs. For each program, there is a PMT, with the PMT for each program appearing on its own PID. The PMTs describe which PIDs contain data relevant to the program. PMTs also provide metadata about the streams in their constituent PIDs. For example, if a program contains an MPEG-2 video stream, the PMT will list this PID, describe it as a video stream, and provide the type of video that it contains (in this case, MPEG-2). The PMT may also contain additional descriptors providing data about its constituent streams.

PCR

To assist the decoder in presenting programs on time, at the right speed, and with synchronization, programs usually periodically provide a Program Clock Reference, or PCR, on one of the PIDs in the program.

Null Packets

Some transmission schemes, such as those in ATSC and DVB, impose strict constant bitrate requirements on the transport stream. In order to ensure that the stream maintains a constant bitrate, a multiplexer may need to insert some additional packets. The PID 0x1FFF is reserved for this purpose. The payload of null packets may contain any data at all, and the receiver is expected to ignore its contents. As it happens, most multiplexers place all 0's or all F's in these packets, but a few have been seen to insert secret messages for the enjoyment of bored engineers.