Media Server

Modern devices as smart TV's, smart Phones, Tablet PC can be connected to a media server to view movies, watch pictures and listen to music. Of course mediaserver and client can run on the same PC.

There is the DLNA (Digital Living Network Alliance) that defines standards and also certifies devices to be inter-operable to exchange multimedia data. However there are also other standards as Universal Plug and Play (UPnP).

In the Linux world there are two servers

Mediatomb and the light way ReadyMedia.


To use it a TV must have a built in media player and support streaming. Some TV's as Samsung use their own PC software (running only on windows) for streaming, but fortunately there is a standard way to communicate so mediatomb can also do the job. The TV has to act as a UPnP compliant MediaRenderer.


medaitomb is not a DLNA server it is a UPnP server but it has some DLNA support that is good enough for most users.

For Gentoo Linux emerge -pv mediatomb to see and decide on the database you like to use. The choice is MySql or Sqlite. Check to see what kernel parameters need to be set and what use flags are available for the compilation. mediatomb --compile-info will show what you have and what options are supported.

Start it as user in a console the user based configuration file ~/.mediatomb/config.xml and a uri as is printed (Ctrl+C stops it). Open this uri in a web browser on an other PC (or since it is TCP/IP you can also do it on the PC running mediatomb). A user interface pops up that looks as a file browser. It has two views, the Filesystem view that shows your harddisk and what ever it linked and mounted and the mediatomb database. So you can add the files you want to make available to the database. You can also add links to the Internet. Add as autoscan dir allows to keep the mediatomb database synchronized with the filesystem. To have this working the scan mode timed has to be selected.

Figure 12.11. Mediatomb

Media Tomb


It is relatively easy to read and write to the computer and therefore hackers might cause some harm.

Therefore do not start mediatomb as root.

Disable the user interface once it has configured by modifying config.xml to:

        <ui enabled="no" show-tooltips="yes">

When now is opened the text MediaTomb UI is disabled. Check your configuration. appears.

To not be so radical the user interface could be enabled but an account (username/password) can be set

        <ui enabled="yes" show-tooltips="yes">
      <accounts enabled="yes" session-timeout="30">
        <account user="<username>" password="<password>"/>

For Sqlite a database file is created in ~/.mediatomb/mediatomb.db different location and file name can be adjusted in /etc/conf.d/mediatomb

The file ~/.mediatomb/mediatomb.html can be opened by a browser or used as uri to open the server.

The system wide config file is /etc/conf.d/mediatomb and the log file is /var/log/mediatomb.log

MediaTomb daemon

For OpenRC init scripts start the mediatomb daemon, so do rc-update add /etc/init.d/mediatomb default. The difficult part here is to know what files and options the daemon uses.

The file /etc/conf.d/mediatomb contains the parameters passed to mediatomb by the init scripts as to take /etc/mediatomb/config.xml instead ~/.mediatomb/config.xml.

The /etc/mediatomb/config.xml script tells the daemon to use /var/lib/mediatomb as home and therefore use /var/lib/mediatomb/mediatomb.db and /var/lib/mediatomb/mediatomb.html not ~/.mediatomb/mediatomb.db and ~/.mediatomb/mediatomb.html

To see what is going on start and stop the init scripts. For OpenRC /etc/init.d/mediatomb start and /etc/init.d/mediatomb stop

Then check the log file /var/log/mediatomb.log

If not happy adapt the system wide config file is /etc/conf.d/mediatomb

To know what server can be seen add something to the name in the config.xml that is taken:

<name>MediaTomb <add here something unique></name> 

With the following setting just the directories holding the files will be visible and can be selected directly:

        <pc-directory upnp-hide="yes"/>

MediaTomb Troubleshoot

Unfortunately my Samsung TV can not play anything with the default settings. But the good news are: It sees all the files and shows how to fix it. To have them working, the following has to be added to ~/.mediatomb/config.xml :

        <protocolInfo extend="yes"/> 
  <add header=" Streaming"/>
  <add header=" DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=017000 00000000000000000000000000"/>

MediaTomb Transcoding

After that everything works well as long the the video codecs used are supported by the TV. If not mediatomb could convert them (transcode) on the fly or you can do it manually to avoid the following additional setup.

The transcode configuration will be done in config.xml

Before configuring mediatomb to transcode, it is worth to test if it runs. Open 3 console windows.

  1. In the first create a fifo with mkfifo /tmp/tr-test since mediatomb uses a fifo to get the transcoded stream from an external program.

  2. In the second console read the media file as here in the example a mkv video using ffmpeg to convert it and write it into the fifo: ffmpeg -i ./Avatar.mkv -vcodec mpeg2video -b 4096k -r 25 -acodec mp2 -ab 192k -ar 48000 -ac 2 -f dvd - > /tmp/tr-test

  3. Finally in the third console use the console version of vlc to read the fifo: cvlc /tmp/tr-test. If the video comes out mediatomb can be configured to transcode.

The ~/.mediatomb/config.xml has already prepared a lot for that mostly just setting enable to yes and adapting the formats you want to change do the job.

The client

After having a server also a UPnP client (other than a modern TV) might be desirable.

kodi (successor of xbmc)

djmount allows to mount a UPnP media server as linux filesystem. After that any program can be used to access the files.

Linurs Servernest startpage