Monday, September 7, 2009

Configuring MediaTomb for the PS3

Having just gone out and splurged on a shiny new PS3 Slim, I've had to make some changes on my file server to cater for what I previously thought was a severe limitation of the PS3 - lack of SMB support for connecting to network shares.

I've now replaced my previous media center - an XBox running the excellent XBMC - with the PS3, however the only remote shares supported by the full-HD, H.264-capable PS3 are UPnP/DLNA media servers.

As mentioned, I initially considered this a limitation but you really do get so much more with a UPnP server, such as transcoding (converting media formats on-the-fly and then streaming to the client) and using media metadata (such as ID3 tags in MP3 files) for searching and browsing.

Enter MediaTomb, "an open source (GPL) UPnP MediaServer with a nice web user interface, it allows you to stream your digital media through your home network and listen to/watch it on a variety of UPnP compatible devices".

Actually the web interface isn't that nice but it is functional, and you only have to visit it once.

My current file server is running Fedora 11 and you'll find MediaTomb in the Everything repo, but you won't have any trouble finding or installing the software on RHEL/CentOS (via EPEL) or Ubuntu.

There are plenty of resources to get you up and running quickly so in this post I wanted to share the specifics of my setup, especially:
  • modifying the import script to preserve a directory heirarchy
  • using transcoding to stream video within RAR archives, Flash video and other formats the PS3 doesn't understand
One of the biggest annoyances is, because your video files will most likely lack any useful metadata, they'll all just get lumped into one big folder, even if you have them neatly organised into seasons, categories or video-type on your fileserver.

Photos aren't quite so bad as they at least contain some metadata and MediaTomb will organise them by date by default.

This however is easily overcome by modifying the import.js script (in /usr/share/mediatomb/js on RHEL/CentOS/Fedora systems).

I use the following JavaScript (adapted from the workaround posted here) which replaces the addVideo() and addPhoto() functions:
function addMedia(obj, media_type) // media_type = Photos | Video
{
// Change this to suit your folder naming scheme
var parent_folder = media_type;

var loc = obj.location.split('/');
var mediaFound = false;
var chain = new Array(media_type);

for (i=0; i<loc.length-1; i++) {
if (mediaFound) chain.push(loc[i]);
if (loc[i] == parent_folder) mediaFound = true;
}

str = loc[loc.length-1];
obj.title = str.substring(0,str.lastIndexOf('.'));
addCdsObject(obj, createContainerChain(chain));
}
You'll need to ensure that you change the function calls in the main section of the script like so:
if (mime == 'video')
{
addMedia(obj, 'Video');
}

if (mime == 'image')
{
addMedia(obj, 'Photos');
}
And that your top level folders which contain your Photos and Video are named exactly "Photos" and "Video" respectively or adjust the parent_folder variable accordingly.

You should now see your files neatly organised just as they appear on the filesystem of your media server.

I'll follow up on this post in a day or so with the configuration and software required to get transcoding of RARs and FLVs working.

0 comments:

Post a Comment