ES, TS, and PS streams

Source: Internet
Author: User



IP datagram consists of the first part and the data. The first part of the first part is a fixed length of 20 bytes, which is required by all IP datagram. The header includes: total length, logo, MF, DF, and slice offset.
In the MPEG-2 system, the process of information combination/separation is called system re-connection/split, the standard information flow generated by the ES stream of the audio and secondary data for actual transmission is called the MPEG-2 Transfer Stream (TS: TransportStream ).
Depending on the quality of the transport media, two composite information flows are defined in the MPEG-2: transport stream (TS) and Program Stream (PS: ProgramStream)
The difference between TS stream and PS stream is that the packet structure of TS stream is fixed length, while the packet structure of PS stream is variable length.
The difference in the structure of the PS package and the TS package leads to different resistance to the transmission error code, so the application environment is also different. The TS code stream adopts a fixed-length packet structure. When the transmission error code breaks the synchronization information of a TS packet, the receiver can detect the synchronization information in the back packet at a fixed position, in this way, synchronization is resumed to avoid information loss. The length of the PS package varies. Once the synchronization information of a PS package is lost, the receiver cannot determine the synchronization location of the next package, which may lead to a loss of data and serious loss of information. Therefore, TS code streams are generally used when the channel environment is poor and the transmission error code is high. PS code streams are generally used when the channel environment is good and the transmission error code is low.
Because the TS code stream has a strong ability to resist the transmission error code, so the MPEG-2 code stream for transmission in the transmission media is basically using the packet lattice of TS code stream

In digital TV system, analog video and audio signal according to the standard of MPEG-2, after sampling, quantification and compression encoding to form the basic code stream ES, the basic code stream ES is not segmented continuous code stream. The basic code stream is segmented into segments, and the corresponding header file is packaged to form the basic code stream PES (1). the PES package and the package can be discontinuous. During transmission, the PES package is segmented into a transmission code stream TS with a fixed length of 18 8B or a Program Stream package with a variable length (PS package ). PES is only the logical structure of the MPEG-2 Data Flow interchange When PS is converted to TS or TS to PS intermediate steps or bridges. The TS and PS streams are suitable for different application scenarios. The Program Stream PS is suitable for use in environments with relatively few errors, and its length varies, the Transfer Stream TS can construct a stream of multiple programs based on one or more time identifiers. The transfer stream is suitable for scenarios with many errors. The advantage of data packet transmission is that the information in the network can occupy different connection lines and be saved temporarily. Multiple Data streams are reused into a new data stream through data packet interlace. This facilitates the decoder to flexibly sort data packets in the appropriate order, thus laying the foundation for data stream synchronization and reuse. The structure of MPEG-2 can be divided into the compression layer and system layer, ES belongs to the compression layer, PES and TS/PS belong to the system layer.
In the PES layer, PTS (display time tag) and DTS (Decoding time tag) are added to the PES header information for video and audio synchronization. In the TS stream, the TS header is added with PCR (program clock reference) for the decoder's system clock recovery. Adding SCR to the Program Stream PS header is similar to the PCR domain.
 
Elasticsearch is an encoded video or audio data stream. Each elasticsearch consists of several access units (AU). Each video AU or audio AU consists of the header and the encoded data, an AU is equivalent to a coded video image or an audio frame. It can also be said that each AU is actually a display unit of the encoded data stream, that is, sampling is equivalent to decoding a video image or an audio frame.
We know that the MPEG-2 compresses the video to produce I frame, P frame, B frame. Encode es of I1 frame-P4 frame-B2 frame-B3 frame-P7 frame-B5 frame-B6 frame, by packaging and inserting the PTS/DTS flag in each frame, it becomes PES. When the PTS/DTS flag is inserted, DTS does not need to be inserted in multiple frames of B because the PTS and DTS of B frames are equal (see figure 1 ). For I and P frames, the sequence of data packets changes after multiplexing. Therefore, the data packets must be stored in the new sort cache of the Video Decoder before display, after being sorted and displayed again, you must insert PTS and DTS at the same time as the basis for the new sorting. For example, the decoder inputs the image frame sequence as a I1-P4-B2-B3-P7-B5-B6, but when the display P4 must be after B2, B3, under the guidance of PST and DTS, after the cache from the new sort, in the sequence from creating video frames: I1-B2-B3-P4-P7-B5-B6.
When we compress PES packets into smaller ts packets with a fixed length, PCR and PID (package ID) are added to the header position ). The PID value is determined by the user. The Decoder uses the PID to distinguish the TS packages of different programs on ts (Multi-program transmission and transmission) to reconstruct the original es. In addition, the TS packet header contains a 4-bit continuous counter. The continuous counter can count the transfer sequence of the PID packet. Based on the number of reads from the counter, the receiving end can determine whether there are packet loss and packet transfer sequence errors. Therefore, TS headers have functions such as synchronization, identification, and error detection.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.