Fix Audio Delays Permanently Using VLC & MKVToolNix

Multimedia files with ‘lip-sync’ issues are not so uncommon, although it happens very rarely in professional environments as they take extra precautions to avoid them.

In a previous post I wrote about how to fix some of these synchronization issues permanently using ‘Avidemux’, but since then I have received few complains of ‘Avidemux’ not being able to fix those issues in some cases. Now to be honest, I too have come across some of these problems but fortunately I have been able to fix them (so far).

‘Avidemux’ can do very little if the input file itself has some issues (corrupted video frames etc) but ‘Avidemux’ is also a bit buggy, so some of the blame goes toward it also. In any case, there are few other tools that you can try while trying to fix a sync ‘malfunction’, and ‘MKVToolNix’ is one among them.

Changing-audio-sync-in-VLC-and-adding-it-to-MKVToolNix-illustration
Illustration …

‘MKVToolNix’ is not an encoder as you can only use it to ‘extract’ audio/video/subtitle tracks from other containers (MP4, AVI, FLV etc) and put them into the powerful and open-source MKV container. While doing so this tools also lets you pass certain settings (sync, fps, aspect ratio …) and it is through that we can attempt to fix sync problems.

But please be aware that the only output format it support is MKV (and few of its variations such as ‘MKA’ for audio’, ‘MKS’ for subtitles etc) and unlike MP4 or AVI, MKV is not supported by a lot of commercial and strictly hardware based multimedia players. Computer users however do not have to worry about it as popular players (VLC, MPC, PotPlayer, SMPlayer, KMPlayer …) support it. Enough talking, let’s do it!.

Note: Make sure you have downloaded and installed the latest builds of ‘MKVToolNix’ from here. I also recommend that you use VLC because both these utilities are available for multiple operating system platforms, so you can use this ‘guide’ in any of them.

What we are going to do is …

*. First we are going to play the ‘troublesome’ file in VLC (or any other player that lets you change the sync temporarily) and we will try to identify the proper sync value.

*. Then we will simply enter that sync value into ‘MKVToolNix’ and save it as a new MKV file so that it is saved permanently. That is it!.

Step 1:

So open your ‘troublesome’ file in VLC, and let it play for a few seconds. Then simply press the ‘j’ key on your keyboard. This will make VLC play the audio track a bit ahead of the video. A single click increases the value by 50 milliseconds only, so unless the ‘gap’ is very small, you will have to press it a few times to get see its effect.

VLC-with-minus-ahead-of-video-audio-sync-value

Anyhow, if after pressing ‘j’ key for a few times it worsens the ‘gap’, then it is an indication that you actually have to make VLC play the audio track a bit behind (delay) the video. The shortcut key for that is ‘k’. Again, to feel its effect, you might have to press it a few times. If after doing that it seems to shorten the ‘gap’ then it is an indication that you are on the right track. So keep doing that until you come up with the perfect sync value.

VLC-with-a-plus-delay-audio-sync-value So as a general rule, play with ‘j’ and ‘k’ keys, until you find the perfect sync value for that multimedia file. Once you have found it, simply take a note of it (note that depending on the file the value could be positive or a negative one. If it is a negative/minus one, then you should enter a minus sign before entering the value in ‘MKVToolNix’, more below) and close VLC.

Step 2:

Now open ‘MKVToolNix’ and load the ‘troublesome’ file into it. Then under ‘Tracks, chapters and tags’ field, select the audio stream/track (shown below is an example).

Selecting-the-audio-track-in-MKVToolNix

Step 3:

Then from under it, click on the ‘Format specific options’ tab and you will see an empty field that says ‘Delay (in ms)’. Now simply enter the sync value you found above into that field.

Entering-an-audio-sync-value-manually-in-MKVToolNix
Make sure to enter a minus sign (-) when needed (-200 for instance) …

Step 4:

Now click on the ‘Browse’ button under ‘Output filename’ field. Select a location and a file name for the output MKV file. Once done, simply click on the ‘Start muxing’ button. If everything goes without any errors, try playing the newly saved MKV file and now you should be able to enjoy it without any ‘lip-sync’ issues!. Good luck.

An RHCE, 'Linux' user with 14+ years of experience. Extreme lover of Linux and FOSS. He is passionate to test every Linux distribution & compare with the previous release to write in-depth articles to help the FOSS community.

91 thoughts on “Fix Audio Delays Permanently Using VLC & MKVToolNix”

  1. Thanks a lot man. I had a transport stream in perfect sync, when I made an mp4 it screwed up the audio. MK Toolnix worked perfectly

    Reply
  2. You can also use something like CamTasia studio if you have it and add or remove the appropriate length of time.

    Save the audio file once sync and then merge with mkvtool

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Shares
Tweet
Share
Share
Pin1