How to Fix A/V Synchronization problems in MPG files
Unfortunately not all conversions go 100% smoothly and some result in the Audio and Video out of synchronization. This can be due to many reasons with the primary problems being the original movie source and software/codec clashes. More importantly, how can they be overcome or fixed. If you are consistently getting A/V sync problems, I would suggest looking at using an alternative procedure and/or software for conversion. Software and Codec clashes are common causes for these problems. There are main ways the Audio and Video can be out of sync. 1. The Audio can be in front or trail the video by the same amount from the start of the movie to the end. 2. The Audio can be in sync at the start of the movie but progressively gets further in front or trails the Video as the movie is played. The first problem here is the most common and also the easiest to fix. The second problem is normally associated with DivX conversions and can be somewhat time consuming to fix. Some conversions can have both problems! Here are the solutions I have found to fix the problems that work 100% every time for me and the software that's needed. It also assumes that the MPG file your trying to fix is a proper MPEG1 or MPEG2 file and not an AVSEQ0x.DAT or AVSEQ0x.MPG on a VCD or SVCD disk. These need to be converted to a proper MPG file first, I recommend using Isobuster for this. 1. TMPGEnc Plus 2.521 or later ( d/l from http://www.tmpgenc.net ) 2. Wombles MPEG2VCR 3.14 or later ( d/l demo from http://www.womble.com ) 3. Isobuster 1.5 or later ( d/l from http://www.isobuster.com ) 4. Goldwave 5.04 or later ( d/l demo from http://www.goldwave.com ) 5. AC3 Delay Corrector 2.1 or later ( d/l from www.doom9.net download section) [b]Audio is out by a constant amount throughout the movie.[/b]
This works for both VCD’s and SVCD’s. The basic principle is to De-multiplex the MPG file and Re-multiplex with MPEG2VCR applying an audio offset. If its an AC3 file thats out of sync, use AC3 Delay Corrector to chop off or add in some blank audio depending if its advanced or retarded.
Run TMPGEnc, click on File and select MPEG Tools. Select Simple De-multiplex tab and for Input, browse to your problem MPG. Video and Audio output names will be automatically generated. The Audio being *.MP2 and video being *.M1V or *.M2V. Click Run and wait until its finished. Exit TMPGEnc.
Run MPEG2VCR and under Tools, select MPEG System Multiplexor. Browse for the Video .M1V/.M2V file after changing Files Type to All(.). Do the same for the Audio *.MP2 file. Now select MPEG-1 System Stream VCD or MPEG-2 Program Stream SVCD depending if its a VCD or SVCD that your trying to fix. Enter an output file name and click on AV-Sync button. Here you have to be able to estimate the amount of time the A/V sync is out. Look for people speaking, Gun fire, door slamming, etc where it is easier to match the sound to the event. If the Audio comes before the Video, then move the slider in +'ve direction to the amount you have estimated. Click on Done, then click Save. In a short time you will have a new MPG file, do NOT shut down MPEG2VCR. Now play the movie, preferably with WinDVD, to check if the sync is correct. If a small adjustment needs to be done (I never get it right first time!) then jump back to MPEG2VCR and adjust the slider a bit more in the direction that’s needed. Hit Save again and when done, re-check the file. Repeat until it is fixed.
Sometimes just a simple De-multiplex with TMPGEnc and a Multiplex with MPEG2VCR with NO audio offset applied can fix A/V sync problems. This is particularly true if using the FlaskMPEG/Panasonic Plug-in method for creating the MPG.
If you now have the A/V sync correct at the start of the movie but is out near the end, then move onto the next solution.
Audio is in sync at start but progressively goes further out as you play the movie.
1. I have never seen this problem in a SVCD or a DVD but should work for them, definitely works for VCD's. The basic principle involved here is to strip out the Audio file (de-mux) then stretch or compress the audio frequency, 44.1kHz, and re-sample to 44.1 Then convert to *.MP2 format and re-multiplex with video stream. 2. Demux the MPG file so we can manipulate the Audio file. Run TMPGEnc, click on File and select MPEG Tools. Select Simple De-multiplex tab and for Input, browse to your problem MPG. Video and Audio output names will be automatically generated. The Audio being *.MP2 and video being *.M1V or *.M2V. Click Run and wait until its finished. Exit TMPGEnc. 3. We now have to estimate the approx time, in seconds, that the audio is out of sync and nearest to the end of the movie as possible. Simply play the original movie with WinDVD or similar player. Windows Media Player is not recommended as it can A/V sync problems of its own. Move slider to near the end of the movie and look for speech, gun fire, explosions, door slamming, etc where you have a precise Audio to Video match up. Estimate the time difference and not the length of the movie. Lets say we find the Audio trails the Video by about 1 second and the movie length was 48 min or 2880 sec (the door slams and about 1 sec later we hear the thud). 3. Run Goldwave and load in the *.MP2 file. Its also best to turn OFF the Undo feature to speed up the conversions (in Options / File...) Click on Effects and then Playback Rate. We need to change the 44100 Hz to sync the movie, use these formulae: [b]New Hz (Audio trails Video) = (Movie length in sec + Out of Sync in sec)/(Movie length in sec) * 44100[/b] or [b]New Hz (Audio precedes Video) = (Movie length in sec - Out of Sync in sec)/(Movie length in sec) * 44100[/b] So for our example, we have: New Hz = (48x60 + 1) / (43x60) * 44100 = 44115 So change the Rate from 44100 to 44115 (or the number you calculated) and hit OK. Now click Effects again and select Resample. Change the 44115 (or what ever figure you have) back to 44100 and hit OK. Once the conversion is finished, hit Save. For Type select Wave (*.wav) and Attributes as 16bit, Stereo, Signed. Change File name if needed and hit Save. When it finish's answer No and exit the program. 4. We now need to convert our WAV file back to an MP2 form. TMPGEnc is the simplest to use for this. Run TMPGEnc, and click File, then New Project to clear out old settings. For Stream Type select Audio Only and for Audio Source, browse to our new WAV file and Open it. Rename the Output file name to something different than the original MP2 file. Now click Settings and change the Bitrate from 192 to 224, this is ESSENTIAL for a VCD. Do NOT change any other settings except Normalize in Setting button (do this only if the audio appears low in volume). Then click OK and finally click Start. When done, exit TMPGEnc. 5. Run MPEG2VCR and under Tools, select MPEG System Multiplexor. Browse for the original Video *.M1V/*.M2V file after changing Files Type to All(*.*). Do the same for the new fixed Audio *.MP2 file. Now select MPEG-1 System Stream VCD or MPEG-2 Program Stream SVCD depending if its a VCD or SVCD that your trying to fix. Enter an output file name (different from the original) and click Save. When done, play the new MPG file in WinDVD and check that A/V sync has been fixed. If its still out a bit, you need to start all over again from Point 3 changing the frequency Rate a bit higher or lower. Repeat until its fixed. 6. It normally takes me 2 tries to get it right, but luckily I rarely have A/V sync problems. ChickenMan (c)2003