Digital Digest
  • About the Author
  • Email
  • Disclaimer
  • Essential Links
  • Essential Tools
  • Ethics, Piracy & Philosophy
    Convert DVDs with Flask Mpeg
  • Extracting the DVD
  • Using FlasK Mpeg
  • Resizing in Flask
  • Convert DVDs with Mpeg2avi
  • Extracting the DVD
  • Using Mpeg2avi
  • Resizing in Mpeg2avi
  • Advanced DVD Conversion
    Convert DVDs with DVD2AVI
    Nandub SBC Encoding
  • Using Nandub
  • Using DivX 4.0
  • Audio / Video Editing
    Advanced VirtualDub
    Digital Video Capture
  • Video Capture: Part 1
  • Special FX Tutorials
  • Morphing Buffy Style
  • Star Wars LightSaber Effects
  • The Exorcist Effect
  • Other Video Formats
    VCD & SVCD Guides
  • DVD to VCD
  • AVI to VCD
  • Multimedia Guides
  • DivX with Subtitles
  • Mutilanguage DivX
  • Multimedia DivX Pt 1
  • Multimedia DivX Pt 2
  • Appendix / Tips
  • Aspect Ratio's
  • Resizing DVD's
  • DivX Quality Guide
  • Bicubic vs Bilinear Resizing
  • Deinterlace Method Test
  • Video Comparisons
  • WM8 Quality
  • Basic DVD Structure
  • NTSC / PAL & Interlace
  • AVI 4GB Limit
  • Key Frames & Delta
  • Monitor Setup Guide
  • FAQ's
  • Questions Answered
  • Downloadable PDF Guides
  • Glossary
  • Word Definitions
  • My Guides Translated
  • Go Here
  • Fixing Audio Synchronization Problems

    There are two major problems with audio either it is stretched or displaced. This can be illustrated thusly:

    When the synch is perfect both the audio and video will match, as seen in the first image above. Video frame1 matches to Audio frame 1 as does frames 2, 3 and so on. In the second picture it shows the audio as displaced, which means that both audio and video are correct length, but either the video or audio will start at different times causing displacement. In the third sinerio we have an audio and video sequence that are different lengths because one of them has become stretched somehow.

    To fix these problems you must check out the film very carefully. If the audio is equally out of synch at the start of the movie as it is the end of the film, then you have an Audio Displacement problem (see Fixing Audio Displacement below). If the audio is very close to correct at the beginning of the movie, but is quite badly wrong at the end of the movie (or vise versa) you probably have a Stretched Video problem (see Fixing Stretched Audio below). It is possible to have both problems of course ;-P. So if you are sure you have both I suggest you fix the Audio Displacement at the very start of the film first and then fix the Stretched Video problem once you know somewhere in the film is absolutely correct!

    Before I start here are the things you will need:
    VirtualDub 1.4c
    Terabits AVI Info 1.2a also get the Source Code Here
    Cool Edit (or simular audio editing tool)




    PART 1: Fixing Stretched Audio

    Stretched audio is the most common reason a video will be out of synch with a video. Luckly the first release of the Terabit AVI Info tool is now ready :). Designed by yours truly and programmed by my own brother - all credit goes to him, though, for all his hard work. Terabits AVI Info tool is designed to make manual synching much easier and also to make easy some of those little things you'd like to do but do not know how. I will explain these other features at the end of this synching article though, so we can stay on track.

    Before we do anything I'd always recommend that you keep a back up of your original AVI file in case something goes wrong. Once installed you do not run AVI Info like most programs, it is more like an extension to Windows. Just find the AVI file you wish to synch and right-click with the mouse. Up will pop an option saying AVI Information - select that.

    Note: For Windows ME or 2000 users the right-click option currently does not work. As a temporary work around for this you can use the Launcher.exe application bundled with this download to open your AVI files.

    Alternatively, you can use this replacement clickme.reg file to try and solve this problem under Windows ME or 2000. Special thanks to Jimbo for submitting this tip.

    Then the following box will appear. It is a convenient way of finding out all those little bits of information that neither Windows Media Player nor VirtualDub are tell us about our AVI files.

    Click on the Synchronize Audio tab and we get a preview of the video we want to correct, and the important part, a control pannel designed to correct the synching.

    Examine your movie carefully using the AVI Player. Preferably very close to the end of the movie to better see how far the audio is out. And also be sure to find a section where their mouths are large enough to see clearly. Locate the frame number of a part just before they are going to speak and put it in the 'From' box below (1). Then take note of the frame number from after they stop talking and enter that into the 'To' box (1). Great, now the movie will loop between these two ponts. This make life much easier because feedback is instant and we do not need to keep opening the file, finding the right place, guessing how much it is out, changing it, and then starting all over again like we need to do with all other synching methods! Oh, by the way you have to press the apply button or it wont start looping :).

    Take note of if the audio comes before their mouths move or if it comes after their mouths move.

    1. If the audio comes after they speak we must decrease the frame rate a little!
    2. If the audio comes before they speak we must increase the frame rate a little!



    It doesn't sound logical at first, so just to clarify: to make the video longer we decrease the framerate. To make the video shorter we increase the framerate. Imagine it like this: if you had a pack of cards and threw 5 cards onto the floor every second, it would take longer for you to finish the pack of cards than it would if you were to throw 10 cards onto the floor every second. In the same way, a movie will finish earlier if it shows more frames per second. This means a higher framerate makes a shorter movie.

    Now the synching is quite straight forward. Play your movie, if the audio comes after the mouth moves hit the -0.001 button (4) once, and try the movie again. If it is not correct, press the -0.001 button again, and again, and again etc., until it is almost perfect. Then use the fine tuning arrows (2) to get the final perfect audio. Conversly, if the audio comes before the mouth moves we must use the +0.001 button in the same way as already described.

    If you want to make really huge changes you can use the slider bar (2) or the increase by a whole frame per second with the +1 and -1 Frame buttons (3). There is also the option to enter any framerate you like with the 'Enter Desired Frame Rate' option.

    But usually we will only change the framerate by avery small amount! I usually only use 0.001. So if my movie was 25.000 fps and I wanted to make it shorter I would change the framerate to 25.001. If that was too long I'd go to 25.002 then 25.003 and so on. If you want to make the movie longer I would try 24.998 then 24.997 and so on. Once it is almost perfect you can use even smaller amounts such as 0.0001. So imagine 25.007 is the almost perfect, but just needed slightly more. I would try 25.0071 or something like that. It shouldn't take long for you to become an expert.

    If you think you are totally out you can reset any section back to how it originally was by using the 'reset' button.


    To apply it or not to apply it, that is the question?

    Whether it be nobler to suffer the slings and arrows of outrageous framerates or not. If we apply it now, the movie will play correctly in Media Player and, in fact, on all PC players. But what if we were synching our AVI file not because it was a DivX movie but because we wanted to convert the AVI to Mpeg or SVCD etc? It is unlikely that the VCD we created would be in synch! This is because all VCD, SVCD and DVD files must be exactly 25 or 29.970 fps to play in a DVD player or a stand alone player! A framerate such as 25.998 will not work!

    Other synching tools offer to change the audio samplerate instead. Changing the audio samplerate may be able to put the movie in synch just as effectively as changing the framerate. But again this causes conversion problems. A VCD, DVD or SVCD will only take 44100Hz or 48000Hz respectively. Feeding an encoder 11025Hz will almost always end up with synch problems!

    For this problem Terabits AVI Info tool is the only utility so far that can offer a solution. Notice that, as you change the framerate to get the movie in synch, it offers a streach (stretch) amount (5).

    So we use the framerate controls as usual to get the movie in synch but this time wedon't save the framerate changes! Instead write down (or copy and paste) the 'streach' number exactly. Now we will use this number to stretch the audio in Cool Edit. But before we do that we must extract the audio.

    Change to the 'Utilities tab'. Select a folder to save the wave, enter a name for your extracted wave file, and hit the 'Extract Audio To Wave File' button. Alternatively you can use VirtualDub to extract the Wave, but I see no need because this is basically the same thing.

    Open the extracted wave in Cool Edit and choose Time/Pitch > Stretch...

    Paste the stretch amount into the ratio box (encircled in red). I suggest you use 'Low Precision' option unless you wish to spend many more hours stretching the audio.

    Note: The 'High Precision' uses interpolation to keep the audio higher quality, but after we have recompressed it, it will not make any audiable difference so choosing higher quality will probably just waste time.

    Cool Edit 2000 automatically converts the audio to PCM Wave for editing. So be careful because this takes over a gigabyte of space! If your are using another audio editing program then you may have to convert the wave to PCM first. Using Winamp is probably the easiest way so check out my 'Converting Audio' section for more info on this subject.


    Reintergrating the Audio

    Probably the most reliable method now is to save our newly stretched audio as PCM Wave and multiplex it back to our video file. Go to my Multiplexing section for details on this.


    PART 2: Fixing Audio Displacement

    Open your video in (you guessed it) VirtualDub. Choose a piece of the movie where people are talking. Their mouths should be clear so you can see easily when the synch is correct or not.

    Go to Audio > Interleaving

    Up pops the box below. Leave everything as it is except the 'Delay audio track by' part. Look at the movie and see if the sound comes before or after the video. If the sound becomes before they speak we will use normal numbers to slide the audio forward. If the audio comes after they speak we will use minus numbers (-) to slide the audio backwards.

    1000 represents one second of time, 500 represents half a second, 250 represents a quarter of a second etc. Lets say the sound appears just after the person speaks. To solve this we must slide the audio to the left a bit. So we can put in minus 250 (ie. -250). Press OK and play the movie in VirtualDub. Is it correct? If not, does the sound come before the person speaks or after? Lets say it is much closer but still comes after the persons mouth moves, we could try increasing the delay by putting in -300. Press OK and check the movie again. Keep doing this until the audio slides into the perfect place!

    Now lets assume the persons mouth moves and then the audio comes after they speak. We do exactly the same thing except we no longer use the minus sign (-). So we start off small with 250 and press OK to see the results. Then, if its not right, try some more like 300 then 400 or 500 etc. Usually a movie will only be out by about half a second (i.e 500), but I have sometimes found movies to go out by six seconds (i.e. 6000) or more! But usually this is becase I made a mistake in the encoding by setting the wrong samplerate or something, so its easier to grab the audio again.

    When the audio is correct save the movie by choosing:

    Video > Direct stream copy

    Audio > Direct stream copy

    File > Save Avi


    Fixing Audio Displacement and Stretching

    If you are really unlucky you will need to fix both problems! If this happens fix the audio displacement first and then the audio stretch. Just repeat steps 1 to 3 and you should be fine:

    1. Go to the very very start of the movie and find the first part where they speak. Use the displacement methods already described to get the audio starting in the correct place.

    2. Then go to the very very end of the movie and use the audio stretch fix method already described to put it back in place.

    3. Check the movie. It will probably still not be correct becase the audio stretch moved the start displacement to the wrong place again! So repeat steps 1 and 2 again :).


    PART 3: The Quick Fix Audio Synch Method

    You could also try the "quick fix method" for audio synch by opening your movie in VirtualDub and choosing Video > Framerate

    Then choose the 'change so video and audio durations match'

    This method sounds amazing but doesn't usually work =(.


    More about using the Terabit AVI Info Tool

    Finally this looks like a good place to add a few more details on the AVI Info tool we are designing. It isn't completely finished (as you probably guessed) and there are many thing on the cards for this tool. You already know how to extract a wave from an AVI with it and how to use its synching functions.

    Delay Audio

    We have put in a delay audio function (6) but it is only partially working so use it at your own risk. It can only delay the audio's start time and will not slide it to the left or right like VirtualDub. Therefore I suggest you use VirtualDub for audio displacement problems.

    Change FourCC codes

    If we go back to the 'Utilities tab' we are given the option to change the Header code of the AVI file (A). As you probably realise Windows knows what codec to decode the AVI with by its FourCC codes.

    If, for example we wanted to join a High Motion DivX movie clip with a Low Motion DivX movie clip, it would be possible to do this (provided they were the same resolution) by changing one of them to the FourCC code of the other! So a Low Motion video which has:




    Can be changed into a Fast Motion video clip by changing it to:




    Once this change has been done you should be able to join them together in VirtualDub. Check out my 'Cutting & Joining' AVI files section for details on how to do this.

    Author Details

    Since our DivX method doesn't allow us to add author details to our movies like ASF files we wanted to make a tool for doing this. This tool doesn't work yet BUT you should be able to open a previously authored movie and change it. So you could take someone elses latest ASF movies and change their author details to 'made by joe bloggs' or something crazy like that =o).

    Again this will only work with a video file that already has someone else's information in it.

    Duplication of links or content is strictly prohibited. (C) NICKY PAGE 2000