MediaTomb
From Gentoo Linux Wiki
Contents |
[edit] Introduction
MediaTomb is an open source (GPL) UPnP MediaServer with a nice web user interface. It allows you to stream your digital media through your home network and access it on a variety of UPnP compatible devices.
[edit] Preparation
[edit] Kernel Configuration
[edit] Inotify
MediaTomb supports Inotify which is a file-monitoring mechanism that allows MediaTomb to be notified about changes to files immediately. For more information, please consult Section 2.1.5 of the MediaTomb User Interface documentation.
- To enable Inotify support, build your kernel with the following options.
| Linux Kernel Configuration: Inotify |
File systems ---> [*] Inotify support for userspace |
[edit] Package Configuration
[edit] Configure the USE Flags
| USE | Description | Recommended |
| curl | Enables proxy support for transcoders (i.e. FFmpeg) that do not support URLs. | Yes |
| debug | Enables debug output support. | - |
| exif | Enables image (EXIF) metadata extraction support. | Yes |
| ffmpeg | Enables audio and video metadata extraction and FourCC processing support. | Yes |
| javascript | Enables SpiderMonkey JavaScript engine support. If this USE flag is enabled, a virtual layout based on the extracted metadata will be created. | Yes |
| libextractor | Enables audio, image and video metadata extraction support. If this USE flag is enabled, media import speed will be slowed considerably. | No |
| mysql | Enables MySQL backend support. If this USE flag is disabled, SQLite will be used by default. | - |
| taglib | Enables audio metadata extraction support. If this USE flag is disabled, id3lib will be used by default. | Yes |
[edit] Installation
- To install MediaTomb:
[edit] Configuration
[edit] Network Interface
- To configure the network interface, set the MEDIATOMB_INTERFACE variable to the interface that you want MediaTomb to bind to.
MEDIATOMB_INTERFACE="eth0"
[edit] MySQL
- To enable MySQL support, set the <mysql> tag enabled attribute to yes.
<mysql enabled="yes">
- Set the <sqlite3> tag enabled attribute to no.
<sqlite3 enabled="no">
- Specify values for the <host>, <database>, <username> and <password> tags.
<host>host</host>
<database>database</database>
<username>username</username>
<password>password</password>
- Log-in to MySQL and create the MediaTomb database and user, using the host, database, username and password values specified in the MediaTomb configuration file.
mysql> CREATE DATABASE database; mysql> GRANT ALL ON database.* TO 'username'@'host' IDENTIFIED BY 'password';
[edit] Transcoding
MediaTomb allows you to transcode unsupported media files to formats that are supported by your UPnP device. The following configuration uses VLC to transcode FLAC, Flash, Theora and Vorbis files. For more information, please consult section 6.3 of the MediaTomb documentation.
[edit] Edit the Configuration File
- To enable transcoding support, add the following section in between the </import> and </config> tags.
<transcoding enabled="yes">
<mimetype-profile-mappings>
<transcode mimetype="application/ogg" using="audio2pcm"/>
<transcode mimetype="application/ogg" using="video2mpeg"/>
<transcode mimetype="audio/x-flac" using="audio2pcm"/>
<transcode mimetype="video/x-flv" using="video2mpeg"/>
</mimetype-profile-mappings>
<profiles>
<profile name="audio2pcm" enabled="yes" type="external">
<mimetype>audio/L16</mimetype>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<accept-ogg-theora>no</accept-ogg-theora>
<agent command="/usr/local/bin/mediatomb-audio2pcm" arguments="%in %out"/>
<buffer size="1048576" chunk-size="131072" fill-size="262144"/>
</profile>
<profile name="video2mpeg" enabled="yes" type="external">
<mimetype>video/mpeg</mimetype>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="/usr/local/bin/mediatomb-video2mpeg" arguments="%in %out"/>
<buffer size="10485760" chunk-size="262144" fill-size="524288"/>
</profile>
</profiles>
</transcoding>
- For every additional mimetype that requires transcoding, add the following section in between the <mimetype-profile-mappings> and </mimetype-profile-mappings> tags and substitute mimetype and profile with the appropriate values e.g. <transcode mimetype="video/quicktime" using="video2mpeg"/>
<transcode mimetype="mimetype" using="profile"/>
[edit] Select the Transcoder
MediaTomb's transcoding support is very flexible and any application capable of transcoding can be used. For more information, please consult the MediaTomb Transcoding documentation.
[edit] VLC
- To enable VLC audio transcoding, create the following script.
#!/bin/bash
VLC_PATH="/usr/bin/vlc"
INPUT="$1"
OUTPUT="$2"
AUDIO_CODEC="s16b"
AUDIO_BITRATE="192"
AUDIO_SAMPLERATE="44100"
AUDIO_CHANNELS="2"
FORMAT="raw"
exec "${VLC_PATH}" "${INPUT}" -I dummy --sout="#transcode{acodec=${AUDIO_CODEC},\
ab=${AUDIO_BITRATE},samplerate=${AUDIO_SAMPLERATE},channels=${AUDIO_CHANNELS}}:\
standard{access=file,mux=${FORMAT},dst=${OUTPUT}}" vlc://quit
- Make the script executable.
- Set the audio2pcm profile <accept-url> tag to yes.
<accept-url>yes</accept-url>
- To enable VLC video transcoding, create the following script.
#!/bin/bash
VLC_PATH="/usr/bin/vlc"
INPUT="$1"
OUTPUT="$2"
VIDEO_CODEC="mp2v"
VIDEO_BITRATE="4096"
VIDEO_FRAMERATE="25"
AUDIO_CODEC="mpga"
AUDIO_BITRATE="192"
AUDIO_SAMPLERATE="48000"
AUDIO_CHANNELS="2"
FORMAT="ps"
exec "${VLC_PATH}" "${INPUT}" -I dummy --sout="#transcode{vcodec=${VIDEO_CODEC},\
vb=${VIDEO_BITRATE},fps=${VIDEO_FRAMERATE},acodec=${AUDIO_CODEC},ab=${AUDIO_BITRATE},\
samplerate=${AUDIO_SAMPLERATE},channels=${AUDIO_CHANNELS},audio-sync,soverlay}:\
standard{access=file,mux=${FORMAT},dst=${OUTPUT}}" vlc://quit
- Make the script executable.
- Set the video2mpeg profile <accept-url> tag to yes.
<accept-url>yes</accept-url>
- Install VLC.
[edit] FFmpeg
- To enable FFmpeg audio transcoding, create the following script.
#!/bin/bash
FFMPEG_PATH="/usr/bin/ffmpeg"
INPUT="$1"
OUTPUT="$2"
AUDIO_CODEC="pcm_s16be"
AUDIO_BITRATE="192k"
AUDIO_SAMPLERATE="44100"
AUDIO_CHANNELS="2"
FORMAT="s16be"
exec "${FFMPEG_PATH}" -i "${INPUT}" -acodec ${AUDIO_CODEC} -ab ${AUDIO_BITRATE} \
-ar ${AUDIO_SAMPLERATE} -ac ${AUDIO_CHANNELS} -f ${FORMAT} -y "${OUTPUT}"
- Make the script executable.
- Set the audio2pcm profile <accept-url> tag to no.
<accept-url>no</accept-url>
- To enable FFmpeg video transcoding, create the following script.
#!/bin/bash
FFMPEG_PATH="/usr/bin/ffmpeg"
INPUT="$1"
OUTPUT="$2"
VIDEO_CODEC="mpeg2video"
VIDEO_BITRATE="4096k"
VIDEO_FRAMERATE="25"
AUDIO_CODEC="mp2"
AUDIO_BITRATE="192k"
AUDIO_SAMPLERATE="48000"
AUDIO_CHANNELS="2"
AUDIO_SYNC="1"
FORMAT="dvd"
THREADS="2"
exec "${FFMPEG_PATH}" -i "${INPUT}" -vcodec ${VIDEO_CODEC} -b ${VIDEO_BITRATE} \
-r ${VIDEO_FRAMERATE} -acodec ${AUDIO_CODEC} -ab ${AUDIO_BITRATE} -ar ${AUDIO_SAMPLERATE} \
-ac ${AUDIO_CHANNELS} -async ${AUDIO_SYNC} -f ${FORMAT} -threads ${THREADS} -y "${OUTPUT}"
- Make the script executable.
- Set the video2mpeg profile <accept-url> tag to no.
<accept-url>no</accept-url>
- Install FFmpeg.
[edit] PlayStation 3
- To enable PlayStation 3 support, set the <protocolInfo> tag extend attribute to yes.
<protocolInfo extend="yes"/>
[edit] DivX
- To enable PlayStation 3 DivX support, add the following section in between the <extension-mimetype ignore-unknown="no"> and </extension-mimetype> tags.
<map from="avi" to="video/divx"/>
- Add the following section in between the <mimetype-contenttype> and </mimetype-contenttype> tags.
<treat mimetype="video/divx" as="avi"/>
[edit] Video Thumbnails
[edit] MediaTomb 0.11.0
- To enable video thumbnail support, enable transcoding and add the following section in between the <profiles> and </profiles> tags.
<profile name="video2jpeg" enabled="yes" type="external">
<mimetype>image/jpeg</mimetype>
<accept-url>no</accept-url>
<thumbnail>yes</thumbnail>
<resolution>160x160</resolution>
<agent command="ffmpegthumbnailer" arguments="-i %in -o %out -s 160"/>
<buffer size="524288" chunk-size="512" fill-size="1024"/>
</profile>
- For every mimetype that requires video thumbnails, add the following section in between the <mimetype-profile-mappings> and </mimetype-profile-mappings> tags and substitute mimetype with the appropriate value e.g. <transcode mimetype="video/quicktime" using="video2jpeg"/>
<transcode mimetype="mimetype" using="video2jpeg"/>
- If you have a DLNA compliant device that supports video thumbnails (i.e. PlayStation 3), set the <protocolInfo> tag extend attribute to yes.
<protocolInfo extend="yes"/>
- Install FFmpegThumbnailer.
[edit] MediaTomb 0.12.0 (SVN)
- To enable video thumbnail support, set the <ffmpegthumbnailer> tag enabled attribute to yes.
<ffmpegthumbnailer enabled="yes">
- If you want to overlay a filmstrip border on the generated thumbnail, set the <filmstrip-overlay> tag to yes.
<filmstrip-overlay>yes</filmstrip-overlay>
- If you have a DLNA compliant device that supports video thumbnails (i.e. PlayStation 3), set the <protocolInfo> tag extend attribute to yes.
<protocolInfo extend="yes"/>
[edit] Raw Images
- To enable (Canon CR2 and Nikon NEF) raw image support, add the following section in between the <extension-mimetype ignore-unknown="no"> and </extension-mimetype> tags.
<map from="cr2" to="image/raw"/>
<map from="nef" to="image/raw"/>
- For every additional raw image format, add the following section in between the <extension-mimetype ignore-unknown="no"> and </extension-mimetype> tags and substitute extension with the appropriate value e.g. <map from="kdc" to="image/raw"/>
<map from="extension" to="image/raw"/>
- Enable transcoding and add the following section in between the <profile> and </profile> tags.
<profile name="raw2jpeg" enabled="yes" type="external">
<mimetype>image/jpeg</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<agent command="/usr/local/bin/mediatomb-raw2jpeg" arguments="%in %out"/>
<buffer size="524288" chunk-size="512" fill-size="1024"/>
</profile>
- Add the following section in between the <mimetype-profile-mappings> and </mimetype-profile-mappings> tags.
<transcode mimetype="image/raw" using="raw2jpeg"/>
- Create the following script.
#!/bin/bash
DCRAW_PATH="/usr/bin/dcraw"
INPUT="$1"
OUTPUT="$2"
exec "${DCRAW_PATH}" -e -c "${INPUT}" > "${OUTPUT}"
- Install dcraw.
[edit] Starting
- To start MediaTomb:
- To start MediaTomb at boot:
[edit] Complete Working Setup
This applies to 0.12.0, which includes built-in video thumbnail support.
The following files and configuration file work with a PlayStation3(r), with the following media playing
- mp3/aac/m4a (this includes iTunes audio files)
- avi divx videos
- wmv (assuming enabled in PS3)
- JPEG images
- Canon Raw CR2 images
Manually edit values identified by ##Set this##, as required.
<?xml version="1.0" encoding="UTF-8"?>
<config version="1" xmlns="http://mediatomb.cc/config/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/1 http://mediatomb.cc/config/1.xsd">
<server>
<ui enabled="yes">
<accounts enabled="no" session-timeout="30">
<account user="mediatomb##Set this##" password="mediatomb##Set this##"/>
</accounts>
</ui>
<name>Lyalls Media</name>
<udn></udn>
<home>/var/lib/mediatomb</home>
<webroot>/usr/share/mediatomb/web</webroot>
<storage>
<sqlite3 enabled="no"> <!-- set to yes if not using MySQL -->
<database-file>mediatomb.db</database-file>
</sqlite3>
<mysql enabled="yes">
<host>localhost</host>
<database>mediatomb##Set this##</database>
<username>mediatomb##Set this##</username>
<password>mediatomb##Set this##</password>
</mysql>
</storage>
<protocolInfo extend="yes"/>
<pc-directory upnp-hide="no"/>
<extended-runtime-options> <!-- 0.1.12 upwards -->
<ffmpegthumbnailer enabled="yes">
<thumbnail-size>160</thumbnail-size>
<seek-percentage>10</seek-percentage>
<filmstrip-overlay>no</filmstrip-overlay>
<workaround-bugs>no</workaround-bugs>
<image-quality>8</image-quality>
</ffmpegthumbnailer>
<mark-played-items enabled="no" suppress-cds-updates="yes">
<string mode="prepend">*</string>
</mark-played-items>
<lastfm enabled="no">
<username>username##Set this##</username>
<password>password##Set this##</password>
</lastfm>
</extended-runtime-options> </server>
<import hidden-files="no">
<scripting script-charset="UTF-8">
<common-script>/usr/share/mediatomb/js/common.js</common-script>
<playlist-script>/usr/share/mediatomb/js/playlists.js</playlist-script>
<virtual-layout type="builtin">
<import-script>/usr/share/mediatomb/js/import.js</import-script>
</virtual-layout>
</scripting>
<mappings>
<extension-mimetype ignore-unknown="no">
<map from="mp3" to="audio/mpeg"/>
<map from="m4a" to="audio/mp4"/>
<map from="m4v" to="video/mp4"/>
<map from="ogg" to="application/ogg"/>
<map from="asf" to="video/x-ms-asf"/>
<map from="asx" to="video/x-ms-asf"/>
<map from="wma" to="audio/x-ms-wma"/>
<map from="wax" to="audio/x-ms-wax"/>
<map from="wmv" to="video/x-ms-wmv"/>
<map from="wvx" to="video/x-ms-wvx"/>
<map from="wm" to="video/x-ms-wm"/>
<map from="wmx" to="video/x-ms-wmx"/>
<map from="m3u" to="audio/x-mpegurl"/>
<map from="pls" to="audio/x-scpls"/>
<map from="flv" to="video/x-flv"/>
<map from="avi" to="video/divx"/>
<map from="cr2" to="image/raw"/>
<map from="nef" to="image/raw"/>
</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"/>
</mimetype-upnpclass>
<mimetype-contenttype>
<treat mimetype="audio/mpeg" as="mp3"/>
<treat mimetype="application/ogg" as="ogg"/>
<treat mimetype="audio/x-flac" as="flac"/>
<treat mimetype="image/jpeg" as="jpg"/>
<treat mimetype="audio/x-mpegurl" as="playlist"/>
<treat mimetype="audio/x-scpls" as="playlist"/>
<treat mimetype="audio/x-wav" as="pcm"/>
<treat mimetype="audio/L16" as="pcm"/>
<treat mimetype="video/x-msvideo" as="avi"/>
<treat mimetype="video/divx" as="avi"/>
</mimetype-contenttype>
</mappings>
</import>
<transcoding enabled="yes">
<mimetype-profile-mappings>
<transcode mimetype="application/ogg" using="audio2pcm"/>
<transcode mimetype="application/ogg" using="video2mpeg"/>
<transcode mimetype="audio/x-flac" using="audio2pcm"/>
<transcode mimetype="video/x-flv" using="video2mpeg"/>
<transcode mimetype="video/quicktime" using="video2mpeg"/>
<transcode mimetype="video/x-flv" using="video2jpeg"/>
<transcode mimetype="video/quicktime" using="video2jpeg"/>
<transcode mimetype="video/divx" using="video2jpeg"/>
<transcode mimetype="video/x-ms-asf" using="video2jpeg"/>
<transcode mimetype="video/x-ms-wmf" using="video2jpeg"/>
<transcode mimetype="image/raw" using="raw2jpeg"/>
</mimetype-profile-mappings>
<profiles>
<profile name="audio2pcm" enabled="yes" type="external">
<mimetype>audio/L16</mimetype>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<accept-ogg-theora>no</accept-ogg-theora>
<agent command="/usr/local/bin/mediatomb-audio2pcm" arguments="%in %out"/>
<buffer size="1048576" chunk-size="131072" fill-size="262144"/>
</profile>
<profile name="video2mpeg" enabled="yes" type="external">
<mimetype>video/mpeg</mimetype>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="/usr/local/bin/mediatomb-video2mpeg" arguments="%in %out"/>
<buffer size="10485760" chunk-size="262144" fill-size="524288"/>
</profile>
<!-- Required for 0.11.0
<profile name="video2jpeg" enabled="yes" type="external">
<mimetype>image/jpeg</mimetype>
<accept-url>no</accept-url>
<thumbnail>yes</thumbnail>
<resolution>160x160</resolution>
<agent command="ffmpegthumbnailer" arguments="-i %in -o %out -s 160"/>
<buffer size="524288" chunk-size="512" fill-size="1024"/>
</profile>
-->
<profile name="raw2jpeg" enabled="yes" type="external">
<mimetype>image/jpeg</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<agent command="/usr/local/bin/mediatomb-raw2jpeg" arguments="%in %out"/>
<buffer size="524288" chunk-size="512" fill-size="1024"/>
</profile>
</profiles>
</transcoding>
</config>