[Libav-user] How to perform drift compensation in MPEG-2 recorder

RJV Bertin rjvbertin at gmail.com
Wed Dec 19 15:26:25 CET 2012



On 19 Dec 2012, at 14:07, Mike Versteeg <mike at mikeversteeg.com> wrote:

> Found another thread with similar question:
> http://libav-users.943685.n4.nabble.com/Libav-user-PTS-values-and-writing-encoded-audio-and-video-frames-td4551001.html
> 
> Again, not answered.
> 
> I do not think no one has ever considered video and audio clocks can
> slightly drift away from each other, so the lack of feedback is likely
> because the questions are wrong. I am therefore trying to rephrase my,
> and all these similar questions, as follows..
> 
> Using the sample code referred to, there is a direct connection
> between a video frame (lasting 1/fps) and an audio frame (fixed length
> lasting length/samplerate). This works fine as long as the audio and
> video clock are in perfect sync. However when has only the smallest
> difference from the other, after a while (could be hours) an error
> accumulates resulting in a slight AV sync problem. Obviously this
> problem can be fixed by monitoring this difference and resampling the
> audio data, but it uses resources. Changing the audio packet size
> dynamically seems a solution, but it does not seem possible. Is there
> another way, like "modulating" some time stamp and if so, how?
> 
> Mike
> _______________________________________________
> 

Maybe you should ask which clock is the most precise, and use that one as your master clock? If that's not possible you won't have many other options if everything has to be done on realtime; adapting frame display times as soon as you detect the need will be much easier than modifying sound chunks, I think.


More information about the Libav-user mailing list