02-05-2021



Let's assume you have a file called MyMovie.avi and the audio track in aseparate file, e.g. MyMovie.wav. First you want to encode the audio toOGG:

$ oggenc -q4 -oMyMovie.ogg MyMovie.wav

After a couple of minutes you can join video and audio:

$ mkvmerge -o MyMovie-with-sound.mkv MyMovie.avi MyMovie.ogg

MKVToolNix comes with with a README.md, a README.Windows.md (instructions how to compile MKVToolNix on Linux for use on Windows), a Contributor Covenant Code of Conduct and man pages for all programs: mkvmerge, mkvinfo, mkvextract, mkvpropedit and MKVToolNix GUI. You can also read the NEWS.md file (contains news & changes). MKVToolnix 55.0 MKVToolNix is a set of tools that allow users to display information about, extract streams from, merge several streams into, and split Matroska MKV media files. Supported video stream types include streams from AVIs, Ogg/OGM, RealVideo, MP4 files, and MPEG program streams as well as various elementary streams (h264/AVC, MPEG1/2. Mkvtoolnix-gui (1) is a Qt based GUI for mkvmerge (1) (and will evolve to cover mkvinfo (1) and mkvextract (1) as well). It offers easy access to most of mkvmerge (1)'s options. All settings (e.g. Source files, track options etc) can be saved and restored.

If your AVI already contains an audio track then it will be copied as well(if mkvmerge supports the audio format). To avoid that simply do

This program takes the input from several media files and joins their streams (all of them or just a selection) into a Matroska(TM) file; seethe Matroska(TM) website. ImportantThe order of command line options is important. Please read the section 'Option order' if you're new to the program. Global options:-v, -verbose 1. Increase verbosity. Suppress status output.o, -output file-name 1. Write to the fi. Type `mkvmerge -h` to get you started. Last edited by QNAPStephane on Fri Jul 12, 2019 2:58 am, edited 1 time in total.

$ mkvmerge -o MyMovie-with-sound.mkv -A MyMovie.avi MyMovie.ogg

After some minutes of consideration you rip another audio track, e.g.the director's comments or another language to MyMovie-add-audio.wav.Encode it again and join it up with the other file:

$ oggenc -q4 -oMyMovie-add-audio.ogg MyMovie-add-audio.wav
$ mkvmerge -o MM-complete.mkv MyMovie-with-sound.mkv MyMovie-add-audio.ogg

The same result can be achieved with

Man

$ mkvmerge -o MM-complete.mkv -A MyMovie.avi MyMovie.ogg
MyMovie-add-audio.ogg

Now fire up mplayer and enjoy. If you have multiple audio tracks (or evenvideo tracks) then you can tell mplayer which track to play with the'-vid' and '-aid' parameters. These are 0-based and do notdistinguish between video and audio.

Man

If you need an audio track synchronized you can do that easily. First findout which track ID the Vorbis track has with

$ mkvmerge --identify outofsync.ogg

Now you can use that ID in the following command line:

$ mkvmerge -o goodsync.mkv -A source.avi -y 12345:200 outofsync.ogg

This would add 200ms of silence at the beginning of the audio track with theID 12345 taken from outofsync.ogg.

Some movies start synced correctly but slowly drift out of sync. For thesekind of movies you can specify a delay factor that is applied to alltimestamps - no data is added or removed. So if you make that factor toobig or too small you'll get bad results. An example is that an episodeI transcoded was 0.2 seconds out of sync at the end of the movie whichwas 77340 frames long. At 29.97fps 0.2 seconds correspond to approx. 6frames. So I did

$ mkvmerge -o goodsync.mkv -y 23456:0,77346/77340 outofsync.mkv

The result was fine.

Introduction

The sync options can also be used for subtitles in the same manner.

For text subtitles you can either use some Windows software (likeSubRipper) or the subrip package found in transcode(1)'ssources (in contrib/subrip). The general process is:

The chapter editor
1.
extract a raw subtitle stream from the source:
$ tccat -i /path/to/copied/dvd/ -T 1 -L |
tcextract -x ps1 -t vob -a 0x20 |
subtitle2pgm -o mymovie
2.
convert the resulting PGM images to text with gocr:
$ pgm2txt mymovie
3.
spell-check the resulting text files:
$ ispell -d american *txt
4.
convert the text files to a SRT file:
$ srttool -s -w -i mymovie.srtx -o mymovie.srt

Creating Matroska Files

The resulting file can be used as another input file for mkvmerge:

$ mkvmerge -o mymovie.mkv mymovie.avi mymovie.srt

If you want to specify the language for a given track then this is easilydone. First find out the ISO639-2 code for your language. mkvmergecan list all of those codes for you:

$ mkvmerge --list-languages

Search the list for the languages you need. Let's assume you have put twoaudio tracks into a Matroska file and want to set their language codes andthat their track IDs are 2 and 3. This can be done with

$ mkvmerge -o with-lang-codes.mkv --language 2:ger --language 3:dutwithout-lang-codes.mkv

As you can see you can use the --language switch multiple times.

Maybe you'd also like to have the player use the Dutch language as the defaultlanguage. You also have extra subtitles, e.g. in English and French, and wantto have the player display the French ones by default. This can be done with

Setting Up Mkvmerge GUI

$ mkvmerge -o with-lang-codes.mkv --language 2:ger --language 3:dut--default-track 3 without-lang-codes.mkv --language 0:eng english.srt--default-track 0 --language 0:fre french.srt

The Chapter Editor

If you do not see the language or default track flags that you've specifiedin mkvinfo's output then please read the section about DEFAULTVALUES.