3

Setting up mediatomb in Ubuntu 9.10 (Karmic)

Having recently bought a WDTV HD Live to replace my Xbox (with XBMC) I decided to look into setting up a UPnP service on my Ubuntu headless server.

After reading around a bit, I firstly tried uShare but didn’t find it very flexible. I finally settled on MediaTomb as I liked the look of the JavaScript import scripts that can be written. I started getting setup so checked out the MediaTomb wiki and a few online tutorials, but struggled to get MediaTomb to work. Either I had missed something, or the articles weren’t 100% clear. Here are the steps I took to get it working…

Steps

sudo apt-get install mediatomb

This will get mediatomb installed, and should set it up as a service. You can stop/start/restart it with:

sudo /etc/init.d/mediatomb stop|start

Next you need to change the config.xml for MediaTomb. This is located at /etc/mediatomb/config.xml

sudo gedit /etc/mediatomb/config.xml

  1. Set the name of your server in the config. This is near the top under the element <name>.
  2. By default (and this point stumped me for a bit) it won’t use import.js to import your videos/music/photos. Instead it will just use the MediaTomb default (which for movies I didn’t find very good). If you search for “virtual-layout” and change its attribute “type”, from “builtin” to “js”, this will cause import.js to be used.
  3. Under the <server> element, add <pc-directory upnp-hide=”yes”/>. This hides the annoying PC Directory folder that will otherwise show up when you view your UPnP service.

Next you’ll want to edit the “import.js” file that defines how your media is imported. This is located at /usr/share/mediatomb/js/import.js.

sudo gedit /usr/share/mediatomb/js/import.js

Here’s my import.js file. I’ve only changed the “addVideo” function so far. The code (if you’re a developer) should be reasonably easy to read. With all of the above set, restart your MediaTomb service

sudo /etc/init.d/mediatomb stop

sudo /etc/init.d/mediatomb start

* note you can try “restart” but I’ve had issues with it.

Importing files

You should now be able to go to the web interface for MediaTomb (http://localhost:49152/), then under the “File System” section add any folders, setup filesystem watchers etc… If you’re running the service on your local machine, “Inotify” is probably the better way of getting Mediatomb to watch any folders for updates. However, using Inotify won’t work remotely. For example, I ssh onto my server, and often move files around which don’t get picked up by Inotify.

Set it watching any folders you choose, then wait a minute or two for Mediatomb to import all the data. You can check what the import looks like in the web interface, under the “Database” section.

Autostarting Mediatomb

sudo gedit /etc/default/mediatomb

Make sure at the top you have the line – NO_START=”no”.

Also, if you’re running Ubuntu it has a bit of a bug, whereby Mediatomb is started before NetworkManager and fails to start as it can’t find a working network device. I found the following lines fixed this (moved it back in terms of load order):

sudo update-rc.d -f mediatomb remove

sudo update-rc.d mediatomb defaults 99

This fix was taken from the Mediatomb wiki FAQ (about 1/4 down the page)

You should now have a fully functional UPnP server up and running!

Related Posts

  • Justin Buser

    I kind of like the Folder structure layout myself, I renamed the PC Directory container to Folders cause the name was stupid but other than that I’d prefer to organize my stuff manually.

    • http://robertbeal.com Rob

      Hi, the problem with folders is that an item can only belong to one folder. Using JavaScript I could have an HD action movie. I could organise my content in such a way that the movie shows up under the “hd” folder, or the “action” genre. It’s just a more powerful way of organising content.

  • Pingback: Inspiration nature