A simple timestamp synchronization algorithm for better understanding of Audio and Video Synchronization concepts:
Blog Source:Stone_kingnet Column
In the sender:
The same timestamp (system time) is used for audio/video frames at the same time point)
Receiver:
Stores two queues. Audio and Video are used to store the audio and video that have not been played.
1. When an audio frame is received, traverse the video queue and compare the time stamp of the audio frame with the time stamp of each video frame:
1) if the audio Frame Time is before the video frame, the frame plays the audio
2) If the time stamp difference between the audio and the video is within an acceptable error, the audio/video will be played simultaneously (and the video frame will be deleted from the video Queue)
3) if the video time is earlier, play the video frame (and delete the video frame from the video Queue)
If the time of the last frame in the video queue is before this audio frame, the video queue will be empty after the frames in the entire video queue are played, put the audio into the audio queue.
2. Similar processing is also performed when a video frame is received.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/stone_kingnet/archive/2008/10/20/3111341.aspx
Http://blog.sina.com.cn/s/blog_672c5a470100pznm.html
Multimedia Development-a simple audio/video synchronization algorithm