If your MKV file has audio that is out of sync, you can fix it without re-encoding the video. The term mkv audio out of sync covers two different problems: a constant offset where the audio is delayed or early by the same amount throughout, or a drift where the gap grows over time. Identify which problem you have, then repair it losslessly with MKVToolNix.

Constant Offset Vs. Drift

Before fixing an mkv audio delay, identify the type of sync error. A constant offset means the audio is shifted by the same number of milliseconds from start to end. The audio might be behind the video for the entire movie. This is the easier problem to fix.

Drift is different. With drift, the audio starts in sync but gradually falls behind or moves ahead. By the end of the file, the gap may be several seconds. Drift usually indicates a frame rate mismatch, a sample rate mismatch, or corrupted timestamps. Fixing drift requires re-encoding the audio or correcting the timing data.

Testing with VLC Audio Delay

Play your file in VLC and use the keyboard shortcuts for vlc audio delay to find the offset. During playback, press J to make the audio later, or press K to make it earlier. Press the keys multiple times to find the correct offset.

If the sync stays consistent after you set the offset, you have a constant offset. If the sync is good at the start but gets worse as the video plays, you have drift.

Fixing a Constant Offset with Mkvmerge Sync

Apply the Offset on the Command Line

Once you know the offset in milliseconds, use the MKVToolNix command-line tool to shift the audio track without re-encoding. The track ID (TID) is the number of the audio track in the file. Negative values move the audio earlier, positive values move it later.

Here is the procedure:

  1. Open a terminal or command prompt.
  2. Run the identification command on your file to find the track ID for the audio track. It will be a number like 2 or 3.
  3. Run the sync command with your track number and offset, writing to a new output file. Replace TID with the track number and ms with the offset.
  4. Check the output file in a media player.

Use the GUI Instead

If you prefer a graphical interface, MKVToolNix GUI exposes this as the "Delay (in ms)" option on the track. Enter the same positive or negative number there.

Handling Drift and Damaged Timestamps

If the audio drifts, a simple offset will not fix it. Drift requires re-encoding the audio to match the video frame rate or sample rate. There is one exception: if the drift is caused by broken timestamps near the end of the file, such as after a crash during recording, remuxing the file may help.

Every MKV block carries its own timestamp relative to its cluster. If a crash damaged timestamps in the last few clusters, the audio may appear to drift in that region. A fresh remux without any sync adjustment can regenerate the timestamp structure. Run the remux command without the sync flag to rebuild the file and correct drift caused by corrupted metadata.

Using the Mkvmerge Sync Option in Detail

The sync option is the primary tool to fix audio sync mkv issues. Here are the key details:

  • The syntax uses the track ID followed by the offset in milliseconds. The track ID is the number of the audio track, not the video track.
  • Negative values shift the audio earlier. Positive values delay the audio.
  • The shift is applied to every block in that track, so it works only for constant offsets.
  • The output is a new MKV file. The original file is not modified.

If you have multiple audio tracks, apply different delays to each track by repeating the sync option for each track ID.

What to Do When Mkvmerge Sync is Not Enough

If the audio drift is not caused by damaged timestamps, remuxing will not fix it. Re-encode the audio to match the video. One common cause of drift is a mismatch between the audio sample rate and the video frame rate. An audio track recorded at a common sample rate might drift when muxed with a video at a common frame rate. Re-encoding the audio to the correct sample rate can solve this.

Another option is a tool that applies a dynamic delay, such as a time-stretching filter. This requires re-encoding and is outside the scope of lossless repair. If you cannot fix the drift, accept a small re-encode of the audio track only.

Repairing Broken MKV Files After a Crash

If your MKV file was created during a recording that crashed, the timestamps near the end may be broken. This can cause the audio to appear out of sync or the file to stop playing early. A simple remux with the MKVToolNix command-line tool can repair this:

  1. Run the remux command on the broken file, writing to a new output file.
  2. Check if the file plays correctly from start to finish.
  3. If the audio is now in sync, the damage was limited to the timestamps.

If the audio is still out of sync after remuxing, test with the VLC audio delay shortcuts to see if the offset is constant. If it is, apply the offset with the sync command. If it drifts, the file may require re-encoding.