Embed subtitles from linux command line



To embed subtitles into an avi to see with your dlna device, you can do as follows

transcode -i name_of_video.avi -x mplayer="-sub name_of_subtitle.srt" -o name_of_subtitled_video.avi -y xvi


After reinsalling my arch box, I had several provems with xvid.so… I found a easier way to do the same with mencoder
$ mencoder -UTF8 -sub movie_subtitle.srt -ovc xvid -xvidencopts bitrate=-700000 -oac copy -o new.movie.name.avi movie.avi

As you will use mplayer to transcode the subtitle, you must configure properly mplayer to show correctly those special characters, like accents, inverted question or exclamation marks. Almost everyone will do with UTF-8 encoding. To configure mplayer, edit ~/.mplayer/config
# Set font.
#set your ttf fonts here, example:

# Set font encoding.

# Set subtitle file encoding.

Note that gmplayer, smplayer and others mplayer-based players, do NOT use that config file, then you MUST edit this file or subtitles will show weird characters and you will transcode the video again. You’re adviced.


3 thoughts on “Embed subtitles from linux command line

    • Transcoding usually is not a good idea, but If you want to see a divx on a player which cannot play srt by itself (there are several cheap dlna/divx players) or if you have a combination of container/subs that your player cannot play (I’m always speaking of physical players, not software), that is a quick and dirty solution.
      In a few minutes, you can enjoy the video, and after that you can always delete the transcoding.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s