MediaTomb on OpenFiler

Description

I wanted my Sharp 70 inch TV to show some of my content stored on my OpenFiler NAS.  So many of the other NAS devices are DLNA capable, so why not my own. 

Process/Implementation

Its only a few steps actually, and isn't too bad.  Alot of people have struggled with this, and their efforts helped give the clues I needed to bring this all together.

  • Step 1 is to get the files.  While using OpenFiler as the location this will run, we don't have ready made packages that we can easily install with.  No Conary package, no apt/rpm package, etc - so go with the staticly compiled binaries available from the MediaTomb site : http://mediatomb.cc/pages/download#static
  • To keep things clean and easy, extract into /opt as the default config shows things that way. 
cd /opt
gunzip -d -c mediatomb-static-0.11.0-r2-linux-uclibc-i386.tar.gz | tar -xvf -
  • Config file change number 1 - modify the /opt/mediatomb/config/config.xml, in the "server" section, add these three changes :
<server>
  ...
  <name>OpenFiler MediaTomb</name>
  <port>50500</port>
  <interface>eth0</interface>
  ...
</server>
  • Config file change number 2 - modify the /opt/mediatomb/config/config.xml again.  To have it autoscan directories that we added, add this in between the scripting tags section and the mapping tags section : 
</scripting>
<autoscan use-inotify="auto">   
  <directory location="/full/path/to/music" mode="timed"     
    interval="86400" level="full" recursive="yes" hidden-files="no"/>   
  <directory location="/full/path/to/movies" mode="timed"     
    interval="86400" level="full" recursive="yes" hidden-files="no"/>   
  <directory location="/full/path/to/pictures" mode="timed"     
    interval="86400" level="full" recursive="yes" hidden-files="no"/>
</autoscan>
<mapping>
  • Config file change number 3 - modify the /opt/mediatomb/config/config.xml again.  For the TV's to work, convert the "protocolInfo" extend setting to "yes", and add these custom headers : 
<protocolInfo extend="yes"/> 
<custom-http-headers>
  <!-- DLNA TVs -->
  <add header="transferMode.dlna.org: Streaming"/>
  <add header="contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01500000000000000000000000000000"/>
</custom-http-headers>
  • Final config looks like this : 
<?xml version="1.0" encoding="UTF-8"?>
<config version="1" xmlns="http://mediatomb.cc/config/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/2 http://mediatomb.cc/config/2.xsd">
  <server>
    <ui enabled="yes" show-tooltips="yes">
      <accounts enabled="no" session-timeout="30">
        <account user="******" password="*****"/>
      </accounts>
    </ui>
    <name>OpenFiler MediaTomb</name>
    <port>50500</port>
    <udn>uuid:6c4de17f-8fe5-478f-8367-3c4f9482f8c8</udn>
    <home>/opt/mediatomb/config</home>
    <webroot>/opt/mediatomb/usr/share/mediatomb/web</webroot>
    <storage>
      <sqlite3 enabled="yes">
        <database-file>mediatomb.db</database-file>
      </sqlite3>
    </storage>
    <protocolInfo extend="yes"/>
    <custom-http-headers>
        <!-- DLNA TVs -->
        <add header="transferMode.dlna.org: Streaming"/>
        <add header="contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01500000000000000000000000000000"/>
    </custom-http-headers>
    <manufacturerURL>redsonic.com</manufacturerURL>
    <modelNumber>105</modelNumber>
  </server>
  <import hidden-files="no">
    <filesystem-charset>UTF-8</filesystem-charset>
    <metadata-charset>UTF-8</metadata-charset>
    <playlist-charset>UTF-8</playlist-charset>
    <scripting script-charset="UTF-8">
      <common-script>/opt/mediatomb/usr/share/mediatomb/js/common.js</common-script>
      <playlist-script>/opt/mediatomb/usr/share/mediatomb/js/playlists.js</playlist-script>
      <virtual-layout type="js">
        <import-script>/opt/mediatomb/usr/share/mediatomb/js/import.js</import-script>
      </virtual-layout>
    </scripting>
    <autoscan use-inotify="auto">
      <directory location="/full/path/to/music" mode="timed"     
        interval="86400" level="full" recursive="yes" hidden-files="no"/>   
      <directory location="/full/path/to/movies" mode="timed"     
        interval="86400" level="full" recursive="yes" hidden-files="no"/>    
      <directory location="/full/path/to/pictures" mode="timed"     
        interval="86400" level="full" recursive="yes" hidden-files="no"/>
    </autoscan>
    <mappings>
      <extension-mimetype ignore-unknown="no">
        <!-- The mapping is only triggered when the data is being imported            -->
        <!-- The setting will not affect content that is already in the database      -->
        <!-- To update previously imported files: remove from the DB &amp; add them again -->
        <map from="ogg"  to="application/ogg"/>
        <map from="mp3"  to="audio/mpeg"/>
        <map from="flac" to="audio/x-flac"/>
        <map from="wav"  to="audio/L16;rate=44100;channels=2"/>
        <map from="mkv"  to="video/x-matroska"/>
        <map from="ts"   to="video/mp2t"/>
        <map from="m2ts" to="video/mp2t"/>
        <map from="mts"  to="video/mp2t"/>
        <map from="avi"  to="video/avi"/>
        <map from="mpg"  to="video/mpeg"/>
        <map from="mp4"  to="video/mp4"/>
        <map from="wmv"  to="video/x-ms-wmv"/>
        <map from="mov"  to="video/x-quicktime"/>
        <map from="srt"  to="video/subtitle"/>
      </extension-mimetype>
      <mimetype-upnpclass>
        <map from="audio/*" to="object.item.audioItem.musicTrack"/>
        <map from="video/*" to="object.item.videoItem"/>
        <map from="image/*" to="object.item.imageItem.photo"/>
      </mimetype-upnpclass>
      <mimetype-contenttype>
        <treat mimetype="application/ogg"  as="ogg"/>
        <treat mimetype="audio/mpeg"       as="mp3"/>
        <treat mimetype="audio/x-flac"     as="flac"/>
        <treat mimetype="audio/x-wav"      as="pcm"/>
        <treat mimetype="audio/L16"        as="pcm"/>
        <treat mimetype="image/jpeg"       as="jpg"/>
        <treat mimetype="video/x-msvideo"  as="avi"/>
        <treat mimetype="video/divx"       as="avi"/>
        <treat mimetype="video/x-matroska" as="mkv"/>
        <treat mimetype="video/mp4"        as="mp4"/>
      </mimetype-contenttype>
    </mappings>
  </import>
  <transcoding enabled="no">
   <mimetype-profile-mappings>
      <transcode mimetype="audio/x-flac"      using="flac2pcm"/>
      <transcode mimetype="audio/mpeg"        using="mpeg2pcm"/>
      <transcode mimetype="application/ogg"   using="video2mpeg"/>
      <transcode mimetype="video/avi"         using="video2mpeg"/>
      <transcode mimetype="video/mp2t"        using="video2mpeg"/>
      <transcode mimetype="video/x-msvideo"   using="video2mpeg"/>
      <transcode mimetype="video/mp4"         using="video2mpeg"/>
      <transcode mimetype="video/x-matroska"  using="video2mpeg"/>
      <transcode mimetype="video/x-quicktime" using="video2mpeg"/>
   </mimetype-profile-mappings>
   <profiles>
      <profile name="video2mpeg" enabled="yes" type="external">
        <mimetype>video/mpeg</mimetype>
        <accept-url>no</accept-url>
        <first-resource>yes</first-resource>
        <hide-original-resource>yes</hide-original-resource>
        <accept-ogg-theora>yes</accept-ogg-theora>
        <sample-frequency>48000</sample-frequency>
        <audio-channels>2</audio-channels>
        <agent command="mencoder"
          arguments="%in -oac lavc -ovc lavc -of mpeg -lavcopts
          vcodec=mpeg2video:keyint=1:vbitrate=200000:vrc_maxrate=9000:vrc_buf_size=1835:acodec=mp2
          -mpegopts muxrate=12000 -vf harddup -o %out"/>
        <buffer size="10485760" chunk-size="262144" fill-size="524288"/>
      </profile>
      <profile name="mpeg2pcm" enabled="yes" type="external">
        <mimetype>audio/L16</mimetype>
        <accept-url>no</accept-url>
        <first-resource>yes</first-resource>
        <hide-original-resource>yes</hide-original-resource>
        <accept-ogg-theora>no</accept-ogg-theora>
        <sample-frequency>44100</sample-frequency>
        <audio-channels>2</audio-channels>
        <agent command="ffmpeg"
          arguments="-i %in -acodec pcm_s16be -ab 192k -ar 44100 -ac 2 -f s16be -y %out"/>
        <buffer size="1048576" chunk-size="131072" fill-size="262144"/>
      </profile>
      <profile name="flac2pcm" enabled="yes" type="external">
        <mimetype>audio/L16</mimetype>
        <accept-url>no</accept-url>
        <first-resource>yes</first-resource>
        <hide-original-resource>yes</hide-original-resource>
        <accept-ogg-theora>no</accept-ogg-theora>
        <sample-frequency>source</sample-frequency>
        <audio-channels>source</audio-channels>
        <agent command="flac"
          arguments="-dfs --force-raw-format --endian=big --sign=signed -o %out %in"/>
        <buffer size="1048576" chunk-size="131072" fill-size="262144"/>
      </profile>
   </profiles>
  </transcoding>
</config>
  • Change the ownership of the files
cd /opt 
chown -R ofguest:ofguest mediatomb
  • Add the multicast route, and set the interface accordingly : 
route add -net 239.0.0.0 netmask 255.0.0.0 eth0
ifconfig eth0 allmulti multicast
  • And then finally, to start it up, just head on over to /opt/mediatomb and run
./mediatomb.sh
  • This will dump log info to std out.  This service can also be run in daemon mode, with dedicated logging - but I'm not quite there yet.

 

Tuning / Customization

 

There really isn't a lot of tuning, but in the event that the need arises, here are some good documentation links :

Tag page
You must login to post a comment.