What is MPEG-TS?
MPEG-TS (MPEG-2 transport stream) is a packetized container that multiplexes the video, audio, and data streams of one or more programs together with the tables that describe them; files that carry it commonly use the .ts extension. It was designed for environments where errors are likely, such as broadcast transmission.
How MPEG-TS works
An MPEG transport stream cuts elementary streams and signaling tables into fixed 188-byte packets, each labeled with a 13-bit packet identifier (PID). A receiver reads the Program Association Table on PID 0, follows it to each program’s Program Map Table, and learns from that which PIDs carry the program’s video, audio, and data. A continuity counter on each PID other than the null-packet PID helps expose lost packets, and a transport error indicator bit in each packet header, when set, flags at least one uncorrectable bit error in that packet. Program clock references are the time stamps from which decoder timing is derived. One multiplex can carry several programs with independent time bases. Because a receiver may join in the middle of a stream, the tables are normally retransmitted periodically; the standard recommends this without fixing a rate.
Key facts
- 1A transport stream packet is always 188 bytes and starts with the sync byte
0x47; 4 of those bytes are header, so framing costs at least 2.1% before adaptation fields, PES headers, or stuffing. Some systems wrap each packet in extra bytes: DVB satellite transmission appends 16 Reed-Solomon parity bytes to make 204, and FFmpeg’s demuxer also probes for a 192-byte variant, so a parser that assumes a 188-byte stride loses sync on such captures. - 2The Program Association Table on PID
0x0000lists every program and the PID of its Program Map Table, which in turn lists the PIDs of that program’s elementary streams. HLS narrows this: each transport stream segment must contain a single program and must include a PAT and a PMT, which should be its first two packets, unless anEXT-X-MAPsupplies them. Timestamps and continuity counters must also carry on from one segment to the next unless the playlist marks a discontinuity. A multi-program broadcast capture therefore has to be reduced to one program before it can serve as HLS segments. - 3The continuity counter is a 4-bit value per PID that advances by one, wrapping to zero after 15, on each packet that carries payload. It legitimately repeats on packets that carry only an adaptation field and on one immediately repeated duplicate, may jump where the stream sets the discontinuity indicator, and is undefined on null packets. Any other value is a continuity error, whose causes RFC 6990 lists as a lost packet, incorrect packet order, or a packet that occurs more than twice. When loss is the cause, the size of the jump gives the number of missing payload-carrying packets only modulo 16, so losing exactly 16, or any multiple of 16, leaves no gap.
- 4Remultiplexing can extract a single program from a multi-program stream, and insert or delete null packets to change the transport bitrate, without recompressing audio or video. The remultiplexer may have to correct program clock reference values, because their positions in the stream change. Extraction alone does not make a program ready for HLS: RFC 8216 recommends that every H.264 segment contain an IDR frame, and Apple’s HLS authoring specification accepts only H.264, HEVC, Dolby Vision, or AV1 video, requires fMP4 rather than transport streams for HEVC, requires each video segment to start with an IDR frame, and requires all interlaced source content to be deinterlaced. A broadcast program whose codec the target players do not accept, or whose keyframes do not fall at usable segment boundaries, has to be re-encoded, as does interlaced broadcast video that must meet Apple’s specification.
When MPEG-TS matters
Choose MPEG-TS for broadcast, IPTV, contribution feeds, or traditional HLS segment delivery. Its resilience and multiplexing support add overhead compared with containers optimized for reliable file storage.
How Transloadit helps with MPEG-TS
Transloadit’s FFmpeg-based Robots list MPEG-TS among the formats they can read and write. /video/encode has a segment option that splits its output into parts for HTTP Live Streaming, named by segment_prefix (the prefix segment_ gives segment_0.ts, segment_1.ts, and so on), and /video/adaptive packages renditions for HLS, MPEG-DASH, or CMAF and writes the playlist or manifest.
Explore Transloadit’s file formats & compression capabilities
Sources
- ITU-T H.222.0 | ISO/IEC 13818-1: Generic coding of moving pictures and associated audio information: Systems
- RFC 8216: HTTP Live Streaming, sections 3 Media Segments and 3.2 MPEG-2 Transport Streams
- Apple: HLS Authoring Specification for Apple Devices
- RFC 6990: RTP Control Protocol (RTCP) Extended Report (XR) Block for MPEG-2 Transport Stream (TS) Program Specific Information (PSI) Independent Decodability Statistics Metrics Reporting, section 3
- ETSI EN 300 421: DVB framing structure, channel coding and modulation for satellite services
- FFmpeg n8.0: libavformat/mpegts.h (packet size constants)