‘Audio to video synchronization‘ is an extremely important aspect of a multimedia file, because when playing, multimedia players rely on it for properly synchronizing the audio and the video tracks. If the synchronization value is incorrect, then the audio (or the video) is going to be played early or with a delay, compared to the other, which is commonly known as ‘lip-sync’ errors, and it jeopardizes all the excitement, obviously.
For instance, while watching a movie, if you have ever come across situations like gunshot firing sounds coming out before its video scene is displayed, then that is due to an improper audio to video sync. This is a pretty common issue in multimedia files and there are many reasons behind its existence, but for keeping the article clear and simple so that anyone can understand its context without having to go through boring technical details, I will not mention them.
In any case, the good news is, depending on the OS platform that you are using, there are powerful software multimedia players (VLC, KMPlayer, MPLayer etc) that give you the ability to manually adjust the sync setting, thus you can enjoy the multimedia files without such issues.
The problem with that method however is that it only saves the sync setting temporarily, and it will be lost the next time you play it. However, thanks to a great open-source tool called ‘Avidemux’, you can save the audio/video sync setting permanently.
‘Avidemux’ supports multiple operating systems, therefore you don’t have to be a Windows user to do it either. Plus, it also supports lots of multimedia codecs and container formats (MP4, MKV, AVI etc), thus, you will be able to fix a lot of different file types too. So if you’re having lip-sync errors in one of your multimedia files, then you can try the below ‘Steps’ for a possible fix.
First of all, go to this page, download the package and install it (it has pre-built packages for Windows, Mac OS X and GNU/Linux).
Now open ‘Avidemux’ program and load the ‘troublesome’ multimedia file into it.
Before continuing, under the ‘Video Output‘ and ‘Audio Output‘ options, make sure it says ‘Copy’. Also make sure to enable the option called ‘Shift’ (disabled by default), as it is the option that lets you change the audio/video sync setting (shown below).
Any value that you enter here (‘Shift’) should be in milliseconds (1000 milliseconds = 1 second).
Now, if you know what the correct audio/video sync value is then you can skip this and go directly into the end of ‘Step 5‘. If not, click on the ‘Play’ button on ‘Avidemux’ window, so we can observe and see whether the audio comes before or after the video scenes.
If the audio comes ‘before’ …
The rule of the thumb is that, if the audio is played before the video, then that means we have to ‘add time’ to it (thus delaying it), so the video track can ‘catch up’ with the audio track. This is done by entering a positive sync value (say 200 milliseconds) into the ‘Shift’ box.
If the audio comes ‘after’ …
If it comes few seconds (or milliseconds) after the video scene is displayed, then it is already delayed, therefore, we have to ‘remove time’ from it, thus making it being played early.
One cannot give you the exact audio/video sync value that is needed as it is something that you will have to guess by observing the video playback. However, in my experience, the usual range is 200 milliseconds to 2000 milliseconds (2 seconds). But there can be occasions where it requires one to enter higher values.
Anyhow, unlike above, this time we have to add a negative value as the sync value, in order to make it load earlier (if you enter ‘-200’, then that means the audio will be loaded 200 milliseconds early).
Let’s assume that the file you loaded had an audio track that was being played with a delay. Then to make it play early, we have to enter a negative value. And unless the sync was so big that you could easily tell that the audio came few seconds after the video, I recommend that you start by entering a small negative (say a ‘-100’ milliseconds) value first.
If it fixes the lip-sync a little, then add another -100 (altogether ‘-200’ milliseconds). Then carry it on until you arrive at the optimal audio/video sync value.
However, before every time you apply a different sync setting, first make sure to ‘Pause’ the playback, then add the new value and resume playback. Otherwise ‘Avidemux’ will not apply that setting to the playback.
Note: This is just an example (of course) and depending on your multimedia file, you will have to figure out whether to use a negative or a positive value, but the procedure is just the same.
Once you are satisfied with your new audio/video sync, now all you have to do is save the changes. But before doing so, just make sure that under the ‘Output Format’ option, you have selected the proper output format.
For example, if the source file was an AVI file, then make sure to select ‘AVI Muxer’. If it was FLV, then choose ‘FLV Muxer’ etc.
‘Avidemux’ doesn’t have like a huge list there, but it supports saving into AVI, FLV, MP4, MPEG-TS, MKV etc. If your input file has a different format than listed there, then you can choose ‘MKV Muxer’ as it supports storing a huge number of different audio and video codecs.
Note: Please be aware that, if you put audio/video that were previously stored in an AVI file into a MKV container, then sure MKV will store them without any issues. But most commercial hardware devices (iPad for example) will struggle to play it afterwards. This does not concern the computer users as most popular players support playing the awesome MKV format.
Update: Sometimes while trying to fix a MP4 file, though you might be able to successfully fix it and play it in ‘Avidemux’, the corrected sync value might simply be lost, after saving it into a new MP4. If this occurs, then I advice you to try selecting ‘MP4v2 Muxer‘ rather than using the ‘MP4 Muxer‘ (under ‘Output Format‘). I have been able to successfully save the corrected sync settings of certain MP4 files, by simply making that change alone!.
Once all is done, from its menu click on: ‘File’ -> ‘Save’ to save the changes permanently.
Depending on the length of the video, the time it takes will differ, but it should not take much longer (pretty much like copying that file over to somewhere else) since nothing gets re-encoded.
When it is finished saving, you can open that file using any media player, and if the sync value you entered was correct, then it should be playable without any sync issues. Well, that is it!.
Update: Some readers have complained that ‘Avidemux’ is not always working for them. So I wrote another method that uses another tool, which is known to work most of the time. However, that method only supports saving your input files (you can input almost anything into it AVI, MPEG, MP4, FLV …) into ‘MKV’, which as briefly mentioned above, is not playable on certain hardware based multimedia players. You can read about it from here.