Fixing audio sync with MPEG2 captures

thier wrote on 3/11/2004, 6:08 PM
Many of us have had the unfortunate experience of trying to use the MPEG2 files produced by our A/V capture devices' built-in capabilities only to find that both Vegas and DVD-Arch are unable to keep the audio synced with the video when rendering or creating DVDs.

In my case, I am using an ATI All-In-Wonder 128 Pro which captures excellent looking and sounding MPEG2 files. I'm capturing at 6 mbps variable bitrate, with CD-quality audio; this uses only about 2 to 3 GB for a typical captured movie.

When I try to burn the movie to DVD with DVD-Arch, the audio is out of sync with the video even though they are perfectly in-sync when I view the MPEG2 itself. The loss of sync is about 1 second after 2 hours of recorded material. In my case, the audio is "ahead" of the video, so I hear a sound before I see it in the video. The loss of sync occurs gradually and linearly throughout the material; i.e., from perfectly in-sync at the start, to 1/2 second after 1 hour, to 1 second after 2 hours.

Sony has refused to fix this defect in their software, even though they've acknowledged that it's caused by their software's inability to deal correctly with the perfectly valid MPEG2 format that is created by my ATI card's hardware and underlying Ligos encoder.

So, I've come up with the following interim "fix" (ok, it's really just a workaround) until Sony gets their act together:

1. Capture the material with ATI card to MPEG2 (.mp2) file.

2. Open the .mp2 in Vegas.

3. Trim off ONLY the end of the audio track as needed; do not trim anything at the start of either the video or audio tracks; if necessary, apply fade (or split with -inf gain) at the start of audio track to work around some of DVD-Architect's In/Out quirks with MPEG2 files.

4. Render the entire audio track to a .wav file using the Microsoft 48 kHz 16-bit 192 kbps template provided with Vegas.

5. Insert the newly-created .wav file into a second audio track in the open project.

6. Go to the end of the audio tracks, expand the horizontal view, and use the "stretch audio" (Ctrl+mouse drag) feature on the .wav track so that the peaks at the end of the original audio track line up with the corresponding peaks of the .wav audio track.
BE SURE that the "Change length, Preserve pitch" option is in-effect to avoid distorting the final audio.

7. MUTE the original audio track and render the entire .wav audio track to a .ac3 file using the "Dolby Digital AC-3" template provided with Vegas.

8. You're now done with Vegas; save the project in case you need to tweak the audio in/out fades.

9. Start a new DVD-Arch project and import the .mp2 movie. Select the movie object and replace the original audio (from the captured .mp2) with the just-created (and time-stretched) .ac3 file.

The audio and video will now be in perfect sync throughout the movie; add chapter points, set In/Out points, or manipulate it in any other desired way in DVD-Arch.

Notice that throughout the above, the original video track was never recompressed; DVD-Arch reencodes/muxes the .mp2 and .ac3 files, but this does not alter the quality of the video as long as you don't change any of the default "Optimize" settings during the DVD-Arch Prepare step.

Using the above technique, I can easily get 2 - 3 hours of high-quality MPEG2, AC3 material on a single DVD.

While at first this might seem to be a lot of work, it actually adds only about 20 minutes to the total time needed to create a file ready for DVD-Arch work -- that's just the time to render the .wav file plus the time to render the .ac3 file.

Sony's advice (mantra) for dealing with this audio sync problem is "We recommend capturing to DV AVI".

Well, for a 2-hour movie, my approach uses 2-3 GB of disk space and 20 minutes. Sony's approach uses about 30GB of disk space, and at least 3 to 5 hours of extra processing time to render from .avi to MPEG2 on a 3 gHz CPU.

One final, added, benefit to my approach is that I can archive my original, captured, MPEG2 file on a single DVD in case I want to use it for something else later -- try doing that with a 30GB .avi file!

Comments

Rogueone wrote on 3/12/2004, 7:37 AM
Thanks for sharing that!! I myself originally started with MPEG-2 files, and had a major 2-week headache of trying to figure out why my audio wouldn't match!! I finally had to go the 'DV AVI' route to solve it. Your solution raises one question for me though:

What if you wanted to edit the MPEG-2 file? Say I captured a 2 hour segment of material that needed editing. For instance, I usually record plays, so I have about 3 different camera angles which I blend together, so that you've always got a different shot throughout. Could I record the files as MPEG2, do your audio blend trick, and still be able to crossfade/switch to another camera angle, without losing audio sync? And would it also decrease the amount of time that I could put on a DVD?

Cheers,
Rogue One
thier wrote on 3/16/2004, 8:52 AM
As long as you create a time-stretched .wav audio track for each of your video tracks, mute the original audio track, and then group each .wav track with its video, you should be able to manipulate them at will.

Because you will be rendering both the audio and video to get all of the effects that you want, you will be losing some quality in the video -- that's unavoidable when you re-compress an already compressed source. It's up to you to decide if the change in quality is acceptable for your needs. If the quality is not ok, you'll have to stick with AVI for your source.

The amount of time you get on a DVD will depend entirely on the parameters you choose for the final rendering. Start with a default MPEG2 template and create your own custom version of it with reduced video bitrates.
The lower the peak and average bitrates, the more time you will get on a disc; i.e., you have to trade off quality vs longer recording times. Again, you'll have to test the results to see if they're acceptable.

You'll have to render the final video and audio tracks separately from Vegas and then bring them into DVD-Arch as I described.

No matter what, using AC-3 instead of PCM will give you a lot more time on disc -- this is one of the best features of DVD-Arch, IMHO.