TS Stream Parsing

Source: Internet
Author: User

The TS Stream parsing steps can be split into the following parts:

Step 1. Get the TS Stream file package Length

TS Stream files are generally classified into SD and HD files, which are composed of Fixed Packages. Each packet header is 0x47 and packetlength = 188byte and 204 byte. Therefore, the first step to parse the TS Stream file is to clear the package length.

The package release length can be implemented through functions such as fopen, fgetc, and fseek in C language. However, it is recommended that the open mode be in binary mode. Otherwise, garbled characters may occur when the file pointer is printed during debugging.

Idea: open the file to read one byte for judgment, and ensure that the judgment is correct through ten jump cycles. If the judgment fails once, the first time the file pointer is started, the first digit is moved to repeat the forward operation.

This phase is relatively simple and will not be described in detail.

Step 2. obtain all the packages of the specified PID

After obtaining the correct length of the data packet and the starting position of the data packet, the user passes in a specified PID,ProgramAnalyze all the packet header information, and save the package with the same PID and specified value as a file. For details, see page 42nd of iso-138181.pdf.

In this step, you must first know the structure of a TS package:

The 188byte Structure describes in detail what each digit represents. For more information, see the figure.

(To be continued ...)

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.