Originally posted in November 2014
Mediatomb
is an opensource (GPL) UPnP mediaserver with a nice web user interface,
allowing you to stream your digital media via your home network and listen
or watch it on a variety of UPnP compatible devices simultaneously.
Particularly, it can be configured as a DLNA server to stream your media to
your Smart TVs or DLNA enabled devices such as ipod docks with the Auris
Skye adapter.
Note the output indicating that the YouTube feature is enabled; this
seems to be the default message, despite the feature being actually
disabled. I decline to confirm or deny whether the feature actually works.
The message says it all!
The convention used for issuing commands in the terminal are if you are
supposed to run via root user the line starts with "#" and if you are to run
the command as user the line starts with "$".
Installation & Configuration of Mediatomb
Binaries for Fedora 20 x64 are available from the Fedora repositories, so
you can install Mediatomb using yum with the following command.
#yum install mediatomb
There are basically two ways of running Mediatomb: you can either start
it directly as a user or run it as a daemon.
To run it as a normal user run $mediatomb
To run it as a daemon #service mediatomb start
The configuration file is stored in two places: if you run as root user it
is /etc/mediatomb/config.xml or as normal user in ~/.mediatomb/config.xml. This is very important because depending on whether you run Mediatomb as
a root user or normal user, you will have to edit the relevant configuration
file. Otherwise, changes to the config.xml file will not be applied. The configuration file for the server itself is /etc/mediatomb.conf
Running Mediatomb in Fedora 20 x64
At the time of writing, Mediatomb is never able to stream media out of the
box. I identified the following issues in the configuration itself.
- The network interface that the server will stream on is not set. This is set in /etc/mediatomb.conf
- Mediatomb is configured to create/write iptable rules itself. However, in the newest Fedora distros, a firewall application called firewalld is the only application allowed to create/write iptable rules. In other words, Mediatomb is effectively blocked by the firewall by default.
- Even if the firewall is unblocked for the Mediatomb server's ports, because the ports that the server binds to are set to be dynamic the server will fail to stream intermittently.
- Mediatomb will not work as a DLNA server out of the box. You will have to write the relevant header files to the config.xml file.
- Mediatomb is unable to play certain files like matroska (mkv) too, unless you enable transcoding manually in the config.xml file.
In this article, I will cover the first 4 points in full, and partially
the last point. Indeed, making Mediatomb stream many formats efficiently
is a large subject; you may look into other places such as here
Importantly, we will run the server in normal user mode rather than as root
user. Thereby, we will configure the local user config file (~/.mediatomb.conf). We will also modify the server configuration file to provide the network
interface.
Make sure all instances of Mediatomb are not running. You may use the killall
command.
Run the following command to find all the network interfaces your computer
operates on.
#ifconfig
In the listed interfaces, generally eth0
is the wired interface, wlan0
is the wireless interface and lo
is the loopback interface. The names mentioned above may differ, but I've
noticed that at least the first letter is common. Check the TX and RX packet
data in the output to verify if the interface is active. Otherwise, you can
go ahead by using the loopback interface for a start.
Now you need to edit the mediatomb.conf
file. My favourite editor is vi
but if you are not familiar with it you may also use something like gedit
too.
#gedit /etc/mediatomb.conf
Change the line which reads MT_INTERFACE="" to MT_INTERFACE="lo"
(the network interface your computer operates). Save and close.
Exit root user mode. Now the local user config file must be edited.
First, we will make the port that Mediatomb binds itself to be static
rather than be dynamic. The server by default binds to port 49152, so we
will use this port permanently.
$gedit ~/.mediatomb/config.xml
You have to modify certain header lines. First, set the port to
49152.
<port>49152</port>
Then add the following lines between the custom-http-headers
to stream Mediatomb as a DLNA server.
<custom-http-headers>
<add header="transferMode.dlna.org: Streaming"/>
<add
header="contentFeatures.dlna.org:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=017000
00000000000000000000000000"/>
</custom-http-headers>
Enable transcoding
<transcoding enabled="yes">
Now, we have to modify the line indicating the transcoding profile vlcmpeg.
I had to modify the lines highlighted to get it work; check yours and alter
accordingly. You may also add more profiles if you wish too.
<profile name="vlcmpeg" enabled="yes" type="external">
<mimetype>video/mpeg</mimetype>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="vlc" arguments="-I dummy
%in --sout #transcode{venc=ffmpeg,vcodec=mp1v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out}
vlc:quit"/>
Save and close.
Now go back into root user mode. We will allow the relevant ports through
the firewall. Port 49152 (tcp) is the one the server binds to; port 1900
(udp) is the general port DLNA servers bind to.
#firewall-cmd --zone=public --permanent --add-port=49152/tcp
#firewall-cmd --zone=public --permanent --add-port=1900/udp
Exit root user mode. Run mediatomb as normal user.
