Saturday, August 30, 2008

Using the PlayStation 3 as a media center with Linux

I recently got a PlayStation 3 from my wonderful girlfriend, and one of the reasons I wanted one was for its great possibilities of being a media center. I installed MediaTomb on my Linux machine (Gentoo) and after half an hour of configurations, it was ready to stream content to the PS3.

Installing MediaTomb
Portage is wonderful, and of course contains MediaTomb. It is an open source uPnP media server with DLNA support. DLNA is a protocol that computers and other devices can use to talk to each other, for instance when supplying video files over a network. It can do much more too, just have a look at the link to wikipedia for more info. When I did my install, I followed the guide at To get more information (especially regarding transcoding), check the site there, this is my "shortcut" guide to it.

Install it using portage:
# emerge mediatomb
Make sure you have the use flags that you need enabled. I'm using
[I] net-misc/mediatomb
Available versions: 0.11.0 {curl debug exif expat ffmpeg javascript libextractor mysql taglib}
Installed versions: 0.11.0(22.28.13 2008-08-17)(curl exif expat ffmpeg javascript taglib -debug -libextractor -mysql)
Description: MediaTomb is an open source UPnP MediaServer
and that works well for me. Since I rather use sqlite instead of a full mysql install, I haven't enabled that use flag.

When streaming to the PS3, you also need to enable some transcoding support. This also allows you to get thumbnails on the different video files. I use ffmpeg as my transcoder, since I already have it installed. Make sure you have the "encode" use flag enabled. If you need video thumbnails, also install ffmpegthumbnailer. support.
# emerge ffmgeg
# emerge ffmpegthumbnailer
Then you have to create 2 scripts to launch the transcoding for you. First the script for audio (/usr/bin/mediatomb-transcode-audio):


exec "${FFMPEG_PATH}" -i "${INPUT}" -vcodec ${VIDEO_CODEC} -b ${VIDEO_BITRATE} \
-ac ${AUDIO_CHANNELS} -f ${FORMAT} - > "${OUTPUT}" 2>/dev/null
and then the one for video (/usr/bin/mediatomb-transcode-video)


exec "${FFMPEG_PATH}" -i "${INPUT}" -vcodec ${VIDEO_CODEC} -b ${VIDEO_BITRATE} \
-ac ${AUDIO_CHANNELS} -f ${FORMAT} - > "${OUTPUT}" 2>/dev/null
We need to make them both executable:
# chmod +x /usr/bin/mediatomb-transcode-audio
# chmod +x /usr/bin/mediatomb-transcode-video
My config file now looks like the following. Copy it to /etc/mediatomb/config.xml and start MediaTomb.
<?xml version="1.0" encoding="UTF-8"?>
<config version="1" xmlns=""
<ui enabled="yes">
<accounts enabled="no" session-timeout="30">
<account user="mediatomb" password="mediatomb"/>
<sqlite3 enabled="yes">
<mysql enabled="no">
<protocolInfo extend="yes"/>
<import hidden-files="no">
<scripting script-charset="UTF-8">
<virtual-layout type="builtin">
<extension-mimetype ignore-unknown="no">
<map from="mp3" to="audio/mpeg"/>
<map from="ogg" to="application/ogg"/>
<map from="asf" to="video/x-ms-asf"/>
<map from="asx" to="video/x-ms-asf"/>
<map from="wma" to="audio/x-ms-wma"/>
<map from="wax" to="audio/x-ms-wax"/>
<map from="wmv" to="video/x-ms-wmv"/>
<map from="wvx" to="video/x-ms-wvx"/>
<map from="wm" to="video/x-ms-wm"/>
<map from="wmx" to="video/x-ms-wmx"/>
<map from="m3u" to="audio/x-mpegurl"/>
<map from="pls" to="audio/x-scpls"/>
<map from="flv" to="video/x-flv"/>
<map from="avi" to="video/x-divx"/>
<map from="divx" to="video/x-divx"/>
<map from="vob" to="video/x-divx"/>
<map from="audio/*" to="object.item.audioItem.musicTrack"/>
<map from="video/*" to="object.item.videoItem"/>
<map from="image/*" to="object.item.imageItem"/>
<treat mimetype="audio/mpeg" as="mp3"/>
<treat mimetype="application/ogg" as="ogg"/>
<treat mimetype="audio/x-flac" as="flac"/>
<treat mimetype="image/jpeg" as="jpg"/>
<treat mimetype="audio/x-mpegurl" as="playlist"/>
<treat mimetype="audio/x-scpls" as="playlist"/>
<treat mimetype="audio/x-wav" as="pcm"/>
<treat mimetype="audio/L16" as="pcm"/>
<treat mimetype="video/x-msvideo" as="avi"/>
<treat mimetype="video/divx" as="avi"/>
<treat mimetype="video/vob" as="avi"/>
<transcoding enabled="yes">
<transcode mimetype="application/ogg" using="audio-common"/>
<transcode mimetype="application/ogg" using="video-common"/>
<transcode mimetype="audio/x-flac" using="audio-common"/>
<transcode mimetype="video/x-flv" using="video-common"/>
<transcode mimetype="video/divx" using="video-common"/>
<transcode mimetype="video/divx" using="video-thumbnail"/>
<profile name="audio-common" enabled="yes" type="external">
<agent command="mediatomb-transcode-audio" arguments="%in %out"/>
<buffer size="1048576" chunk-size="131072" fill-size="262144"/>
<profile name="video-common" enabled="yes" type="external">
<agent command="mediatomb-transcode-video" arguments="%in %out"/>
<buffer size="10485760" chunk-size="262144" fill-size="524288"/>
<profile name="video-thumbnail" enabled="yes" type="external">
<agent command="ffmpegthumbnailer" arguments="-i %in -o %out -s 128"/>
<buffer size="524288" chunk-size="512" fill-size="1024"/>
Start it using
# /etc/init.d/mediatomb start
Adding files and directories
To add files to the MediaServer, simply point your favourite browser to and then press the "Filesystem" link to the left. There you can add the directories you want, and the server parses them for you. If you have inotify enabled in you kernel (which you probably do) it will be possible to let the server automatically know when something has been changed, and it reparses that directory when needed.


Anonymous said...


I m not a guru in Linux, but why did you not take Yellowdog Linux? So far as i understood, it s the distribution "supported" by Sony for the PS3. You should then have less effort to configure :)

I m interested about this topic because i plan to buy a PS3 and to make as you, a media server of it.


steve said...

Because the chap is streaming media from a pc/laptop to his ps3, not installing an os to it.
This way you can use the storage of your pc and play what you want via your home network on the ps3.

Tormak said...

You can enable transcoding of vob files as well by having the lines for vobs as such:

instead of:

map from="vob" to="video/x-vob"/
Put this:
map from="vob" to="video/x-divx"/

In the transcoding profile section add this line (with the appropriate angle brackets):
transcode mimetype="video/vob" using="video-common"/

AZMel said...

Are the video and audio transcode files supposed to be exactly the same? I would have thought the audio would be different.

Peter said...

tormak: Thanks! I actually just added those lines as a guess after my initial config, and forgot to remove them when I did the post. I'll change it. Both here and at home, hehe.

psykil said...

Nice. Thanks for the tips.