If you plan on using a UPnP server to share media and you have a DirecTV DVR, MediaTomb is a great application to look into. MediaTomb is an open source UPnP server with a basic web interface that allows you to stream digital media to any UPnP compatible device through your home network. One of the really cool aspects of MediaTomb is that it is able to transcode files on-the-fly into a format readable by your UPnP player. While, installation of MediaTomb is pretty straightforward, the configuration can be a bit tricky for those new to Ubuntu and the command line interface (like me).
If you've been following my guide from the beginning, you'll know I'm using Ubuntu Server 10.04 (Lucid Lynx). The following configuration should work on any Ubuntu system post 9.04 (Jaunty), but I've only tested 10.04. Also, since Ubuntu is Debian based, this configuration should work on Debian 6, but you may have to tweak your configuration a bit to get everything working.
First we need to get our system updates then we'll install MediaTomb and the supporting programs used by MediaTomb to transcode your media files on the fly.
sudo apt-get update
sudo apt-get install mediatomb vlc imagemagick vsftpd ffmpeg
At the prompt, answer "y"
As a rule of thumb, any time I change my configuration files, I make a "control" copy that I can revert back to. These control copies have been invaluable when I'm configuring a service and it completely stops working. Using them I can simply start from scratch without uninstalling/removing a program. So, let copy the original MediaTomb config file to preserver a control or backup copy.
sudo cp /etc/mediatomb/config.xml /etc/mediatomb/config.xml.original
Now we need to edit the MediaTomb config file to transcode our media files to a format compatible with our DirecTV DVR. Personally, I like the vim command line text editor. If you prefer another editor such as nano, vi, etc, simply change "vim" to the editor of your choice. Issue the following command to edit the MediaTomb config file.
sudo vim /etc/mediatomb/config.xml
This will open the config file for editing and viewing. Ass you scroll through the file you'll see loads of options your can change and customize to meet your specific needs.
The first thing we are going do is change the display name of our media server. While this doesn't change any functionality of MediaTomb, it is a quick way to ensure the correct configuration file is being used by MediaTomb. To change your MediaTomb's server name look for the line that reads:
<name>MediaTomb</name>
and change it to
<name>YourServerName</name>
Persoanlly, I used "Media Server" but you can call your server whatever your heart desires.
Next we need to add the following lines to the config file under the <extension-mimetype> group. Add the following lines under the default set under this heading.
<map from="ts" to="video/mpeg">
<map from=”vob” to=”video/mpeg”/>
<map from=”wav” to=”audio/wav”/>
<map from=”mpg” to=”video/mpeg”/>
<map from=”aac” to=”audio/x-aac”/>
<map from=”m4a” to=”audio/mp4"/>
<map from=”mkv” to=”video/x-matroska”/>
<map from=”mov” to=”video/x-quicktime”/>
Now we need to define MediaTomb's transcoding responsibilities. To configure for the DirecTV DVR, replace or comment out the original <transcoding> sections with the following configuration lines. Personally, I commented out the original section with <!– –> so I could track the changes I made. If you are commenting out the original transcoding line, look out for the line that reads:
<agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit"/>
The double dashes in front of the "sout" command will end your commenting and give cause errors when starting MediaTomb. To overcome this error simply add a space between the double dashes.
Once the original transcoding section is commented out or removed, add the following lines to your MediaTomb configuration file.
<transcoding enabled="yes">
<mimetype-profile-mappings>
<transcode mimetype="audio/mpeg" using="vlcwav"/>
<transcode mimetype="video/x-flv" using="vlcyoutube"/>
<transcode mimetype="video/mp4" using="transvideo"/>
<transcode mimetype="video/x-quicktime" using="transvideo"/>
<transcode mimetype="application/ogg" using="vlcwav"/>
<transcode mimetype="audio/x-ms-wma" using="vlcwav"/>
<transcode mimetype="audio/x-ms-asf" using="vlcwav"/>
<transcode mimetype="audio/x-flac" using="ffmpegwav"/>
<transcode mimetype="audio/x-aac" using="vlcwav"/>
<transcode mimetype="audio/mp4" using="vlcwav"/>
<transcode mimetype="video/x-msvideo" using="transvideo"/>
<transcode mimetype="video/x-ms-wmv" using="transvideo"/>
<transcode mimetype="video/mpeg" using="mpeg2trans"/>
<transcode mimetype="video/x-matroska" using="transvideo"/>
<transcode mimetype="image/jpeg" using="rescalejpeg"/>
</mimetype-profile-mappings>
<profiles>
<profile name="transvideo" enabled="yes" type="external">
<mimetype>video/mpeg</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<agent command="ffmpegvideo" arguments="%in %out 8300k 256k"/>
<buffer size="57600000" chunk-size="128000" fill-size="10000000"/>
</profile>
<profile name="mpeg2trans" 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>
<agent command="ffmpegvideo" arguments="%in %out 8000k 256k"/>
<buffer size="28800000" chunk-size="512000" fill-size="12000"/>
</profile>
<profile name="ffmpegwav" enabled="yes" type="external">
<use-chunked-encoding>no</use-chunked-encoding>
<mimetype>audio/wav</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<agent command="ffmpegaudio" arguments="%in %out"/>
<buffer size="1048576" chunk-size="131072" fill-size="262144"/>
</profile>
<profile name="vlcwav" enabled="yes" type="external">
<use-chunked-encoding>no</use-chunked-encoding>
<mimetype>audio/wav</mimetype>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<agent command="vlc" arguments="-I dummy %in –sout #transcode{acodec=s16l,ab=192,channels=2}:standard{access=file, mux=wav,dst=%out} vlc:quit"/>
<buffer size="512000" chunk-size="32000" fill-size="64000"/>
</profile>
<profile name="rescalejpeg" enabled="yes" type="external">
<mimetype>image/jpeg</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<accept-ogg-theora>no</accept-ogg-theora>
<agent command="convert" arguments="-size 1080×720 %in -auto-orient -resize 112.5%x100% +profile ‘*’ %out"/> <buffer size="50000" chunk-size="100" fill-size="100"/>
</profile>
<profile name="ffyoutube" enabled="no" type="external">
<mimetype>video/mpeg</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="ffmpegyoutube" arguments="%in %out"/>
<buffer size="14400000" chunk-size="256000" fill-size="80000"/>
</profile>
<profile name="vlcyoutube" 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{vcodec=mp2v,vb=4096,canvas-width=448, canvas-height=252,acodec=mpga,ab=64,samplerate=44100,channels=1}:standard{access=file,mux=ts,dst=%out} vlc:quit"/>
<buffer size="14400000" chunk-size="256000" fill-size="80000"/>
</profile>
</profiles>
</transcoding>
If you read through the script above, you’ll see the configuration calls several additional scripts which we now have to create. If you’ve been following my guide from the beginning, each of the following scripts will be placed in the /usr/bin directory; If your just jumping in to install MediaTomb, your system configuration may be slightly different and you’ll need to adjust fire to suit your system specifics. Also, once the scripts are created, we'll need to apply the proper permissions so the scripts can be run by MediaTomb.
Here are the three additional scripts we are going to create:
- ffmpegaudio
- ffmpegvideo
- ffmpegyoutube
Again, I’ll be using vim, but feel free to you the command line editor of your choice.
To create the ffmpegaudio script file in the /usr/bin directory issue the following command at the prompt.
sudo vim /usr/bin/ffmpegaudio
Next paste the script
here copied from
here.
Now we make the script executable by issuing the following command at the prompt.
sudo chmod a+x /usr/bin/ffmpegaudio
The remaining scripts are created using the same method, but you’ll need to change the respective names. The scripts for ffmpegvideo is
here, and ffmpegyoutube is
here.
Finally, if you read through the ffmpegvideo script, you’ll notice we also need to install Mediainfo which is not in the Ubuntu repositories. Mediainfo is a program which our script uses to gather the technical and tag information about our video files. Installation of Mediainfo is fairly straightforward and can be accomplished by issuing the commands below.
At the time of this writing, the links below were the most up-to-date versions for Ubuntu 10.04 LTS 64bit. If you are using a different version of Ubuntu, find the versions that correspond to your system at
http://mediainfo.sourceforge.net/en/Download/Ubuntu and update the commands below to download/install the correct files.
wget http://downloads.sourceforge.net/zenlib/libzen0_0.4.20-1_amd64.Ubuntu_10.04.deb
wget http://downloads.sourceforge.net/mediainfo/libmediainfo0_0.7.47-1_amd64.Ubuntu_10.04.deb
wget http://downloads.sourceforge.net/mediainfo/mediainfo_0.7.47-1_amd64.Debian_5.deb
sudo dpkg -i libzen0_0.4.20-1_amd64.Ubuntu_10.04.deb
sudo dpkg -i libmediainfo0_0.7.47-1_amd64.Ubuntu_10.04.deb
sudo dpkg -i mediainfo_0.7.47-1_amd64.Debian_5.deb
If you have followed all the directions above, MediaTomb should be ready to serve media to you DirecTV DVR, so all that is left is to restart the MediaTomb service using the following command.
sudo service mediatomb restart
Once the service restarts, open your web browser and navigate to http://YourServerIP:49152
When the page loads, you should see the MediaTomb homepage generated by your server. From here you should be able to navigate to and add in your media files to share across your network.
Hopefully you found the above useful in setting up your MediaTomb UPnP server. While I wish I could claim all the credit for the scripting listed in this post, I can't. All the scripting was pulled from teh MediaTomb site located here:
http://mediatomb.cc/dokuwiki/transcoding:transcoding This site also contains a wealth of information that you can use to further customize and configure your system.