EdgeOne Logo
Tencent EdgeOne Blog

What is TS File Format and How to Play TS Videos?

Tencent EdgeOne - Product Manager


Many people may not be familiar with the TS file format, as it is not as popular as the MP4 format. To help you better understand TS videos, this article will provide detailed information about the origin of the TS video format, its applications, how to open it, and how to edit and convert it.

What is a TS Video?

A TS file, short for Transport Stream, is a type of video file format used for storing, transmitting, and playing digital video and audio streams. TS is an encapsulated format, also known as MPEG2-TS. MPEG2-TS is a standard data container format for transmitting and storing audio and video, as well as program and system information protocol data. It is mainly used in digital broadcasting systems, such as DVB, ATSC, and IPTV. The transport stream was originally designed for broadcasting. Later, by adding a 4-byte time code (TC) to the standard 188-byte data packet, making it a 192-byte data packet, it was adapted for use with digital cameras, video recorders, and players.

MPEG2 is a multimedia transmission and multiplexing technology that can provide hundreds of program channels in digital TV broadcasting. Multiplexing means that multiple layers of programs can be transmitted simultaneously. In the MPEG-2 standard, there are two different types of bitstreams output to the channel: one is the program stream (PS), which is suitable for scenarios without transmission errors, and the other is the transport stream (TS), which is suitable for scenarios with channel noise. 

The program stream is used for stable and reliable media, such as optical discs (e.g. DVD/CD), while the transport stream is used for unstable transmission, such as terrestrial or satellite broadcasting. In addition, the transport stream can transmit multiple programs, and they do not have a hierarchical relationship. Logically, they are all composed of PES (Packetized Elementary Stream) packets, so they can be easily converted between each other.

What is TS File Format?

TS videos (streams) can be divided into three layers: TS layer (Transport Stream), PES layer (Packetized Elementary Stream), and ES layer (Elementary Stream).

The ES layer contains the audio and video data, the PES layer adds information about the data frames, such as time stamps, to the audio and video data, and the TS layer adds necessary information for data stream identification and transmission to the PES layer. A TS video (stream) is composed of multiple TS packets.

TS Layer

The size of a TS packet is fixed at 188 bytes. The TS layer is divided into three parts: TS header, Adaptation Field, and Payload. The TS header is fixed at 4 bytes. The Adaptation Field may or may not exist and is mainly used to fill in data that is less than 188 bytes. The Payload contains the PES data.


1. TS Header

TS packet header provides information about the transmission.

The length of the TS packet header is not fixed. The first 4 bytes are fixed, and there may be an adaptation field following the header. The 4 bytes are the minimum header length.

The structure fields of the packet header are as follows:

  • sync_byte (Synchronization byte): Fixed at 0x47. This byte is recognized by the decoder to separate the packet header and payload.
  • transport_error_indicator (Transport error flag): '1' indicates that there is at least one uncorrectable error bit in the related transport packet. Once set to 1, it cannot be reset to 0 until the error is corrected.
  • payload_unit_start_indicator (Payload start flag): When set to 1, it indicates that the payload of the current TS packet contains the start position of PES or PSI. After the first 4 bytes, there will be an adaptation byte with a value of length for the length of the following adaptation field. Therefore, the position where the payload starts should be offset by 1+[length] bytes.
  • transport_priority (Transport priority flag): '1' indicates that the priority of the current TS packet is higher than other TS packets with the same PID that do not have this bit set to '1'.
  • PID: Indicates the type of data stored in the grouping effective payload.
  • transport_scrambling_control (Scrambling control flag): Indicates the encryption mode of the effective payload of the TS stream grouping. Empty packets are '00'. If the adaptation field is included in the packet header, it should not be encrypted. Other values are user-defined.
  • adaptation_field_control (Adaptation field control flag): Indicates whether the packet header has an adaptation field or effective payload. '00' is reserved for future use by ISO/IEC; '01' contains only effective payload without adaptation field; '10' contains only adaptation field without effective payload; '11' effective payload follows the adaptation field, and the first byte in the adaptation field indicates the length of the adaptation field, and the position where the payload starts should be offset by [length] bytes. Empty packets should be '10'.
  • continuity_counter (Continuity counter): Increases with each TS stream grouping with the same PID and returns to 0 after reaching the maximum value. The range is 0~15.

2. TS Adaptation Field

The length of the Adaptation Field should include one byte for the Transport Error Indicator flag.

PCR (Program Clock Reference) is a program clock reference. PCR, DTS, and PTS are all sampling values of the same system clock. PCR is incremental, so it can be set to the DTS value, and the audio data does not need PCR.

When packing the TS stream, the PAT and PMT tables do not have an Adaptation Field. If the length is insufficient, it can be filled with 0xff.

Both the video stream and audio stream require an adaptation field, which is usually added to the first and last TS packets of a frame, but not added to the middle TS packets.

3. TS Payload

The information transmitted in the Payload of a TS packet includes two types: PES packets for video and audio, as well as auxiliary data; Program Specific Information (PSI).

TS packets can also be empty packets. Empty packets are used to fill the TS stream and may be inserted or deleted during remultiplexing.

The ES streams of video and audio need to be packaged into PES streams. Auxiliary data (such as teletext information) does not need to be packaged into PES packets.

PES Layer & ES Layer

1. PES Layer


The PES layer adds information such as time stamps to each video/audio frame. The content of a PES packet can be complex, but the most commonly used fields are:

  1. PES start code: Fixed at 0x000001.
  2. Stream ID: For audio, the value is between 0xc0-0xdf, usually 0xc0. For video, the value is between 0xe0-0xef, usually 0xe0.
  3. PES packet length: The length of the PES data that follows. A value of 0 indicates that the length is not limited, but only the video data length may exceed 0xffff.
  4. PES data length: The length of the data that follows, with a value of 5 or 10.
  5. PTS: A 33-bit value indicating the Presentation Time Stamp.
  6. DTS: A 33-bit value indicating the Decoding Time Stamp.

PTS (Presentation Time Stamp) is used for display timing, while DTS (Decoding Time Stamp) is used for decoding timing.

Both video and audio data require both PTS and DTS timestamps. However, for audio data, PTS and DTS are the same, so only PTS is required.

PTS and DTS are both used for B-frames. For I-frames and P-frames, PTS is equal to DTS. If a video stream does not contain B-frames, then PTS will always be equal to DTS.

When reading video frames from a file, the order of the frames is the same as the order of the DTS timestamps. The DTS algorithm is relatively simple, with an initial value plus an increment. The PTS calculation is more complex and requires an offset added to the DTS.

For audio PES, only PTS (same as DTS) is required, while for video I-frames and P-frames, both PTS and DTS timestamps are required. For video B-frames, only PTS (same as DTS) is required.

2. ES Layer

The ES layer refers to the elementary stream layer, which contains the raw audio and video data.

In general, video is encoded in H.264 format, while audio is encoded in AAC format.

Why to Use TS File Format?

As a type of container file format, the TS videos has a wide range of applications, including:

1. Broadcasting and television:TS videos is commonly used in broadcasting systems such as DVB and ATSC. The format has error correction and stream synchronization functions, which can maintain transmission integrity when the signal is degraded. The most classic application of TS streams is in digital high-definition television that we use in our daily lives.

2. Real-time streaming media: Apple's HTTP Live Streaming media is based on TS files. In live broadcasting, video streams are sliced or segmented into file fragments for transmission, or played sequentially through given TS file addresses.

3. Blu-ray discs / Full HD videos: As a container format, TS can encapsulate MPEG-2 or VC-1 encodings, and is also a commonly used container format for Blu-ray discs and Full HD videos. Therefore, videos in the TS format usually have high video quality, large file size, and accurate restoration, making it a favorite format among high-definition enthusiasts.

4. Digital cameras: To be used in digital cameras, the TS format grouping has an added 4-byte time code. In addition, with the help of time codes, it can be used to synchronize content shot by multiple cameras.

The TS video format is used for several reasons:

  1. Error correction: TS videos are designed to handle errors better than other formats. This is crucial for data that's being streamed or broadcast over networks where data loss might occur.
  2. Multiplexing: TS videos can contain multiple audio and video streams, as well as metadata. This makes them ideal for broadcasting applications where you might need to include multiple languages, subtitles, or additional data services.
  3. Synchronization: The TS format includes timing information, ensuring that the audio and video streams can be correctly synchronized on playback.
  4. Compatibility: The TS video format is part of the MPEG-2 standard, which is widely supported in both hardware and software, making it a good choice for broadcasting.
  5. High Quality: TS videos maintain high-quality video and audio, making them suitable for professional broadcasting and production.

How to Play TS Videos?

There are several programs that support TS Videos:

  • VLC Media Player
  • Windows Media Player
  • MPC-HC
  • KMPlayer
  • PotPlayer

Some TS videos may require additional codecs to play properly. If you encounter any issues playing a TS file, you may need to install additional codecs or use a different media player.

How to Convert TS to MP4?

If you want to play TS video files on your mobile or other portable media player, the best way is to convert them to a more accessible format, such as MP4. While both TS and MP4 formats are used for storing video files and streaming media, they are vastly different in their applicable areas. TS is more suitable for professional streaming media playback, while MP4 is an excellent choice for storing and watching videos on computers and mobile devices. If you want to play TS video files on a mobile device, it's best to convert them to MP4 format for easier access and playback.

Below is a table explaining the salient difference between TS and MP4.


To convert TS to MP4, you can use a video converter software. There are many video converter software available, such as HandBrake, Freemake Video Converter, Any Video Converter, and Wondershare UniConverter. The steps to convert TS to MP4 may vary slightly depending on the software you use.

Tencent EdgeOne

Tencent EdgeOne is a product of Tencent Cloud that can process video on edge devices. Here are the advantages of Tencent EdgeOne:

  1. Low latency: Tencent EdgeOne can perform real-time video processing on edge devices, reducing the delay in video transmission. This is important for real-time video applications, such as live streaming and video conferencing.
  2. High performance: Tencent EdgeOne supports hardware acceleration, which can greatly improve the efficiency of video processing. This means it can achieve high-quality video processing with lower computing resources.
  3. Low cost: Tencent EdgeOne can perform video processing on edge devices, reducing the computational burden on the cloud. This can lower the cloud computing costs of enterprises.
  4. Scalability: Tencent EdgeOne supports a variety of video processing algorithms and models, allowing you to choose the appropriate algorithm and model depending on the specific application scenario. This enables Tencent EdgeOne to be applied to a variety of video processing scenarios.

If you want to learn more information, please visit our official website and explore freely. You are welcome to contact us for any needs.