View Full Version : Audio drift
Recon
4th August 2005, 16:36
I've had a few movies do this rarely, but its usually not an issue.
When it does happen I have NO idea how to solve it, I thought maybe someone here might know..
In the beginning of the encoded movie, the audio is perfect, but by sometime in the middle, the audio has drifted to the point where it is noticable that the characters in the movie aren't in lip-sync with what they are saying. By the end of the movie, it could be as much as a half second off.
Anyone know what causes this or if there's a way to correct it?
mimungr
4th August 2005, 20:49
This isn't related to DivX, so there's probably a better forum for this question.
I assume that the audio is in sync on the original DVD.
DVDs can have audio discontinuities at the ends of cells. DVD players (software and hardware) handle this properly. I've never seen a demuxing/encoding app that does. Instead, they treat the demuxed AC3 frames as a single continuous stream.
You can use DVD Decrypter to split the ripped VOB files on cell boundaries, run DGIndex separately over each continuous region of cells, and do an aligned splice in Avisynth using the various delays reported by DGIndex.
Recon
5th August 2005, 04:41
Yeah I figured it wouldn't really belong in this forum except it is about MPEG4 encoding, but it doesn't really fit in any of the other forums either.
I'll play around some more with the tools I've got (vStrip may do it) but the suggestion you gave sounds over my head. For starters, how does DVD Decrypter split the ripped VOB files on cell boundaries? All I can get DVD Decrypter to read is the DVD drive. It won't even attempt to open a file that's on the hard drive.
Ok, vStrip was able to split the movie into individual cells.
DGIndex can load these cells as segments of several cells at a time, but I don't see how it reports delays like you are saying. Also, how do I use avisynth to perform an "aligned splice" using delays?
mimungr
5th August 2005, 06:17
In DVD Decrypter, go to Tools\Settings ...\IFO Mode and set File Splitting to By Cell ID.
After you've ripped the disc, open the IFO file in IFO edit. It will show you which cells have the discontinuity (DISC) flag set.
Then run DGIndex over each continuous region. For example, suppose Cell 14 has the DISC flag set. Run DGIndex over Cells 1-13 and Cells 14-End.
DGIndex will encode the delay in each AC3 file name. For example,
test T01 2_0ch 192Kbps DELAY 15ms.ac3
Now, you'll join all these rips using AlignedSplice in AVISynth. In my case, I always convert the AC3 to 2-channel mp3, so I first decode the AC3 streams to WAV and then do something like this:
v1 = mpeg2source(seg1.d2v)
a1 = wavsource(seg1.wav).DelayAudio(0.023)
c1 = AudioDub(v1,a1)
v2 = mpeg2source(seg2.d2v)
a2 = wavsource(seg2.wav).DelayAudio(0.156)
c2 = AudioDub(v2,a2)
return AlignedSplice(c1,c2)
where the audio delays are the delays reported by DGIndex. Note that DelayAudio expects seconds, while DGIndex reports milliseconds.
Yes, this is a bit of a pain. But the A/V sync will be perfect, and as you noted, you don't come across this often. And I have a script that automates much of this.
Recon
5th August 2005, 16:02
Wow thanks! That's great.
One more question: When this AviSynth text file is created, how do you "run" it? (I've never used AviSynth)
And is that the last step? Its you run it somehow and it outputs the finalized video? What about the encoding?
At some point you gotta run GKnot or avi.NET or something right?
mimungr
5th August 2005, 17:50
Many (most?) encoding applications accept AVS scripts as input.
GK does, but it expects the audio in a separate file. Open the AVS file in VirtualDubMod, and select Streams\Stream List\Save WAV.
At this point, you could encode the AVS file directly in GK. Alternatively, since you've extracted the synchronized audio, you can throw out the AVS script and encode the movie normally in GK (i.e., rerun DGIndex over all the cells to produce a single d2v file) -- just use the synchronized WAV instead of the AC3. And make sure you set the delay to zero since you've already corrected for it.
Recon
6th August 2005, 07:13
Ok I downloaded IFO Edit and ran it with the movie's IFO.
There were 2 angles so many of the "yes" cells for the DISC flag were missing from my rip, since I picked Angle 1.
Then, I used DGIndex to process each batch that ended in a DISC=Yes cell, and the AC3 files did indeed show the delay in ms in the filename.
Then, I used DGIndex again to process each batch, but this time output as WAV instead of AC3, and renamed all the wav files things like 1.wav 2.wav etc
Then I typed up the script just as you suggested, but VirtualDubMod didn't like it, saying that it was expecting , or ) in line 1 or something like that.
Putting quotes around the names fixed that but now I have an error that says:
Avisynth open failure:
Script error: there is no function named "mpeg2source"
in line 1.
My entire script looks like this:
v1 = mpeg2source("1.d2v")
a1 = wavsource("1.wav").DelayAudio("0.000")
c1 = AudioDub(v1,a1)
v2 = mpeg2source("2.d2v")
a2 = wavsource("2.wav").DelayAudio("0.196")
c2 = AudioDub(v2,a2)
v3 = mpeg2source("3.d2v")
a3 = wavsource("3.wav").DelayAudio("0.091")
c3 = AudioDub(v3,a3)
v4 = mpeg2source("4.d2v")
a4 = wavsource("4.wav").DelayAudio("0.065")
c4 = AudioDub(v4,a4)
v5 = mpeg2source("5.d2v")
a5 = wavsource("5.wav").DelayAudio("0.058")
c5 = AudioDub(v5,a5)
v6 = mpeg2source("6.d2v")
a6 = wavsource("6.wav").DelayAudio("0.061")
c6 = AudioDub(v6,a6)
v7 = mpeg2source("7.d2v")
a7 = wavsource("7.wav").DelayAudio("0.047")
c7 = AudioDub(v7,a7)
v8 = mpeg2source("8.d2v")
a8 = wavsource("8.wav").DelayAudio("0.022")
c8 = AudioDub(v8,a8)
v9 = mpeg2source("9.d2v")
a9 = wavsource("9.wav").DelayAudio("0.078")
c9 = AudioDub(v9,a9)
v10 = mpeg2source("10.d2v")
a10 = wavsource("10.wav").DelayAudio("0.059")
c10 = AudioDub(v10,a10)
v11 = mpeg2source("11.d2v")
a11 = wavsource("11.wav").DelayAudio("0.021")
c11 = AudioDub(v11,a11)
v12 = mpeg2source("12.d2v")
a12 = wavsource("12.wav").DelayAudio("0.080")
c12 = AudioDub(v12,a12)
v13 = mpeg2source("13.d2v")
a13 = wavsource("13.wav").DelayAudio("0.193")
c13 = AudioDub(v13,a13)
return AlignedSplice(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13)
Any ideas? Or did I completely screw it up?
mimungr
6th August 2005, 14:57
You're missing:
LoadPlugin("DGDecode.dll")
And you may need to replace all these filenames with fully-qualified paths. The snippet above was intended more as an illustration, than a working script. If you haven't used AVS before, you may want to check the docs on their website or look at some of the scripts generated by GK for a working example.
Also, the reason DGIndex doesn't include the delay in the WAV file name is because it has already corrected for the delay. Thus, you can remove all the DelayAudio calls from your script.
I use azid to decode the AC3 -- in which case, you do need DelayAudio. neuron2 has recommended that people not use DGIndex to decode AC3, but I don't know why. If nothing else, azid gives you a lot more options. In any case, what you've done so far should be fine, so I just mention this for future reference.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.