If you like to watch videos with subtitles, you have two options. First, you have an external subtitles file and your player can pick it up while playing the video file. Second, you have a video file with an embedded subtitles stream. You may be forced to use the second option for certain video players or for streaming video content using media servers, like MiniDLNA for example.
It is possible to embed a subtitles file, for example a SubRip
.srt file, into a video file to output a video file that has the subtitles stream embedded in it. The easiest method to achieve this is to output to a Matroska Multimedia Container (MKV) file. This is a commonly used container format for video files that can hold multiple streams: video, audio and subtitles. So, we create a MKV file containing the original video file (of any format) and a subtitles stream to be used along with it. The only limitation is that you will need a player that supports MKV to replay this back.
To deal with MKV files, we need the
$ sudo apt-get install mkvtoolnix
We use the
mkvmerge tool from this package to merge a SubRip SRT file into an existing video file:
$ mkvmerge -o out.mkv in.avi in.srt
- The input file cannot be overwritten with the output file, hence we use a different name here.
Multiple subtitle files can be added to MKV file incrementally in this way. This is typically used to embed subtitles of multiple languages into the file.
When playing with a player like VLC, one or none of the subtitles can be picked. For example, right-click in the middle of the playing video and choose Subtitle -> Sub Track.
Tried with: MKVToolNix 6.7.0-1 and Ubuntu 14.04
FileBot is a useful tool to have if you need to organize your TV or movie video files or need to download subtitles. It is available on the Ubuntu Software Center as a paid app. However, it can be installed for free from the packages offered for download on their webpage.
For example, to download subtitles, click the Subtitles tab. Type or paste in the name, choose the language, search and download. Takes out all the grunt work.
Note that the 4.5.x versions of Filebot require Java 8 JRE to be available. Older 4.2.x versions works fine with older Java versions.
Tried with: FileBot 4.2 and Ubuntu 14.04
GNOME Subtitles is a good tool to edit, sync and perform all other common operations on subtitles.
Installing it is easy:
$ sudo apt install gnome-subtitles
Open up a subtitle file and you can perform the following operations:
Tried with: GNOME Subtitles 1.3 and Ubuntu 14.04
One of the most convenient features of XBMC is that you can automatically download subtitles for any video right from inside it. It would be really nice to have this feature with VLC. And it can be done using the VLSub extension:
- Download the vlsub.lua file from its Github repository or VLC addon page.
- Create the directory ~/.local/share/vlc/lua/extensions/ and place the Lua file there. This is where VLC looks for its extensions.
- Play any video using VLC. Choose View > VLSub, this shows the VLSub dialog.
- Choose either Search by hash or Search by name. The extension searches in OpenSubtitles and displays the list of all matching subtitles. Select the subtitle you want and click Download. Once the download is done, click Close.
- The extension downloads the subtitle file, places it in the same directory as the video file, renames it to have the same name as the video file and applies it to the currently playing VLC. Enjoy 🙂
Tried with: VLSub 0.9, VLC 2.0.5 and Ubuntu 12.04 LTS
XBMC, and hence Raspbmc, can automatically show subtitles when the subtitles file has the same name as the video filename and is placed in the same directory. What is awesome is that you can download and play subtitles for any video file right from the comfort of your XBMC!
XBMC 13 (Gotham) and later
XBMC 13 added native support for subtitle downloading. Go to Settings > Video > Subtitles. Scroll down to Default TV service and Default Movie service. When you enter, you are given a list of subtitle websites and you can pick which you want for TV and movies. More details can be found here.
XBMC 12.x and older
First, you need to install the XBMC Subtitles add-on. To do this, go to System > Settings > Add-ons > Get Add-ons > XBMC.org Add-ons > Subtitles, choose XBMC Subtitles Add-on and install it.
Next, play any video file. While it is playing choose the Download Subtitles option. This is available in XBMC remote apps like Yatse. Else, choose whatever option makes the video playback scroller appear. There on the set of icons below it on the right side, pick the first one.
Either way, this takes you to the Downloading Subtitles widget. XBMC will query subtitles databases online and show you a list of the best matching subtitles for your video file. Pick the one you want and press OK. XBMC will download the subtitle file and restore playback of the video file with the subtitles enabled. It is as easy as that! 🙂
Many videos come with a subtitles track, either embedded in the video container or as a separate file (typically a .
srt file). Sometimes, these subtitles might be out of sync with the video.
Syncing up the subtitles to the video is easy in VLC. Use the keyboard shortcuts
g to either delay or forward the subtitles over the video. Each keypress changes the delay by 50 milliseconds and VLC displays the current delay value as an overlay on the video.
There is another method, but surprisingly it does not work! Open the Tools → Track Synchronization dialog. Here, go to Synchronization → Advance of subtitles over video and set the delay to the amount you wish. This setting surprisingly has no effect! What works is only the keyboard shortcuts described above.
Tried with: VLC 1.1.3