MediaTomb and PS3: Adding subtitles

Native english speakers usually don't bother much with them, but movie subtitles are a good thing. When you're fond of Asian movies, like I am, they move from "good thing" to "absolute necessity". Why not setup mediatomb to serve those movies with embedded subtitles to the PS3?

The trick is telling mediatomb that a subtitle actually is a movie itself. First job is creating a mimetype for the subtitle extensions:

<map from="srt" to="video/subtitle"/>
<map from="sub" to="video/subtitle"/>

And, just like any other mimetype that needs transcoding, add a mapping line...

<transcode mimetype="video/subtitle" using="mencoder-sub"/>

... and a matching transcoding profile.

<profile name="mencoder-sub" enabled="yes" type="external">
        <agent command="/usr/local/bin/mediatomb-mencoder-sub" arguments="%in %out"/>
        <buffer size="1000000" chunk-size="512000" fill-size="20480"/>

If you're unfamiliar with the mediatomb config.xml structure, my full config file is up here. The mediatomb-mencoder-sub script looks up the movie for the given subtitle, and for this to work the filenames must be identical, except for the extension. requires a MyFile.avi.

exec mencoder "$(echo $1 | sed 's/...$/avi/')" \
-oac lavc -ovc lavc -of mpeg \
-lavcopts vcodec=mpeg2video:keyint=1:vbitrate=2000:vrc_maxrate=8000:vrc_buf_size=1835 \
-vf harddup,scale -zoom -xy 720 -mpegopts muxrate=12000 \
-sub "$1" -font "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf" \
-subfont-autoscale 0 -subfont-text-scale 25 -subpos 100 \
-o "$2" &>/dev/null

This has a few things hardcoded: first of all, the simple extension replacement, a font for the subtitles (pick your own favourite) and various options for the scaling thereof, and last but not least scaling of the movie to 720px wide. This was only included to allow me to stream HD divxes with subtitles - my processors aren't powerful enough to decode and re-transcode HD divx on the fly. Once again, edit to suit your needs.

Once you re-import your movies and subtitles, you'll notice the .srt or .sub showing up as separate movie files below the original .avi in the PS3's menu. The .avi will be just the movie, without subtitles; the .srt/.sub will give you a transcoded stream of movie + subtitles.


silly question

im unsure where to put the last part on the config window. where it starts with bin bash, where does that go?

Submitted by john (not verified) on Sat, 03/11/2012 - 17:17.
Can't pause.

Hi! ... great tutorial!

One thing though, for some reason when I play a movie calling it from the .srt
at the PS3, I can't pause it or FF it. This works fine if I call it from the avi file. I only care about the pause since it helps with my bathroom breaks :P ... Any ideas ?

Thanks a lot.

Submitted by Nicolas (not verified) on Tue, 22/11/2011 - 15:12.
You can pause using the "PS"

You can pause using the "PS" button, but yes, ffwd/rew doesn't work when transcoding. Pretty much a limitation of MT (and most other streaming servers).

Submitted by Someone (not verified) on Tue, 22/11/2011 - 15:14.
Lennert! Thank you very


Thank you very much!

I read about 20 tutorials regarding MediaTomb during the last week and none of them made the subtitles work.

Your tutorial worked!

Now I can finally watch my TV Series with subtitles on my Upnp devices!!

I would marry you if i was not already married!

Thank you very much!

Submitted by Marcos (not verified) on Wed, 19/10/2011 - 01:08.
How can i test

How can i test mediatomb-mencoder-sub from shell?

srt files are not displaying in mediatomb....


Submitted by Cristian (not verified) on Mon, 20/06/2011 - 09:46.
PS3 can't read .srt files


Thanks for sharing the tip.

I followed the tutorial, but when I browse my server from my PS3 the .srt files are shown as not compatible. The PS3 can't read it.

Any thought on this ?


Submitted by Chrisnof (not verified) on Sat, 11/06/2011 - 17:32.
I figured it out, I forgot

I figured it out, I forgot the set the 'enabled' option to 'yes'

Submitted by Chrisnof (not verified) on Sun, 12/06/2011 - 16:06.
Almost there...

Hi. I guess you are not playing with this anymore but maybe you can shed some light on my problem. I'm basically stuck at the same point that helgeim was (or is). I can see the srt's in the XMB but when I select them it says that the data is corrupted... Do you know what could it be?

Submitted by Jose Miranda (not verified) on Sun, 05/06/2011 - 07:18.
Very cool

Very much appreciated, this worked perfectly after adding "-ofps 24000/1001" to mencoder flags. Two problems, though: when watching the transcoded+subtitled version, my PS3 doesn't allow rewinding/fast forwarding (not much of a problem) or pausing the movie (bigger problem). Do you know if this is fixable?

Submitted by thi (not verified) on Sun, 10/04/2011 - 18:09.
Amendment: I learned from the

Amendment: I learned from the Mediatomb FAQ that the PS-button can be used to pause the movie.

Submitted by thi (not verified) on Sat, 16/04/2011 - 08:38.
Mencoder for FreeBSD v7.3 on AMD

please where and how to download mencoder for "FreeBSD freenas.local 7.3-RELEASE-p3 FreeBSD 7.3-RELEASE-p3 #0: Tue Nov 2 22:41:50 CET 2010 amd64"

Submitted by Ahmed Tawfik (not verified) on Thu, 24/02/2011 - 00:06.

cd /usr/ports/multimedia/mencoder
make install clean

Submitted by Someone (not verified) on Thu, 03/11/2011 - 03:49.
Very cool - you wrote a very

Very cool - you wrote a very nice tutorial and saved a lot of people a lot of time. Thanks.

Submitted by Barry de Graaff (not verified) on Wed, 03/11/2010 - 19:49.
media server error


I tried this out and the PS3 sees the sub files, but when I try to open them I get either "Media Server Error/failed" or "corrupted data".

Any suggestions ?

Submitted by helgeim (not verified) on Tue, 22/06/2010 - 22:11.

If I were you, I'd check first if the mencoder command works when being ran directly from the shell, instead of via mediatomb. Usually this kind of problem is caused by mencoder throwing an error (because of FPS settings, in lots of cases - mencoder doesn't like floating-point FPS values).

Alternatively, you can try using my "Lazy man's solution" which should do everything; see for that.

Submitted by Lennert on Wed, 23/06/2010 - 11:23.
something about subtitles

hi! i am having some troubles to make this thing work, i have used all kind of scritps i have found on the web but any of them could merge subtitles with the video, when i select the subtitle in the tv ( this is the device i am using with mediatomb) it hangs up saying that its loading and then ( file not supported ) this is my mencoder-sub (i am using archlinux):
exec mencoder "$(echo $1 | sed 's/...$/avi/')" \
-oac lavc -ovc lavc -of mpeg -ofps 24000/1001 \
-lavcopts vcodec=mpeg2video:keyint=1:vbitrate=2000:vrc_maxrate=8000:vrc_buf_size=1835 \
-vf harddup,scale -zoom -xy 720 -mpegopts muxrate=12000 \
-sub "$1" -font "/usr/share/fonts/TTF/DejaVuSans.ttf" \
-subfont-autoscale 0 -subfont-text-scale 25 -subpos 100 \
-o "$2" &>/dev/null

and the config.xml

<?xml version="1.0" encoding="UTF-8"?>












thanks in advance for any help (sorry for my english)

Submitted by Santiago (not verified) on Tue, 26/04/2011 - 17:35.
works with my Motorola Xoom

Thank you so much for your tutorial.. now i can see my subtitled videos on my new android Motorola Xoom (with Skifta upnp client)

Submitted by Thus0 (not verified) on Tue, 26/04/2011 - 23:14.

User login

Who's online

There are currently 0 users and 2 guests online.