Dreamstime

Wednesday, 8 August 2012

VirtualDub Post Capturing: Keeping Audio And Video In Sync

Unless it is less than 20 minutes long, I have a problem with audio and video synchronization in all my VirtualDub TV captures. During playback, the audio and video will start out okay, but after about 20 minutes they will begin to go out of sync. It is only later that I realized that this problem is caused by the audio and video having different length in time. In my case, the length of the audio is always less than the video, causing the audio to be heard first before the corresponding event in the video.

This is what I have to do to bring audio and video back in sync. To recap, I am using the KWorld PCI Analog TV Card Lite (PVR-TV 7134SE) as my capture hardware device. My video captures are encoded into XVid, while audio is encoded into MP3.


  1. Start VirtualDub and open and load the out of sync AVI file.

    Select File -> File Information ... to display "AVI Information" dialog box.

    AVI Information


  2. Calculate the value of Video stream Length minus Audio stream Length.
    In our case (1:03:00:00 - 1:02:59:78) = 0.22 seconds = 220 ms

    Audio/Video Interleave Options

  3. Select Audio -> Interleaving ... (or Ctrl-I) to open the "Audio/Video Interleave Options" dialog box.

    Key in the value calculated in Step 2 above into the field "Delay audio track by" - 220 ms in our case.

    Select the "OK" button to set and close this dialog box.

  4. In the VirtualDub main window, select Video -> Full processing mode.

    Move the Position Slider (just below the display pane in the VirtualDub main window) to about ¾ of the AVI file - this is the best place to check for audio and video synchronization. Click on the Output Play button - the play button with the small "O".

    Watch and listen carefully to the playback. If the audio and video are in sync then goto step 5 - we have fixed the problem.

    Otherwise, reopen the "Audio/Video Interleave Options" dialog box, as in Step 3, and add an additional 10 ms to the previous value for'"Delay audio track by" and check for audio and video synchronization. Goto step 5 once audio and video are in sync. Sometimes, I have to go through a few iterations of these steps, adding up to 80 ms in total. Yes. A bit tedious.

  5. Select Video -> Direct stream copy.

    Hit the F7 funtion key to save the, now in sync, AVI file. I usually save it into a different directory but with the same file name.

Update 29 October 2013

  • These days, I hardly have to make multiple iterations in adjustments to the value of "Delay Audio Track" as described in the last paragraph of Step 4 above, thanks to a better TV reception after I made some adjustments to my antennas.

    Bad reception not only gives poor video and audio quality. It also causes higher CPU utilization which may give rise to "inserted frames" when VirtualDub cannot cope. And this in turn may cause problems later in re-syncing audio and video.

    Do not overlook the importance of getting a good TV reception. Get a booster/preamp and/or a better quality antenna if you persistently have problems in re-syncing.
  • I find that audio and video re-sync becomes trickier if I were to do some disk intensive tasks like launching a program or copying a big file to another device while capturing. Sometimes, I thought I have successfully resynced a captured file. But upon playback, certain parts may appear to be in sync, while other parts may appear to be not. To be safe, don't do anything while recording is in progress.
  • At one time, I combined various types of antenna thinking that they would boost TV reception. A very bad idea indeed. In one particular capture, audio and video were offset at different rates at different parts of the file making re-sync almost impossible. In the end, I had to chop the file up into 30 minute chucks and re-sync the chunks individually.
  • I have Avira Antivirus Real-Time Protection enabled all the time - i.e. the umbrella icon is always opened on the Windows Taskbar. It does not cause any syncing problems in my captures.




0 comments:

Post a Comment