PDA

View Full Version : Fixing audio/video sync of an AVI


the terminator
01-03-2004, 05:48 PM
In an AVI video file that I have captured, the sound is about one second ahead of the video, e.g. I hear the sound of a car door slamming about one second before it happens. The audio/video sync is fine for about the first 15 minutes, but I havent yet pinpointed the loss of sync. I really don't want to re-capture the video, because it is fine except for the audio. So, is there anyway I can restore the sync using a program like Virtual Dub or any other program? Or am I stuck having to capture all over again?

sailor
01-03-2004, 07:31 PM
Audio tends to slowly drift out of sync when you capture. It was explained to me that the Audio card is using its own clock which will inevitable be at a slightly different frequency than the video. My captures result in the same effect. I believe it can be corrected with video processing software by extracting the audio and resampling but I have not bothered to do it mainly because I need to determine if it is fast or slow and by how much.

I also would be interested in simpler solutions.

MMMason
01-03-2004, 08:21 PM
This link which i saw in www.divx.com should give you a starting point.

http://www.dvdrhelp.com/sync.htm

If you don't have those programs, there is a link near the bottom that shows more sync solutions.

squeegee
01-03-2004, 08:21 PM
The sync problem may have happened when the file was captured. OTOH, the file may be fine, the sync is drifting as it's played back.

A quick way to tell which is the case: while the file is playing back, wait for the sync loss to become noticable. When that happens, pause/stop playback, and then restart it at the same point. If the playback is still out of sync, it's probably the file. If playback of the same segment is now in sync, the player you're using is drifting sync during playback.

If it's the file: there are various tools you can use to fix the audio to again be in sync with the video -- Premiere, Sound Forge, etc -- but I'm not aware of any free ones.

the terminator
01-03-2004, 08:45 PM
I have Premiere. Do you know how to fix it with that?

Ximenean
01-03-2004, 08:58 PM
Originally posted by sailor
Audio tends to slowly drift out of sync when you capture. It was explained to me that the Audio card is using its own clock which will inevitable be at a slightly different frequency than the video. My captures result in the same effect. I believe it can be corrected with video processing software by extracting the audio and resampling but I have not bothered to do it mainly because I need to determine if it is fast or slow and by how much.

I also would be interested in simpler solutions. It's true that most audio/video sync or frame drop problems are caused by the difference between the sound card's clock (inevitably slightly inaccurate) and the implicit, extremely accurate, clock of the video signal. However, if you're not worried about adhering to the standard NTSC 29.97 fps frame rate (25 fps for European PAL), and you use a capture utility such as VirtualVCR (http://virtualvcr.sourceforge.net/) which allows you to regard the sound card's clock as the master clock, you can capture hours of video in perfect sync, without dropping a single frame. You end up with a perfect AVI file that runs at a slightly non-standard frame rate, e.g 25.002 fps for PAL video when it should be 25.000, an imperceptible difference.

squeegee
01-03-2004, 09:31 PM
Originally posted by the terminator
I have Premiere. Do you know how to fix it with that?Well, first you need to determine if you're dealing with a badly captured file, or bad playback. See my post above. If it's bad playback there's nothing to fix in the file. Try updating your audio drivers, I'm not sure what else to try.

(Question: is this file DV video? Something else?)

Next, determine if the sync loss is a slow drift or a sudden shift at some point in the file.

If it's a sudden shift, the fix is to insert silence or remove some audio to restore sync. Find the spot in the file where the audio time shift occurs, and find a sync point in the file that can be used for reference (such as that car door slamming you'd mentioned. Unlink the audio from the video (clip menu->unlink audio and video), then use the razor tool to slice out some audio or slice the track and move it to insert silence so that car-door-slam matches up with the video.

If the problem is a slow drift of sync, you need to unlink the audio from the video, then change the speed of the audio portion to match the video (clip->speed). This requires some experimentation. You can also you the time stretch tool to accompish this.

the terminator
01-03-2004, 10:15 PM
I have determined that the loss of audio sync is from a bad capture. To answer your question, it is an AVI that I captured from a VHS tape. I'm pretty sure that it is a very gradual drift of sync because the sync is worse near the end of the video than where I noticed it earlier. I'll try your suggestions for Premiere.

the terminator
01-03-2004, 10:32 PM
When I alter the speed of the audio, even by just one percentage point, it results in a drastic change in audio sync. Is there something i'm not doing right here? :confused:

squeegee
01-04-2004, 01:02 AM
No, you're on the right track. A 1% audio shift over, say, 30 minutes would shift the end of the audio clip by ~.6 seconds, which is a very noticable shift. If I'm not mistaken, the Premiere speed dialog accepts decimal entries (e.g. "100.1"), so you may need to try fractional speed changes.

sailor
01-04-2004, 09:22 AM
>> A 1% audio shift over, say, 30 minutes would shift the end of the audio clip by ~.6 seconds,

If I am not mistaken a 1% shift over 30 mins would be 0.3 mins = 18 seconds which is huge. A 1/1000 shift would be 1.8 seconds which is still huge. A 1/10,000 would be 0.18 seconds which is still quite unacceptable. A 1/100,000 would be 18 ms which is noticeable but at least you can follow what's going on. A 1/1,000,000 is the least to be considered acceptably good.

That is over 30 mins. Over 2 hrs you need an order of magnitude higher.

the terminator
01-04-2004, 10:08 AM
I tried inputting decimal values and it won't let me enter a decimal point.

the terminator
01-04-2004, 02:59 PM
Well, i've pretty much given up on fixing the file and I am just going to capture again. Does anyone have any suggestions on how to not lose audio sync, other than the suggestion involving PAL capture?

sailor
01-04-2004, 03:19 PM
I would either (a) capture video and audio separately or (b) separate them once captured and then (c) process the audio separately until it matches the video and then combine them again. This is not complicated using Gordian Knot and associated crap.

Just now I extracted the sound of an AVI to a separate file using Besweet and using COOL Edit I stretched by 1/10,000 and saved it again. No problem there. If you need an audio file stretched just email it to me and tell me by how much.

if I had a couple of nice markers at beginning and end (like clapboards) it would be a piece of cake to resync movies. The problem is that you have to keep guessing and trying. I do it with subtitles all the time and it is easier but still a hassle.

sailor
01-04-2004, 03:22 PM
if you capture again with the same system you will get the same result. Same causes leading to same effects and all that.

Just extract the audio using Besweet and we can stretch it to whatever you need.

Unless you can extract it in a different manner which will preserve the sync.

squeegee
01-04-2004, 08:44 PM
Originally posted by sailor
If I am not mistaken a 1% shift over 30 mins would be 0.3 mins = 18 seconds which is huge. A 1/1000 shift would be 1.8 seconds which is still huge. A 1/10,000 would be 0.18 seconds which is still quite unacceptable. A 1/100,000 would be 18 ms which is noticeable but at least you can follow what's going on. A 1/1,000,000 is the least to be considered acceptably good.
<bangs head on desk>Gak. Note to self: check math before posting. :smack:

Thanks sailor.

squeegee
01-04-2004, 08:46 PM
Originally posted by the terminator
I tried inputting decimal values and it won't let me enter a decimal point.Hmmm, the current version of Premiere ("Pro") let's you enter a decimal. I'll see if I can find a workaround if you tell me what version you're using.

squeegee
01-04-2004, 08:49 PM
Or what sailor said would work -- extract the audio and then stretch it using a separate audio program. Then reintegrate using that app or Premiere or whatever. It's a piece of cake if you have an obvious sync point, such as a clapboard or someone clapping, a slamming car door, whatever.