Looking for a quick command line solution to extract a specific section of video clip from a mkv (Matroska) file? Well look no further, mkvmerge can do this and more.
Using mkvmerge you can split a mkv file between specific timecodes to extract a timed video clip, for example to extract a 30 minute clip which starts 70 minutes into the source file:
mkvmerge --out outfile.mkv --video-tracks 1 --audio-tracks 2 --no-subtitles --no-attachments infile.mkv --split timecodes:01:10:00,01:40:00 --split-max-files 3
or put more succinctly:
mkvmerge -o outfile.mkv -d 1 -a 2 -S -M infile.mkv --split timecodes:01:10:00,01:40:00 --split-max-files 3
The above command will split the source infile.mkv into three new output files. The command line arguments specify using video track 1, audio track 2, and the removal of any subtitles or attachments.
The first outfile will contain the first 70 minutes, the second will contain the next 30 minutes (the segment you want) and the last outfile will contain the remainder of the file.
Easy when you know how 😀