Audio/Video Synchronization-Timestamp
When media content is being played, the biggest headache is that audio and video are not synchronized. Technically, the best solution to the problem of audio/video synchronization is the timestamp: first, select a reference clock (refer to
Time is linearly increasing). Each data block is timestamp (generally including the start time and End Time) based on the time on the reference clock when data streams are generated. during playback, the timestamp used to read data blocks.
The start time of the data block is later than the start time of the current reference clock, until the reference clock reaches the start time of the data block. For example
If the start time of the data block is less than the time on the current reference clock, play the data block as soon as possible or simply discard the data so that the playback progress can catch up with the reference clock ).
It can be seen that there are two key points to avoid audio/video non-synchronization: one is to add the correct timestamp when generating the data stream. If there is a problem with the timestamp played on the data block, how can I adjust it during playback?
Nothing to do. For example, if the video stream content starts from 0 s and someone starts to speak at 10 s, the audio stream must start at 10 s, if the timestamp starts from 0 s or other times,
The mixed audio and video streams have a problem in time synchronization. When the time stamp is set, both the video stream and the audio stream refer to the time of the reference clock, and there is no reference relationship between the data streams. That is to say, the video
Streams and audio streams are synchronized through a neutral third party (that is, the reference clock. The second key is to control the data stream based on the timestamp during playback, that is, to control the data block early to late.
To adopt different processing methods. In Figure 2.8, when the video stream content is played within 0-10 s, even if the audio stream data block is received, it cannot be played immediately, but it must wait until the time of the reference clock reaches
It takes 10 seconds to complete. Otherwise, audio and video synchronization may occur.
In the timestamp-based playback process, it is sometimes not enough to wait for or quickly process data blocks that arrive early or arrive late. If you want to adjust the playback performance more actively and effectively, you need to introduce
Feedback mechanism, that is, to feed back the current data stream speed to the "Source", so that the source can slow down or speed up the data stream. Readers familiar with DirectShow must know that
Quality control is such a feedback mechanism. DirectShow provides excellent solutions for audio/video synchronization. However, the wmf sdk only reads the ASF data stream and
Decoding is not responsible for the final presentation of audio and video content, so it lacks such a feedback mechanism.
In order to better understand the time stamp-Based Audio/Video Synchronization solution, the following is an example in our daily life. Suppose you have made an appointment with a friend of yours to meet at Shanghai square at today, eat together, and then fight again.
Game. In fact, this is a time point for you and your friends to stay in sync. As a result, you will arrive at Shanghai Plaza at, so you must wait for your friends. After 10 minutes, your friend has not arrived.
He called and said there was a delay and it was only a little late. You can't help it, because you have already booked a location in the restaurant next to you. If you don't rush in, the reservation will be canceled, so you tell your friends to go directly.
Come to the restaurant and ask him to speed up. So at a certain time point in the restaurant, it will become another synchronization point between you and your friends. Although the specific time is not certain (depending on the speed of your friend's arrival ),
Yes, you and your friends will certainly be able to meet at the restaurant. What are the results? Your friend finally arrived at, and you finally "synchronized. After dinner, at, you have to deal with the problem temporarily.
My friend made an appointment to meet at a nearby game room. You are not synchronized, but you will synchronize again at a certain time point in the game room.
Why? In fact, synchronization is a dynamic process, a process of waiting and catching up with others. Synchronization is only temporary, but not synchronous. People are always on the horizontal line of Synchronization
Oscillating fluctuation, but will not deviate too far from this baseline.
Author: happydeer Source: csdn Date: 2006-3-2 3:26:58
From: http://www.window07.com/dev/code/vc/2006-3-2/k56287.htm