Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Fix Audio Sync Issues In MKV Video Files


First, we need to find out how much of a shift in the audio track we need to make to have it match the video. Open up the video in VLC and use the j and k keys to shift the audio until you get it spot on.

  • k - add delay (50ms)
  • j - reduce delay (50ms)

There is nothing more annoying than finding out that your video's audio doesn't match up with the video. Rather than throwing the file away, you can just fix it in Linux with these easy steps.

This tutorial assumes you are running Ubuntu 16.04, but the steps should be similar in other distros.

Install Mkvtoolnix

In order to fix the sync issue on the video file, we will need to use mkvmerge, which can be installed with:

sudo apt-get install mkvtoolnix -y

Get Track ID

We need to find out what the ID of the track is. Use the command:

mkvmerge -i input.mkv

... which should output something like this:

File 'input.mkv': container: Matroska
Track ID 0: video (MPEG-4p10/AVC/h.264)
Track ID 1: audio (AC-3/E-AC-3)

As you can see, in my example the audio track is ID 1.

Sync The Audio

Now that we know what delay we need (from using VLC), and we have the audio track ID (previous step), we can run this command to create a new copy of the file that should be fixed.

-o output.mkv
--sync [audio track ID]:[number of ms]

The shorthand for --sync is -y.

So in my case, the audio track is 1, and I want to add -2 seconds delay so:

mkvmerge \
-o output.mkv \
--sync 1:-2000 \


Last updated: 16th August 2018
First published: 16th August 2018