MPEG transport stream
From Wikipedia, the free encyclopedia
Transport stream (TS, TP, MPEG-TS, or M2T) is a communications protocol for audio, video, and data. It is a type of digital container format that encapsulates packetized elementary streams and other data. TS is specified in MPEG-2 Part 1, Systems (ISO/IEC standard 13818-1).[1] It is also known as ITU-T Rec. H.222.0. 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. It is contrasted with program stream, designed for more reliable media such as DVDs.
Contents |
[edit] Layers of communication
Similar to the OSI network protocol stack, a transport stream is processed by the receiver in layers. An example stream containing video may be processed as follows:
- Composition of the various programs
- Packetized Elementary Stream (PES)
- Elementary stream (ES) — audio or video (the below is for video only)
- Group of pictures (GOP) — providing random access points
- Slice — preventing an error from being propagated through intra prediction
- Macroblock—consisting of 6 to 12 DCT blocks
- Encoding block or just block—a DCT encoding block, 8x8 pixels
An example of data that is muxed into the transport stream is an electronic program guide. See Program and System Information Protocol for more information.
[edit] Important elements of a transport stream
[edit] Packet
Name | Number of bits |
Description |
---|---|---|
sync byte | 8 | 0x47 |
Transport Error Indicator (TEI) | 1 | Set by demodulator if can't correct errors in the stream[2] |
Payload Unit Start Indicator | 1 | 1 means start of PES data or PSI otherwise zero only. |
Transport Priority | 1 | One means higher priority than other packets with the same PID. |
PID | 13 | Packet ID |
Scrambling control | 2 | '00' = Not scrambled. The following per DVB spec:[3] '01' = Reserved for future use, '10' = Scrambled with even key, '11' = Scrambled with odd key |
Adaptation field exist | 1 | 1 means presence of the adaptation field |
Payload data exist | 1 | 1 means presence of data |
Continuity counter | 4 | |
Note: the total number of bits above is 32 and is called the transport stream 4-byte prefix. | ||
Adaptation field | 0 or more | Depends on flags |
Payload Data | 0 or more | Depends on flags |
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 Packet Identifier (PID). This is followed by a 4-bit continuity counter. Additional optional transport fields, as signaled in the optional adaptation field, may follow. The rest of the packet consists of payload. Packets are 188 bytes in length[4] , but the communication medium may add some error correction bytes to the packet. DVB-ASI uses 204 bytes and ATSC 208 bytes as transport stream packet. ATSC transmission adds 20 bytes of Reed-Solomon forward error correction to create a packet that is 208 bytes long [5]. The 188-byte packet size was originally chosen for compatibility with ATM systems [6] [7] .
Name | Number of bits |
Description |
---|---|---|
Adaptation Field Length | 8 | Number of bytes in the adaptation field immediately following this byte |
Discontinuity indicator | 1 | Set to 1 if a discontinuity occurred in the continuity counter of the TS packet |
Random Access indicator | 1 | Set to 1 if the PES packet in this TS packet starts a video/audio sequence |
Elementary stream priority indicator | 1 | 1 = higher priority |
PCR flag | 1 | 1 means adaptation field does contain a PCR field |
OPCR flag | 1 | |
Splicing point flag | 1 | 1 means presence of splice countdown field in adaptation field |
Transport private data flag | 1 | 1 means presence of private data bytes in adaptation field |
Adaptation field extension flag | 1 | 1 means presence of adaptation field extension |
Below fields are optional | variable | Depends on flags |
PCR | 33+9 | Program clock reference |
OPCR | 33+9 | Original Program clock reference. Helps when one TS is copied into another |
Splice countdown | 8 | Indicates how many TS packets from this one a splicing point occurs (may be negative) |
stuffing bytes | variable |
[edit] PID
Each table or elementary stream in a transport stream is identified by a 13-bit packet ID (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.
[edit] Programs
Transport stream has a concept of programs. Each single program is described by a Program Map Table (PMT) which has a unique PID, and the elementary streams associated with that program have PIDs listed in the PMT. 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 decode a particular "channel" merely has to decode the payloads of each PID associated with its program. It can discard the contents of all other PIDs. A transport stream with more than one program is referred to as MPTS - Multi Program Transport Stream. A single program transport stream is referred to as SPTS.
[edit] Program Specific Information (PSI)
There are 4 PSI tables: Program Association (PAT), Program Map (PMT), Conditional Access (CAT), and Network Information (NIT). The MPEG-2 specification does not specify the format of the CAT and NIT.
[edit] PAT
PAT stands for Program Association Table. It lists all programs available in the transport stream. Each of the listed programs is identified by a 16-bit value called program_number. Each of the programs listed in PAT has an associated value of PID for its Program Map Table (PMT).
The value 0x0000 of program_number is reserved to specify the PID where to look for Network Information Table (NIT). If such a program is not present in PAT the default PID value (0x0010) shall be used for NIT.
TS Packets containing PAT information always have PID 0x0000.
[edit] PMT
Program Map Tables (PMTs) contain information about programs. For each program, there is one PMT. Each PMT shall be transmitted on a separate PID although technically it is not required. The PMTs describe which PIDs contain data relevant to the programs. 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.
[edit] 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. This is also known as the master clock. Timing in MPEG2 references this clock, for example the presentation time stamp (PTS) is relative to the PCR. The first 33 bits is based on a 90kHz clock, increment bit extension is ed for each Hertz or cycle. The 9-based on a 27MHz clock.
[edit] 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 not contain any data at all, and the receiver is expected to ignore its contents.
[edit] Modifications of transport stream specification for random-access media (M2TS)
[edit] Timecode
Transport Stream was designed for tape and broadcast, but it required modifications for usage with random-access media devices like new generation of digital camcorders that record onto DVD disks, Blu-ray disks, hard drives or solid-state memory cards.
Random-access based systems may save data packets into a temporary buffer if a storage device is not ready, for example on device startup. Packets are written out of order, and to keep track of them, a 4-byte timecode (TC) is added to standard 188-byte packets. The result is a 192-byte packet. This is what is informally called M2TS stream. Sony calls it "BDAV MPEG-2 transport stream". JVC calls it TOD (possibly an abbreviation for "Transport stream on media") when used in HDD-based camcorders like GZ-HD7.[8] M2TS transport stream is also used for AVCHD video files, which often have MTS extension.
[edit] Programs that open TS files
[edit] Multiple OS
- FFmpeg
- MPlayer [9]
- VideoLAN VLC media player [10]
[edit] Linux
[edit] Windows
- Combined Community Codec Pack [11]
- GOM Player
- Haenlein-Software DVR Studio
- Squared 5 MPEG Streamclip [12]
- VideoReDo [13]
- VobEdit [14]
[edit] Mac OS X
- Squared 5 MPEG Streamclip [15]
[edit] References
- ^ http://neuron2.net/library/mpeg2/iso13818-1.pdf
- ^ TSReader Support
- ^ DVB scrambling control bits defined. Page 6
- ^ ISO/IEC 13818-1 Second edition. 2000-12-01. p. xi or 11 according to PDF viewer. http://neuron2.net/library/mpeg2/iso13818-1.pdf.
- ^ ATSC transmission
- ^ MPEG Systems FAQ
- ^ Tektronix: Products > ATSC MPEG Transport Stream Monitor - AT970: Characteristics/Specs
- ^ "Steve Mullen, M2TS primer". http://dvinfo.net/conf/showthread.php?t=105486.
- ^ http://www.mplayerhq.hu/
- ^ http://www.videolan.org/vlc/
- ^ http://cccp-project.net
- ^ http://www.squared5.com
- ^ http://www.videoredo.com
- ^ http://www.free-codecs.com/download/VobEdit.htm
- ^ http://www.squared5.com
[edit] See also
- ATSC tuner
- DVB
- Elementary stream
- Flash Video
- Program stream
- IPTV
- MPEG-2
- Packetized Elementary Stream
- Program and System Information Protocol
- Unidirectional Lightweight Encapsulation (ULE)
- HDV and AVCHD, which both implement TS streams to packetize data
[edit] External links
- MPEG-2 Systems FAQ
- MPEG-4 Systems FAQ
- MPEG-1 description
- Powerpoint MPEG-2 Transport Stream introduction [1]
- Splicing FAQ
- OpenCaster free GPL licensed software for transport stream broadcasting
- Freeware TS-Muxer
- DVB Transport Stream.pdf (currently does not work?) WaybackMachine
- MPEG-2 Transport Stream
- MPEG-2 Transmission
- ITU Recommendation H.222.0
|