Perspective of a Thinking Human Being

  • arch linux
  • general
  • programming
  • tips & tricks
Home › How to Merge Subtitles to a Movie File

Reply to comment

How to Merge Subtitles to a Movie File

kensai — Wed, 06/25/2008 - 09:25

My refusal to use Windows is what makes me learn to do everything using only Linux, even though it usually requires long times in front of the computer researching and tweaking the hints google.com/linux gives me. But, at least I can say that at the end the results are satisfying, I end up learning more about Linux and how powerful a command line application can be compared to a most GUI application. I must admit that I do prefer GUI in the majority of the cases, is just that from time to time I am amazed by the power of the CLI. My latest adventure was learning how to merge a .srt (movie subtitle file) with a .avi (movie file). How I did it? Well, first we need to have mplayer installed, which on Arch Linux can be done as follows:

# pacman -Sy mplayer codecs

After that you might need to create the mplayer folder (if it isn't there already) so we can add the fonts we would like to use for the displaying of the subtitles in the movie, with that purpose we issue the following command:

$ mkdir .mplayer && cp /usr/share/fonts/TTF/LiberationSans-Regular.ttf .mplayer/subfont.ttf

Change the LiberationSans-Regular.ttf with the font you want to use. If you want to use the Liberation font, install the ttf-liberation package which is available in the community repository.

# pacman -Sy ttf-liberation

OK, we have gone a bit off the curse here with the fonts thing, but by now we should have the mencoder application installed, hopefully this makes us still on track for the merging that is about to happen. The mencoder application is part of the mplayer application we just installed, mencoder is the tool we are going to use to merge the subtitles with the movie. Now, to the better part of this tutorial, how we merge the subtitles with the movie files, the following script should do the trick:

$ mencoder -o fileiwantatend.avi -sub subtitlesfile.srt -oac copy -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell theactualmovie.avi

The first .avi we refer to in the above script is the file we want to create at the end of the merge (the resulting file), which could be named movie_subtitle.avi, now, the .srt file referred to in the script is the subtitles file which do not necessarily need to be on .srt format, it could be for example in .sub format, and the latests .avi file referred to in the command is the original movie file which you want to merge with the subtitles.

This command is very simple and has few options so it preserves the original movie file quality without much alterations, if any.
Legend:
# = as root
$ = as user

  • Tips & Tricks
  • Add new comment
  • 4429 reads

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Navigation

  • Recent posts
  • Feed aggregator

User login

What is OpenID?
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
9 + 7 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password

Recent comments

  • forex blog is essential
    1 sec ago
  • online Forex trading
    3 min 3 sec ago
  • online casinos > online
    1 week 6 days ago
  • well, I use...
    6 weeks 1 day ago
  • Youtube video question?
    8 weeks 1 day ago
  • Awesome!
    13 weeks 5 hours ago
  • Great newsletter!! - Keep it up ;)
    13 weeks 5 hours ago
  • Not for the end-user
    13 weeks 1 day ago
  • you can test it on
    13 weeks 1 day ago
  • Efficiency
    13 weeks 1 day ago

Search

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
5 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Who's online

There are currently 0 users and 4 guests online.
  • arch linux
  • general
  • programming
  • tips & tricks

Copyright © 2008 - Eduardo Romero - All rights reserved.