11. Setting up your uPNP media server
A uPNP media server allows you to stream videos from your Pi to any device that can talk to it.Â A lot of tellies do this these days, along with PS3s, XBoxs, iPads, tablets and your PC.Â With a server on your Pi, you can watch what you have downloaded on any compatible device in your house without the hassle of moving files or memory sticks about.Â Let’s rock.
You could try doing an apt-cache search for “upnp server” if you want the practice in finding suitable packages, or I could tell you that the one you want is Mediatomb.Â So sudo apt-get install mediatomb
It’s the same as when you installed Transmission.Â Apt tells you what it is going to install and you say Yes.Â It nips off, installs everything and sets it up.Â It doesn’t need much configuring either.Â It’ll work straight away but we’ll make a little adjustment or two.Â Or three if you own a Samsung TV.Â Our Samsung TV could connect to the server OK but wouldn’t play the videos.Â If you have the same problem, the fix for it is here.Â Read what it says and add the lines to the config file after you have made the following changes:
The configuration file for Mediatomb is /etc/mediatomb/config.xml (note that it’s in /etc, as usual) and is a bit unusual in that it’s an XML file.Â Let’s not pussyfoot around here.Â XML is a horrible way to present data and to use it in a configuration file is a crime against humanity.Â I could rant on for a while but I will spare you that – you have enough problems, being faced with a configuration file in XML format.Â So, open it up with sudo nano /etc/mediatomb/config.xml and let’s get started.Â As you can see, it’s nice and easy to read – if you are a robot…
<?xml version="1.0" encoding="UTF-8"?> <config version="2" xmlns="http://mediatomb.cc/config/2" xmlns:xsi="http://www.$ Â Â Â Â Read /usr/share/doc/mediatomb-common/README.gz section 6 for more Â Â Â Â information on creating and using config.xml configration files. Â Â Â --> Â <server> Â Â Â <ui enabled="yes" show-tooltips="yes"> Â Â Â Â Â <accounts enabled="yes" session-timeout="30"> Â Â Â Â Â Â Â <account user="mediatomb" password="mediatomb"/> Â Â Â Â Â </accounts> Â Â Â </ui> Â Â Â <name>MediaTomb</name> ... and so on ...
Straight away, you should see something that needs changing.Â The user interface web page has a default username and password, which is bad.Â Change that user=”mediatomb” password=”mediatomb” to something else.Â Or, if you are feeling brave, you can change “accounts enabled” to “no” and you won’t have to log on at all. This is a bad idea if you want to access it from outside your home network.
On the line after “<server>” add <port>49152</port> this forces it to use that port rather than pick one of its own choosing.Â Done that?Â CTRL-X, [Y]es you want to save, return to save it over the top of the original.
I’ve set up a download of a config.xml file with all those changes applied to it.Â Feel free to replace yours with it.Â The username is “mediatomb”, password is “wibble”.Â Please change them on your system.
A quick sudo service mediatomb restart and you are done with the setting up.Â To use the web interface, point your browser at http://your_pi_ip:49152 , log in (if you have to) and you should see this:
or something like that anyway.Â To get it to index your media, click on the “Filesystem” tab (next to “Database”), then the cross next to “mnt” (to expand that branch) and “downloads” to highlight it.Â Over on the right, there will appear a swirly cross which says “Add as autoscan dir” when you hover over it.Â Click on it to select that directory as one you want Mediatomb to scan.Â Choose “Inotify” for Scan mode, “Basic” for Initial scan and check “Recursive”.Â Click on “Set”, it will perform a basic scan and then when you click on the “Database” tab on the left, all your stuff should appear under the “Video” branch.Â Documentation for the user interface is available for those who want to tinker.
And that’s it.Â Your Pi should appearÂ asÂ a media server when your TV/PS3/whatever does a scan.Â Any new downloads should appear automatically but be aware that if you swap the external storage, it might not be rescanned when you plug it back in, so you will have get Mediatomb to do it manually.
Put the kettle on, make a cup of tea and enjoy your videos.Â That’s pretty much it for now.Â There’s one more chapter of useful things to know about Linux.