3.2 KiB
Creating a basic guide to working with MKV files focuses on MKVToolNix, a suite of tools designed specifically for the Matroska media container format. MKVToolNix includes mkvmerge for merging and mkvextract for extracting streams, among other utilities. This guide will introduce you to the core functionalities of MKVToolNix for handling MKV files.
Introduction to MKVToolNix
MKVToolNix is a set of tools to create, alter, and inspect Matroska files (MKV). Matroska is a flexible, open standard container format that can hold an unlimited number of video, audio, picture, or subtitle tracks in one file. MKVToolNix is available for Linux, Windows, and macOS.
Installing MKVToolNix
Before using MKVToolNix, you need to install it on your system.
- On Ubuntu/Debian:
sudo apt update sudo apt install mkvtoolnix mkvtoolnix-gui - On Fedora:
sudo dnf install mkvtoolnix - On macOS (using Homebrew):
brew install mkvtoolnix
Basic MKVToolNix Commands
1. Merging Files into an MKV
You can combine video, audio, and subtitle files into a single MKV file using mkvmerge:
mkvmerge -o output.mkv video.mp4 audio.ac3 subtitles.srt
This command merges video.mp4, audio.ac3, and subtitles.srt into output.mkv.
2. Extracting Tracks from an MKV File
To extract specific tracks from an MKV file, you first need to identify the tracks with mkvmerge:
mkvmerge -i input.mkv
Then, use mkvextract to extract the desired track(s):
mkvextract tracks input.mkv 1:video.h264 2:audio.ac3
This extracts the first track (usually video) to video.h264 and the second track (usually audio) to audio.ac3.
3. Adding and Removing Subtitles
To add subtitles to an existing MKV file:
mkvmerge -o output.mkv input.mkv subtitles.srt
This adds subtitles.srt to input.mkv, creating a new file output.mkv.
To remove subtitles or other tracks, first identify the track numbers, then use mkvmerge to create a new file without the undesired tracks:
mkvmerge -o output.mkv --track-order 0:1,0:2 input.mkv
Assuming track 3 is the subtitle track you wish to remove, this command re-creates input.mkv as output.mkv without track 3.
4. Changing Track Properties
To modify track properties, such as language or default track flag:
mkvpropedit input.mkv --edit track:a1 --set language=eng --set flag-default=1
This sets the language of the first audio track (a1) to English (eng) and marks it as the default track.
GUI Alternative
For those who prefer a graphical interface, MKVToolNix comes with MKVToolNix GUI, an application that provides a user-friendly way to perform all the tasks mentioned above without using the command line.
Conclusion
This guide covers the basics of handling MKV files with MKVToolNix, from merging and extracting tracks to modifying track properties. MKVToolNix is a powerful toolkit for MKV file manipulation, offering a wide range of functionalities for users who work with video files in the Matroska format. Whether you prefer the command line or a graphical interface, MKVToolNix has the tools you need to manage your MKV files effectively.