MPEG Transport Stream Introduction

Intraway Symphonica: Accelerating new service launches with cloud-native automation

In this post, I’ll try to give a brief introduction to the MPEG TS, which is a standard currently used as the data link layer in most of the digital terrestrial television broadcast systems, centered in the behavior of the TS packet data.

Considering that the design relies on some fundamental concepts of broadcasting, I’ll give a brief introduction before starting with the introduction about the standard.

 

Broadcast and the need for service

Most of the broadcast networks work as what we can call a one-way network system (a broadcast network). This design is implemented on this way not because it is impossible to have a return channel from any device of the network, but because it would be quite expensive for the final user to afford the device that would be able to have features. Since the beginning, all the broadcasting services are like a consumer-producer problem, so we can accept as a fact that there is no such a need for a return channel. This design is what makes the data transmission over a mass communication network cheaper (the transmission antenna is much more complex than the design of the needed reception antenna, which is a key factor that allows to any mass communication network achieve the mass concept).

So then, we face a design on which we must transmit services (e.g. TV channels) for a very big audience. As you may know, the old analogue system used to be broadcasted using a certain bandwidth of the RF band. Each division of the band was called channel. So, in the analogue TV, we used to have only one TV channel inside of one channel frequency.

With the advancement of the digital transmission, we stopped using the concept of analogue data and started to use the concept of bit transmission. This means that what it used to be a channel frequency that transmitted video and sound signals, now it is a channel that has a bandwidth for binary data transmission (note that all the transmissions must be understood as a serial transmission). The existence of a bit as a data unit give the flexibility to transmit many types of files, which implies that now there is no such a design limit that only allows one channel, one sound, etc. Now, a channel is a bunch of bytes that the broadcaster can distribute to transmit many types of data to the consumers. However, how can we be able to send all this data without mixing each? The answer is called Time-Multiplexing and MPEG TS has been designed to allow such transmission method.

 

What is MPEG TS?

MPEG TS defines the Data Link layer and, also, the layers of the service information data (in an OSI model point of view, I would like to say that MPEG TS covers from the Data link to the transport layers). All the data transmission is done using a fixed size packet known as “TS packets”. The TS Packets are the base bricks on which all the data of a channel is transmitted and, also, it is the one that allows the time-multiplexing being capable of doing the transmission.

The TS packet structure can be summarized in this picture:

 

Any transmission in a channel is done sending one after other TS packet (the minimum data transmission unit is 184 bytes. Have you ever heard about the Planck constant?). As it was shown in the previous picture, there are two parts in the packet:

  • Header
  • Payload

The Payload is just plain binary data for the upper layers, layers that do not belong to the topic of this post.

The 4 bytes of the header has several sections:

 

Name

Length (bits)

Description

Sync byte

8

Constant value (0x47) used to detect the start of a TS packet.

Transport Error Indicator (TEI)

1

It informs that the current packet must be ignored because it has bit with errors.

Payload Unit Start Indicator

1

It is used to specify which kind of information is present on the payload (out of our scope!)

Transport Priority

1

It gives high priority to this packet over other packet of the same PID

PID

13

Packet ID. This is the essence for the multiplexing capabilities of the MPEG TS. In the next section, I’ll explain this.

Scrambling control

2

Not much to say

Adaptation field exist

1

It informs if there is extra header bits

Contains payload

1

As far I know, this bit is used with some special kind of packets (null packets and PCR packets)

Continuity counter

4

The other part of the essence of the multiplexing. This counter is used by the upper layer (i.e. any protocol in the payload) to know when there was a data loss.

 

From this table, the most important fields are the PID and the Continuity counter. I’ll try to give an overview of the use of them in the next section.

 

Multiplexing data

In the beginning of this post, I mentioned that one of the key features of the MPEG TS is the ability to multiplex data. But how is this magic achieved? Well, all is related to PID.

The PID value is a key that is used as the identifier of the type of data that is travelling through the stream. This means that I can choose a PID to identify a video signal, other PID to identify the sound of this video and, finally, a third PID that relates video and sound (a.k.a. “Program Map Table” or “PMT”). With all this data, the receiver can actually show the video and related sound if it knows how to detect the PMT packets. But, is this all? Of course not! On the same way, I can create many pairs of video & sound packets with their PMT and send all them throw the same channel, so I this give us the ability to multiplex multiple TV-channels using one data channel! (Of course, the receiver will need a fourth kind of packet to know which are all the programs in the streaming – a.k.a. Program Association Table).

The next diagram summarizes the idea of program multiplexing:

 

In the diagram above, we have three TV-channels transmitted throw one stream. All the shown tables are, more or less, the data groups which are related. Note that for this example, if the receiver wants to know all the programs of a channel, it only has to read the PAT (which, in this example, is carried inside of one packet, but don’t believe that this is always done on this way). So, the receiver knows all the programs one has and, if the receiver wants to tune one program, one only has to read the PMT packet and start filtering all the video and sound one needs, discarding the video and sound of the not tuned channels. In conclusion, the PID allows to multiplex data and, also, gives to the receiver the mechanism to filter the data which must be use!

Now, the MPTS packets only carries 184 bytes of payload data. Any person that has ever used a video or sound file knows that this amount of data is quite small to carry any useful amount of video/sound data. So, the transport layer is responsible for carrying this information (a layer upward the MPTS), but still we must have a way to know how to reassemble the data of the payload and, most importantly, to know how to detect when a payload of data is lost (we should be able to detect when a data packet has been lost!). The mechanism to detect this data loss is given by the continuity counter.

The continuity counter (CC) is a counter from 0 to 15 related to the PID (the CC only applies for the PID on which it is being sent). It increments by one every time a packet of its related PID is sent through the stream. With this approach, the packet loss detection is implemented by analyzing a loss of sequence in the received packets. So, if a sequence is lost, the TS layer can inform to its upper layer that it has lost a part of all the transmitted data, letting the upper layer choose the action to do (in most of the case, the action is the discard of the affected information).

The next sequence shows an example of data loss by sequence corruption (In the example, we suppose that 4 video TS packets represent one video frame and if a frame is lost, the decoder puts a no signal! frame). Note that the CC is cyclic.

 

I wish that this post has been useful to improve or give you an introduction to MPEG TS. If you need more information, you can look it up on the Internet! Please, share your comments and opinions with us!

You may also like

No results found.

Menu