Mpeg2-ts audio and Video synchronization principle

Source: Internet
Author: User
First, Introduction
The MPEG2 system is used for AV synchronization and time labels for system clock recovery in the 3 levels of es,pes and TS respectively.
On the TS layer, the TS header information contains the program Clock Reference PCR (Programme clock Reference),
It is used to recover the system timing clock STC, which is consistent with the encoder end.
In the PES layer, the PES header information contains a timestamp of PTS (Presentation time Stamp) and
Decode Timestamp DTS (decoding time Stamp);
In the ES layer, the main synchronization-related is video buffer verification VBV (Verifier),
To prevent the buffer of the decoder from overflowing or underflow;

Standard Rules in the original audio and video streams,
The interval of PTS cannot exceed 0.7s,
The PCR interval that appears in the TS header cannot exceed 0.1s.




Fig. 1 schematic diagram from ES to PES

MPEG-2 the compression of the video to produce I-frame, p-frame, B-frame.
The ES frame represented by the frame order "I1-p4-b2-b3-p7-b5-b6" shown in the figure above,
PES is composed by packaging and inserting the PTS/DTS flag in each frame.

When inserting the PTS/DTS flag,
For B-frames, it is not necessary to insert DTS in B-frames because PTS and DTS are equal in B-frames (see Figure 1).
For I-frames and P-frames, the order of the packets changes after being reused,
The display must be stored in the video decoder's sort buffer, and then displayed after a new sort.
So be sure to insert both PTS and DTS as the basis for the new sort.

Second, the synchronization mechanism
Encoder
System clock STC:
There is a system clock in the encoder (the frequency is 27MHz),
This clock is used to produce a timestamp for the correct display and decoding of the audio and video.
It can also be used to indicate the instantaneous value of the system clock itself during the sampling process.

PCR (Program Clock Reference):
The time label that indicates the instantaneous value of the system clock itself is called the Program Reference Clock label (PCR).

The PCR insertion must be at the end of the PCR field at the time of the last departure of the multiplexer,
At the same time, the sampling instantaneous value of the 27MHZ system clock is inserted into the corresponding PCR domain as a PCR field.
It is placed in the adaptive zone of the TS header for transmission.

The 27MHZ system clock STC is divided into two ways by waveform finishing:
Pcr_ext (9bits), generated by the 27MHz pulse directly trigger the counter to generate the extended domain.
Pcr_base (33bits), the 300 divider divides into 90kHz pulses into a 33-bit counter to generate a 90kHz base value,
Used to compare with Pts/dts to generate the required synchronization signals for decoding and display.
These two parts are placed into the PCR domain, which together form a 42-bit PCR.

Table 2-2 Transport Packet of the recommendation| International Standard
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ============================================================================== syntax No.of bits mnemonic ============================================================================== transport_pack ET () {sync_byte ...

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.