Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
MPEG transport stream
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Elements== === Packet === A [[network packet]] is the basic unit of data in a transport stream, and a transport stream is merely a sequence of packets. Each packet starts with a [[sync byte]] and a [[Header (computing)|header]], that may be followed with optional additional headers; the rest of the packet consists of [[Payload (computing)|payload]]. All header fields are read as [[Endianness#Big-endian|big-endian]]. Packets are 188 bytes in length, but the communication medium may add additional information.{{efn|[[Forward error correction]] is added by [[ISDB]] & [[DVB]] (16 bytes) and [[ATSC]] (20 bytes),<ref>{{cite web|url=http://broadcastengineering.com/infrastructure/Atsc-transmission-digital-20050620/ |title=ATSC transmission |website=Broadcastengineering.com |date=2005-06-20 |access-date=2012-05-17}}</ref> while the [[M2TS]] format prefixes packets with a 4-byte copyright and timestamp tag.}} The 188-byte packet size was originally chosen for compatibility with [[Asynchronous Transfer Mode|Asynchronous Transfer Mode (ATM) systems]].<ref>{{cite web|url=http://mpeg.chiariglione.org/faq/mp2-sys/mp2-sys.htm#mp2-12 |title=MPEG Systems FAQ |website=Mpeg.chiariglione.org |access-date=2012-05-17}}</ref><ref>{{cite web|url=http://www.tek.com/datasheet/atsc-mpeg-transport-stream-monitor |title=ATSC MPEG Transport Stream Monitor |website=Tek.com |access-date=2012-05-17}}</ref> {|class="wikitable" |+ Partial transport stream packet format !Name !Number of bits ![[Bitmask]] ([[big-endian]]) !Description |- |colspan=4 style="text-align: center" |''4-byte Transport Stream Header'' |- |[[Sync byte]] |style="text-align:center;"|8 |style="text-align:right;"|<code>0xff000000</code> |Bit pattern of 0x47 (ASCII char 'G') |- |Transport error indicator (TEI) |style="text-align:center;"|1 |style="text-align:right;"|<code>0x800000</code> |Set when a [[demodulator]] can't correct errors from FEC data; indicating the packet is corrupt.<ref>{{cite web |url=http://www.coolstf.com/tsreader/support.html |title=TSReader |website=Coolstf.com |date=2008-04-07 |access-date=2012-05-17 |archive-url=https://web.archive.org/web/20100327060631/http://www.coolstf.com/tsreader/support.html |archive-date=27 March 2010 |url-status=dead }}</ref> |- |Payload unit start indicator (PUSI) |style="text-align:center;"|1 |style="text-align:right;"|<code>0x400000</code> |Set when this packet contains the first byte of a new payload unit. For [[Program-specific information|PSI]] packet data, the first byte of the payload will indicate where this new payload unit starts. For [[Packetized elementary stream|PES]] packet data, the new PES packet shall start at the start of the payload.<ref>{{Cite web |date=February 2000 |title=Information technology β Generic coding of moving pictures and associated audio information: systems |url=https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-H.222.0-200002-S!!PDF-E&type=items }}</ref> This field allows a receiver that started reading mid transmission to know when it can start extracting data. |- |Transport priority |style="text-align:center;"|1 |style="text-align:right;"|<code>0x200000</code> |Set when the current packet has a higher priority than other packets with the same PID. |- |PID |style="text-align:center;"|13 |style="text-align:right;"|<code>0x1fff00</code> |Packet Identifier, describing the payload data. |- |Transport scrambling control (TSC) |style="text-align:center;"|2 |style="text-align:right;"|<code>0xc0</code> | '00' = Not scrambled. For [[DVB-CSA]] and [[Data Encryption Standard|ATSC DES]] only:<ref>{{cite web|url=http://www.dvb.org/technology/standards/a125_CSA3_dTR101289.v1.2.1.pdf|title=Standards β DVB|website=Dvb.org|access-date=11 September 2012|archive-url=https://web.archive.org/web/20110313135150/http://www.dvb.org/technology/standards/a125_CSA3_dTR101289.v1.2.1.pdf|archive-date=13 March 2011|url-status=dead}}</ref><br />'01' <small>(0x40)</small> = Reserved for future use<br />'10' <small>(0x80)</small> = Scrambled with even key<br />'11' <small>(0xC0)</small> = Scrambled with odd key |- |Adaptation field control |style="text-align:center;"|2 |style="text-align:right;"|<code>0x30</code> |01 β no adaptation field, payload only, <br /> 10 β adaptation field only, no payload, <br /> 11 β adaptation field followed by payload, <br /> 00 β RESERVED for future use <ref>{{Cite web |url=http://www.abdn.ac.uk/erg/research/future-net/digital-video/mpeg2-trans.html |title=MPEG-2 Transmission |first=Gorry |last=Fairhurst |access-date=30 November 2018 |archive-url=https://web.archive.org/web/20170813122328/http://www.abdn.ac.uk/erg/research/future-net/digital-video/mpeg2-trans.html |archive-date=13 August 2017 |url-status=dead }}</ref> |- |Continuity counter |style="text-align:center;"|4 |style="text-align:right;"|<code>0xf</code> |Sequence number of payload packets <small>(0x00 to 0x0F)</small> within each stream (except PID 8191)<br/>Incremented per-PID, only when a payload flag is set. |- |colspan=4 style="text-align: center" |''Optional fields'' |- |Adaptation field |style="text-align:center;"|variable|| |Present if ''adaptation field control'' is 10 or 11. See below for format. |- |[[Payload (computing)|Payload]] data |style="text-align:center;"|variable|| |Present if ''adaptation field control'' is 01 or 11. Payload may be PES packets, program specific information (below), or other data. |} {|class="wikitable" |+ Adaptation field format !Name !Number of bits !Bitmask !Description |- |Adaptation field length |style="text-align:center;"|8|| |Number of bytes in the adaptation field immediately following this byte |- |Discontinuity indicator |style="text-align:center;"|1 |style="text-align:right;"|<code>0x80</code> |Set if current TS packet is in a discontinuity state with respect to either the continuity counter or the program clock reference |- |Random access indicator |style="text-align:center;"|1 |style="text-align:right;"|<code>0x40</code> |Set when the stream may be decoded without errors from this point |- |[[Elementary stream]] priority indicator |style="text-align:center;"|1 |style="text-align:right;"|<code>0x20</code> |Set when this stream should be considered "high priority" |- |PCR flag |style="text-align:center;"|1 |style="text-align:right;"|<code>0x10</code> |Set when PCR field is present |- |OPCR flag |style="text-align:center;"|1 |style="text-align:right;"|<code>0x08</code> |Set when OPCR field is present |- |Splicing point flag |style="text-align:center;"|1 |style="text-align:right;"|<code>0x04</code> |Set when splice countdown field is present |- |Transport private data flag |style="text-align:center;"|1 |style="text-align:right;"|<code>0x02</code> |Set when transport private data is present |- |Adaptation field extension flag |style="text-align:center;"|1 |style="text-align:right;"|<code>0x01</code> |Set when adaptation extension data is present |- |colspan=4 style="text-align: center" |''Optional fields'' |- |PCR |style="text-align:center;"|48|| |Program clock reference, stored as 33 bits base, 6 bits reserved, 9 bits extension.<br/>The value is calculated as base * 300 + extension. |- |OPCR |style="text-align:center;"|48|| |Original Program clock reference. Helps when one TS is copied into another |- |Splice countdown |style="text-align:center;"|8|| |Indicates how many TS packets from this one a splicing point occurs ([[Two's complement]] signed; may be negative) |- |Transport private data length |style="text-align:center;"|8|| |The length of the following field |- |Transport private data |style="text-align:center;"|variable|| |Private data |- |Adaptation extension |style="text-align:center;"|variable|| |See below |- |Stuffing bytes |style="text-align:center;"|variable|| |Always <code>0xFF</code> |} {|class="wikitable" |+ Adaptation extension format !Name !Number of bits !Bitmask !Description |- |Adaptation extension length |style="text-align:center;"|8 |<code>0xff00</code> |The length of the header |- |Legal time window (LTW) flag |style="text-align:center;"|1 |<code>0x0080</code> | |- |Piecewise rate flag |style="text-align:center;"|1 |<code>0x0040</code> | |- |Seamless splice flag |style="text-align:center;"|1 |<code>0x0020</code> | |- |Reserved |style="text-align:center;"|5 |<code>0x001f</code> | |- |colspan=4 style="text-align: center" |''Optional fields'' |- |colspan=4 |'''LTW flag set''' (2 bytes) |- |LTW valid flag |style="text-align:center;"|1 |<code>0x8000</code> | |- |LTW offset |style="text-align:center;"|15 |<code>0x7fff</code> |Extra information for rebroadcasters to determine the state of buffers when packets may be missing. |- |colspan=4 |'''Piecewise flag set''' (3 bytes) |- |Reserved |style="text-align:center;"|2 |<code>0xc00000</code> | |- |Piecewise rate |style="text-align:center;"|22 |<code>0x3fffff</code> |The rate of the stream, measured in 188-byte packets, to define the end-time of the LTW. |- |colspan=4 |'''Seamless splice flag set''' (5 bytes) |- |Splice type |style="text-align:center;"|4 |<code>0xf000000000</code> |Indicates the parameters of the H.262 splice. |- |DTS next access unit |style="text-align:center;"|36 |<code>0x0efffefffe</code> |The PES DTS of the splice point. Split up as multiple fields, 1 marker bit (0x1), 15 bits, 1 marker bit, 15 bits, and 1 marker bit, for 33 data bits total. |} <div style="clear:both" > {| class="wikitable" |+Payload format !Name !Number of bits !Bitmask !Description |- |Payload Pointer (optional) |8 |0xff |Present only if the Payload Unit Start Indicator (PUSI) flag is set, and the packet data type is PSI (not PES). It gives the index after this byte at which the new payload unit starts. Any payload byte before the index is part of the previous payload unit. |- |Actual Payload |variable | |The content of the payload. |} </div> ===Packet identifier (PID)=== Each table or elementary stream in a transport stream is identified by a 13-bit packet identifier (PID). A [[Inverse multiplexer|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. {| class="wikitable" |+ Packet identifiers in use |- ! Decimal !! Hexadecimal !! Description |- |0 |0x0000 |Program association table (PAT) contains a directory listing of all program map tables |- |1 |0x0001 |[[Conditional access]] table (CAT) contains a directory listing of all ITU-T Rec. H.222 entitlement management message streams used by program map tables |- |2 |0x0002 |Transport stream description table (TSDT) contains descriptors relating to the overall transport stream |- |3 |0x0003 |IPMP control information table contains a directory listing of all ISO/IEC 14496-13 control streams used by program map tables |- |4β15 |0x0004-0x000F |Reserved for future use |- |16β31 |0x0010-0x001F |Used by [[DVB]] [[metadata]]<ref name="PID used by DVB">{{cite book |url=http://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.13.01_40/en_300468v011301o.pdf |page=20 |section=5.1.3 Coding of PID and table_id fields |series=EN |volume=300 468 |edition=v1.13.1 |title=Digital Video Broadcasting (DVB); Specification for Service Information (SI) in DVB systems |website=Etsi.org|year=2012 |access-date=2016-10-13}}</ref> * 0x0010: NIT, ST * 0x0011: [[Service Description Table|SDT]], BAT, ST * 0x0012: EIT, ST, CIT * 0x0013: RST, ST * 0x0014: TDT, TOT, ST * 0x0015: network synchronization * 0x0016: RNT * 0x0017-0x001B: reserved for future use * 0x001C: inband signalling * 0x001D: measurement * 0x001E: DIT * 0x001F: SIT |- |32-8186 |0x0020-0x1FFA |May be assigned as needed to program map tables, elementary streams and other data tables |- |8187 |0x1FFB |Used by [[DigiCipher 2]]/[[ATSC]] MGT [[metadata]] |- |8188β8190 |0x1FFC-0x1FFE |May be assigned as needed to program map tables, elementary streams and other data tables |- |8191 |0x1FFF |Null Packet (used for fixed bandwidth padding) |} ===Programs=== Transport stream has a concept of ''programs''. Every program is described by a program map table (PMT). The elementary streams associated with that program have PIDs listed in the PMT. Another PID is associated with the PMT itself. 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 [[ATSC tuner|receiver]] wishing to decode one of the three channels 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 a multi-program transport stream (MPTS). A single program transport stream is referred to as a single-program transport stream (SPTS). ===Program specific information=== {{Main article|Program-specific information}} There are 4 program specific information (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. === PCR ===<!-- This section is linked from [[PCR (disambiguation)]] --> To enable a decoder to present synchronized content, such as audio tracks matching the associated video, at least once each 100 ms, a ''program clock reference'' (PCR) is transmitted in the adaptation field of an MPEG-2 transport stream packet. The PID with the PCR for an MPEG-2 program is identified by the ''pcr_pid'' value in the associated PMT. The value of the PCR, when properly used, is employed to generate a ''system_timing_clock'' in the decoder. The system time clock (STC) decoder, when properly implemented, provides a highly accurate time base that is used to synchronize audio and video elementary streams. Timing in MPEG-2 references this clock. For example, the [[presentation time stamp]] (PTS) is intended to be relative to the PCR. The first 33 bits are based on a 90 kHz clock. The last 9 bits are based on a 27 MHz clock. The maximum jitter permitted for the PCR is {{no wrap|+/- 500 ns}}. ===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 null packets have a payload that is filled with 0xFF, and the receiver is expected to ignore its contents.<ref>{{citation |url=http://www.img.lx.it.pt/~fp/cav/Additional_material/MPEG2_overview.pdf |title=A Guide to MPEG Fundamentals and Protocol Analysis |publisher=Tektronix |access-date=2020-04-23 |page=37}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)