23

My TV can only play subtitles if they are embedded into the file (eg a MKV or hardcoded over the video).

So given a film in a format (eg MP4) and a subtitle as something like a SRT, how can I combine them into something my TV can play?

5 Answers 5

26

Short answer

You could use mkvmerge (apt-get install mkvtoolnix) to create a Matroska container and include the subtitles in the output:

mkvmerge -o output.mkv input.mp4 subtitle0.srt subtitle1.srt

This does not require re-encoding, so it is pretty fast.

Further customization

You may set the language and name of each subtitle track:

mkvmerge -o output.mkv input.mp4 \
    --language 0:en --track-name 0:English english_subtitles.srt
    --language 0:es --track-name 0:Español spanish_subtitles.srt

Note that we used for both languages the same track ID (0:), which corresponds to the input video track.

The --language needs to be properly encoded. You can list all allowed ISO 639-2 and ISO 639-1 codes with:

mkvmerge --list-languages

Other useful features

You may also set the title of the output video with:

--title "Your title"

We can check how all subtitles were added to the output:

$ mkvmerge -i output.mkv
File 'output.mkv': container: Matroska
Track ID 0: video (MPEG-4p10/AVC/H.264)
Track ID 1: audio (AAC)
Track ID 2: subtitles (SubRip/SRT)
Track ID 3: subtitles (SubRip/SRT)

If you really want to "burn" the subtitles in the video, you may use ffmpeg instead.

4
  • Can you explain how to do this with multiple files? Jun 19, 2017 at 2:33
  • It doesnt support special characters as á à ñ... Aug 5, 2017 at 0:27
  • Also (as per superuser.com/questions/609113/…) mkvmerge -o output.mkv input.mkv --language 0:ger --track-name '0:German subs' subs.srt
    – sdaau
    Oct 25, 2018 at 8:47
  • @SumeetDeshmukh A bit late, but I actually asked myself the same question and took the opportunity to update the answer. :-)
    – Peque
    Nov 19, 2020 at 20:39
10

Try HandBrake. HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded video transcoder, available for MacOS X, Linux and Windows. it allows users to add subtitles as a part of the movie with the option to turn the subtitle on and off. Something like DVD movie subtitles.

To install HandBrake from Ubuntu PPA:

  1. In terminal window enter: sudo add-apt-repository ppa:stebbins/handbrake-releases Your system will now fetch the PPA's key.
  2. Now just update the list of software repos, including the PPA you just added, by using apt-get: sudo apt-get update
  3. Open "Ubuntu Software Center" and check your "Sound & Video" category. You can also filter results by clicking the small down-arrow on right-side of "All Software" option and select your PPA.

OR

If you are using Karmic (9.10) or later, you can just click on "Technical details about this PPA" link on the PPA page and select your Ubuntu version. sources.list entries hence shown can be added directly to your system's software sources: System Setting > Software Sources > Other Software(Tab).

4
  • 2
    you can even use vlc's convert/save feature to hard-sub videos. Apr 5, 2012 at 21:48
  • 1
    I couldn't install handbrake. I add the ppa and update, should I also add the lines frome here: launchpad.net/~stebbins/+archive/handbrake-releases to the system software source? If do, how?
    – yinon
    Apr 6, 2012 at 7:47
  • 1
    just updated my answer, just check it. similar instructions can be found on HandBrake Releases page. Apr 6, 2012 at 13:10
  • Handbreak is not yet available for 12.04. Only daily non-stable snapshots. I recommend waiting a bit for it since they are fixing a couple of saving issues. May 11, 2012 at 10:31
5

I added them with avconv like:

avconv -i The.Hunt.For.Red.October.1990.1080p.BluRay.x264.anoXmous_.mp4 -f srt -i The.Hunt.For.Red.October.1990.1080p.BluRay.x264.anoXmous_.spa.srt -c:v copy -c:a copy -c:s mov_text The.Hunt.For.Red.October.1990.1080p.BluRay.x264.anoXmous_subtitles.mp4
5

you can use avidemux.

To install

sudo apt-get install avidemux

The procedure:

1.Launch avidemux.

2.Open the .avi file.

3.Select a video encoder from the pull-down menu on the left pane, where it says Video.

4.Configure the encoder by clicking the "Configure" button.

5.Add a subtitler filter. First click on the "Filters" button in the left pane (under Video).

7.To finalize the process, click Save and type in a name for the output file.

More You can use VLC

  1. Make a new folder and keep the movie file inside that folder.

  2. put the subtitle file into the folder that you have created.

  3. Rename the subtitle with the movie name and use .srt extension at the last

Read more on.

2

Use ffmpeg:

ffmpeg -i "/tmp/toggle-android-lib-and-layout.mp4" -f srt -i "/tmp/toggle-android-lib-and-layout.srt" -c:v copy -c:a copy -c:s mov_text /tmp/t.mp4 -y

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .