[mythtv] Broken AV sync after mythtranscode
mythtv0368 at phracturedblue.com
Sat Dec 24 23:38:56 EST 2005
On 12/24/05, Tino Keitel wrote:
> I can provide the stream which has broken AV sync after
> mythtranscode, if you don't mind downloading several hundreds of MB.
> I'll send you the URL in a private mail, to ensure that only you will
> download it.
Thanks for this.
The problem is twofold:
1) there are parts of the stream where you lose a single audio or
video packet. If it is video, the code corrects, but it can't do that
for audio. If there were just a few, this wouldn't cause any issues,
but if you get too many, the delta between the PTS in the file and the
expected PTS gets too big and the 'big hammer' kicks in (see below).
The solution seems to be to just increment the expected audio PTS as
if we had inserted an audio packet (or even better, encode a real one,
though I'm not ready to do that yet), thus preventing the 'big hammer'
from ruining the A/V sync.
2) There are places in the stream where the PTS jumps by 3 seconds
(i.e. there are 3 seconds of the stream just not there). This causes
the 'big hammer' to kick in, at which point the A/V sync is out the
window. Fixing this will require some thought.
Basically, what I'm calling the 'big hammer', is some code that kicks
in when all other hope is lost. It just throws away all timestamps in
the file, and uses its internal running count. From then on, there is
no attempt to keep AV in sync anymore. This happens when the PTS
jumps by more than 20 frames at once. After that, it is unreasonable
to try to fill in the empty frames. If this only happens to the
video, but not to the audio, the stream is broken, and there's not
much we can do. The 'big hammer' is better than nothing. However, if
all streams have the same (or similar) jump at the same time, we can
just reset the offset and move on. This is what I need to code.
Unfortunately, because audio and video are processed independently, it
isn't that easy to detect this case. I'll need to think about the
best way to do it. I'll let you know after I come up with a
Thanks again for the stream. It isn't the easiest in the world for me
to work with (it is challenging to determine lip-syncing on animation
that has been dubbed over in a language I don't know), but I'm
More information about the mythtv-dev