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
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.
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.
mkvmerge -o output.mkv --sync [audio track ID]:[number of ms] input.mkv
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 \ input.mkv
- Hectic Geek - Fix Audio Delays Permanently Using VLC & MKVToolNix
- Mkvmerge Man Page
- Linux Forums - How To Synchronize Audio in a Matroska (MKV) media file container
First published: 16th August 2018