[mythtv] Transcoding AC3/5ch and video sync

Jesse Crews jcrews at gridlox.net
Sun Sep 17 04:37:49 UTC 2006


Hi,

I've been working on an AC3/5ch -> stereo transcoding issue on and off  
for a while, and I'm trying to find some advice on where to focus my  
efforts.

Here's what's happening:
I transcode an ATSC recording with AC3/5ch audio to MPEG4, mp3 2ch.  
The resulting file has video that is about 300ms early, or, audio that  
is 300ms late, whichever way you like to look at it. This offset is  
constant, and only happens when a recording with 5 channels is  
transcoded. AC3/2ch does not create this effect at all. This may be  
difficult to notice at first, but I see it easily and it is distracting.

I'm not at all familiar with a/v processing, and I'm trying to  
understand how audio and video are kept in sync while transcoding.  
Looking at -v all output, it's a bit of a pain figuring out exactly  
what's going on here.

This is what I think is going on:
The process of downmixing AC3/5ch to 2 channels is causing the audio  
timecodes to become wrong by about 300ms. Just converting 2 channel  
AC3 (no downmix) doesn't create the delay.

I'd like to develop a fix for this, but the trouble I'm having is  
finding the source of the discontinuity. What I need to know is how  
exactly audio and video are kept in sync while transcoding, and, where  
this is happening (I think I'm on the right track looking at  
avformatdecoder.cpp).

Also, a great help would be if anyone at all knows why (specifically)  
the downmixing process would add 300ms to the audio's timecode.  
Pinpointing the responsible code or pattern would help immensely.

Other than fixing the downmix, a workaround could just be to do a  
direct audio copy from ATSC -> mpeg4, removing what I suspect is  
causing the delay, and improving sound quality for passthru users  
(this would of course be optional).

Thanks for any help.



More information about the mythtv-dev mailing list