You only need this Advanced Guide if your video and audio lengths were different by more than about a second when you were following the Intermediate Guide. Normally when this happens it is the audio length that is shorter than the video length. If you followed that guide and played the resulting 3gp file on your P900, you might have found that the start of the movie was perfectly synchronised but that, at some point, the movie lost sync. It wasn’t a gradual loss, it just suddenly happened mid way through the movie. Make a note of the approximate time during the movie at which sync was lost.
Let’s start by looking in a bit more detail at some of the characteristics of AVI files, in particular around video/audio synchronisation. It would be helpful if you have kept your original AVI file and the one produced by VirtualDub above. Open the second AVI file in Windows Media Player, Winamp or another PC video player. Drag the slider across to scan to a position in the movie later than the time noted above. Wait until someone is speaking so you can see if the sync is there. Probably the video and audio are out of sync. Now open the original AVI file in the PC video player and scan to the same position. Probably the video and audio are in sync. Strange, eh?
What’s happening here? It turns out that many (but not all) AVI files are internally structured to keep video and audio in sync, even if the video and audio lengths are not identical. PC video players use this internal structure to maintain sync during playback, even if there is a bad section of video. However – and this is the key problem for us – AVI conversion programs such as PV Author are not always able to allow for bad sections of video which can cause video and audio lengths to differ. For PV Author to work well, the video and audio lengths have to be the same within the AVI file. We are going to resolve this problem by finding the bad section of video using VirtualDub and removing just enough of it to bring the video and audio lengths in line with each other.
Let’s check the length of the AVI file which is out of sync and compare it to the length of the WAV file. First the AVI file:
Now the WAV file:
Now the reason for the loss of sync is clear: there’s a difference of 9.88 seconds between the video and audio lengths! Note that the audio length reported by the File Information option in VirtualDub will not always show this discrepancy – that’s why we are using jWavlength.
Anyway we need to fix this problem. Let’s get started.
Step 1: Run VirtualDub. Open your new AVI file in VirtualDub. Go to Video and select Full Processing Mode. Go to Compression and select the DivX Codec as before.
Step 2: Identify the bad section of video. The task here is to find the exact position in the AVI file where we lose video/audio sync. Unfortunately this will require some trial-and-error. As above, you have already found a position in the video which is out of sync so at least we have a starting point - move the slider to that position. Now move the slider backwards through the file until you locate a point at which the video and audio are in sync. A good method is to look for a section where there are people speaking. Press the Input button I to play, then compare the video and audio. Gradually move the slider forward through the movie until you locate the bad section of video. You can normally find this through some picture degradation or abnormality. Before this section the video and audio are in sync. After this section the video and audio are out of sync.
Step 3: Delete the bad section of video. Use the frame backward and forward buttons to find the first bad video frame. Mark the current position in the file using the ‘start selection’ button. Make a note of the precise time (to the nearest thousandth of a second) of this first frame. In the example below it is 1:06:07.333.
In order to restore video/audio sync, we want to move forward in the file by the exact difference in length between the AVI file and the WAV file. Subtract the WAV length from the AVI length. The result should be in seconds (to the nearest hundredth) – in our example it is 9.88 seconds. Now use the frame advance button to move the video forward by as close as you can to this exact amount. Mark this position using the ‘end selection’ button.
As you can see, we have moved forward to a time of 1:06:17.250. We have incremented the position by 9.917 seconds – as close to 9.88 seconds as we could. Now go to the Edit tab and select Delete. The bad section that we marked is removed. In reality there may be a small number of additional bad frames but that doesn’t matter – the important thing is to restore the sync process.
Step 4: Save the new AVI file. From the File tab select Save AVI. It would be nice if this new AVI file was now in sync. Unfortunately it probably is not. We have one more, fairly quick, process to do.
Step 5: Open the new AVI file in VirtualDub. That’s right. Open the AVI file that you have just saved. This time select Direct Stream Copy mode in the Video tab.
Step 6: Open the WAV file in VirtualDub. That’s right, the same WAV file as before. This time select Direct Stream Copy mode in the Audio tab.
Step 7: Save the AVI under a new name. For the final time, specify another filename for this (third) AVI file. This file should be synchronised for video and audio.
Step 8: Run PV Author. In exactly the same way as described in the Basic Guide.
We are done. Hopefully you now have a nice new 3gp file which plays in sync. That completes the Basic, Intermediate and Advanced Guides. See the next article we'll keep for some general FAQs and anythign you want me to cover