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

Mike Versteeg mike at mikeversteeg.com
Thu Dec 13 19:41:17 CET 2012


> I assume that you notice the drift during playback.
> Many player are using different approaches in how to sync
> the two streams (AV). You might encounter different results
> with different players.
>
> One way is to stuff the continuous audio stream in the audio channel
> and then sync in the video frames. Playing back the audio, you have to
> take two clocks into account and compensate for it. The clock of the
> recorder and the playback host will slightly different.
>
> A simple way on the recorder site is to stuff an additional frame
> or toss one. You could soft 'calibrate' it against the real time clock.
> This might ease the AV sync on the playback site. But nevertheless
> playback needs to compensate on its own in similar fashion.

Thanks. But as I mentioned both sources have their own clock and
doubling or omitting frames is unacceptable in the world of
broadcasting. The problem is also not at playback but at recording, as
one can easily detect in the changing size of the audio buffer. I can
overcome this by changing the sample rate of the audio slightly so the
buffer's size will remain constant, but figured there would be an
easier way by modulating the PTS appropriately. At least I figured
that's what it's for. The question here is how to change it in this
particular case.


More information about the Libav-user mailing list