TS encapsulation and encapsulation recognition for audio and video processing 20181030

Source: Internet
Author: User

**************************************** **************************************** ********************
I. Ts Encapsulation
1. Introduction
MPEG2 transport stream (TS Stream) is a data stream defined according to the ITU-T Rec. h.222.0 | ISO/IEC 13818-1 protocol.
To transfer and store the encoding data of one or more programs in an environment where serious errors may occur. TS streams are widely used.
Storage of video and audio data, non-linear editing system for TV programs, and network.

TS packet with Pat | TS packet with PMT | TS packet with pes of I frame |
... | TS packet with pes of audio frame |... | TS packet with private data |
... | TS packet with pes of P/B frame |...

2. Glossary
TS: transport stream, the transmission stream defined in the first part of MPEG2.
VCL: Video Coding layer, video encoding layer, which is an element result level defined by H.264 and only contains encoding data.
PTS: presentation time stamp. The timestamp is displayed.
PSI; program specific information, program special information.
Pat: Program Association Table, program Association table.
PMT: Program Map Table, program ing table.

3. Introduction to ts Encapsulation
A ts stream consists of a series of TS packets with a fixed length of 188 bytes.
The TS packet starts with a four-byte prefix (TS header) with a starting code of 0x47, including a 13-bit PID, which can be obtained through the PID and the program special information table (PSI ).
Identify the content of the load in the TS package. The same PID is worth the TS packet, and its load only carries data from the same original stream.
PSI is very important information in the MPEG-2 system, it is used to describe the composition of the TS stream, has the following 4 PSI:
1) Program Association Table: Program Association Table, Pat, PID associated with the program number and program ing table
2) program ing table: Program Map Table, PMT provides ing between program numbers and the original streams that make up them.
3). Network Information table: network information table, nit
4). Conditional Access Table: Conditional Access Table, cat

4. Ts encapsulation structure
1). Composite Process
Video ES (original stream), audio es, and other data are first packaged into a PES package, that is, three PES packages are then combined into a TS stream through the TS composite.

2). TS Stream Structure
TS Stream structure, from the inside out,
The first layer is the es layer. The data in this layer is the video code stream, the audio code stream or other code streams, that is, the bare stream.
The second layer is the PES layer. Each PES packet is divided into two parts: the packet header and the load. The load is data from the es layer. A piece of data from the es layer can be packaged into multiple
PES package.
The third layer is the TS layer. The TS packet is divided into two parts: the packet header and the load. The load is the data from the PES packet.

5. Ts Header
1). TS Stream header Structure
Baotou:
8-Bit Synchronization bytes | 1-bit transmission error | 1-bit payload indication bit | 1-bit transmission priority | 13bit PID | 2-bit transmission encryption control | 2-bit adaptive field control | 4-bit Continuous Counter | adjust Field
Adjusted field:
8-bit adjust Field Length | 1-bit non-continuous indicator bit | 1-bit random access indicator bit | 1-bit original stream priority indicator bit | 5-Bit Flag bit | optional field | fill byte
Optional fields:
42bit PCR | 42bit opcr | 8-bit mosaic descending count | 8-bit private data length | private data | 8-Bit Field Length | 3-Bit Flag | optional field
Optional fields:
1bit LTW valid flag | 15bit LTW valid offset | 2bit | 22bit segmentation rate | 4bit splicing type | 33bit dts_next_ou

2) Baotou
Synchronization Byte (sync_byte): 8 bit, packet start mark, fixed to 0100 0111 (0x47)
PID: 13bit, indicating the type of data stored in the current ts package payload,
0x0000 program Association Table
0x0001 Conditional Access Table
0x0002 Transfer Stream description table
0x0003-0x000f Reserved
0x0010-0x1ffe network_pid, program_map_pid, elementary_pid, or other
0x1fff empty package


**************************************** **************************************** ********************
2. Simple encapsulation Recognition
1. Tool Recognition
Elecard, VLC, mediainfo

2. binary data analysis
1). PS Encapsulation
You can search for the SMS header (00 00 01 BC) and PSH header (00 00 01 BA) to confirm the encapsulation type.

2) RTP Encapsulation
The encapsulation type is determined by searching for the private flag 88 77 66 55.

3) hik Encapsulation
The encapsulation type is determined by searching for the private flag 01 00 00 and combining the image group mode.

4) ts Encapsulation
The encapsulation type is determined by searching the 0x47 synchronization header, Which is 188 bytes at each interval and verifying multiple synchronization headers repeatedly.

TS encapsulation and encapsulation recognition for audio and video processing 20181030

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.