Audio and video out of sync when using mkvmerge

I extracted audio and video from an mkv using mkvextract. Then I used mkvmerge to merge them back into an mkv. When I played the mkv the audio and video were out of sync.

How can I combine them so that they are in sync? I tried to find some helpful information using mkvmerge on the original file to see if there was any useful information, but didn't find any.


Here is a simple workflow:

  • Find out how much out of sync it is with VLC player by using j and k buttons.
  • Download mkvtoolnix and click on add file.
  • Add your video file. When added, click on the audio file and now you can add your delay. Simply put, use - or + and which ever you delay worked out with vlc.
  • Press mux now. Done :)

It's possible that the original file specified an audio delay. If you're using the mkvmerge GUI, you can change the audio track's delay in the Format specific options tab. Positive values delay the audio track, negative values advance it (all in milliseconds). If you're using the command line, you need to use the -y or --sync arguments. See the mkvmerge documentation for details. The documentation also shows you how to scale the audio delay evenly though out the video (instead of a set constant delay).

To determine the audio delay you need, you can use Media Player Classic along with the +/- keys to determine the delay. Alternatively, you can try to use a media information tool to see what the delay was on the original file.