In this tutorial, we will be discussing how to extract subtitles from MKV files in Ubuntu. This can be a useful task when you want to manipulate subtitles or translate them. We will be using a command-line tool called
mkvextract, which is part of the
To extract subtitles from MKV files in Ubuntu, you can use the command-line tool
mkvextract from the
mkvtoolnix package. First, install
mkvtoolnix using the command
sudo apt-get install mkvtoolnix. Then, identify the track number of the subtitle track using
mkvmerge -i <filename>. Finally, use the
mkvextract tracks command to extract the subtitle track by specifying the track number and the desired output file.
The first step is to install
mkvtoolnix. This can be done by running the following command in the terminal:
sudo apt-get install mkvtoolnix
This command uses the
apt-get package manager to download and install
sudo keyword is used to run the command with root privileges.
Identifying the Track Number
Before we can extract the subtitles, we need to identify the track number of the subtitle track in the MKV file. This can be done using the
mkvmerge -i <filename> command. For example:
mkvmerge -i some_movie.mkv
This command will display information about the tracks in the MKV file. The output will look something like this:
Track ID 0: video (MPEG-4p10/AVC/h.264)
Track ID 1: audio (AC3)
Track ID 2: subtitles (SubRip/SRT)
In this example, the subtitle track has the track ID 2. The track type (SubRip/SRT) indicates the format of the subtitle track.
Extracting the Subtitle Track
Once we have the track number of the subtitle track, we can use the
mkvextract tracks command to extract the subtitle track. The syntax is as follows:
mkvextract tracks <your_mkv_video> <track_number>:<subtitle_file.srt>
For example, to extract the subtitle track with track number 2 from the file “some_movie.mkv” and save it as “some_movie_subs.srt”, you would run the following command:
mkvextract tracks "some_movie.mkv" 2:some_movie_subs.srt
In this command,
tracks is the command that tells
mkvextract to extract tracks from the MKV file.
<your_mkv_video> is the name of your MKV file,
<track_number> is the track number of the subtitle track, and
<subtitle_file.srt> is the name of the file where the extracted subtitles will be saved.
Extracting subtitles from MKV files in Ubuntu can be easily done using the
mkvextract tool from the
mkvtoolnix package. By identifying the track number of the subtitle track and using the
mkvextract tracks command, you can save the subtitles to a separate file for further use.
Remember to check the track type using
mkvmerge -i <filename> and adjust the file extension accordingly when saving the extracted subtitles. This will ensure that the subtitles are in the correct format and can be used with other software or media players.
An MKV (Matroska Video) file is a multimedia container format that can hold multiple audio, video, and subtitle tracks in a single file.
You can check if the
mkvtoolnix package is already installed by running the command
dpkg -s mkvtoolnix in the terminal. If the package is installed, you will see information about the package. If it is not installed, the command will display an error message.
Yes, you can extract multiple subtitle tracks from an MKV file by specifying multiple track numbers in the
mkvextract tracks command. For example,
mkvextract tracks "some_movie.mkv" 2:some_movie_subs.srt 3:some_movie_subs_2.srt will extract the subtitle track with track number 2 and save it as "some_movie_subs.srt", and extract the subtitle track with track number 3 and save it as "some_movie_subs_2.srt".
mkvextract tool is specifically designed to extract tracks from MKV files. If you have a different video file format, you may need to convert it to MKV format before using
mkvextract to extract the subtitles.
Extracted subtitles are typically saved in the SubRip/SRT format, which is a common format for subtitles. You can view the extracted subtitles using a text editor or a dedicated subtitle viewer software.