Gentoo Wiki ArchivesGentoo Wiki

MediaTomb

Contents

Introduction

Note: This HOWTO is for MediaTomb 0.11.0.

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.

Preparation

Kernel Configuration

Inotify Support

MediaTomb supports Inotify which is a file-monitoring mechanism that allows MediaTomb to be notified about changes to files immediately. Please consult Section 2.1.5 of the MediaTomb UI documentation for more information.

To enable Inotify support build your kernel with the following options.

Linux Kernel Configuration:
File systems --->
  [*] Inotify file change notification support
  [*]   Inotify support for userspace

Package Configuration

Unmask the Ebuild

Note: You only need to unmask the ebuild if the version of MediaTomb that you want to use has been keyword masked.
# echo "net-misc/mediatomb" >> /etc/portage/package.keywords

Configure the USE Flags

USEDescription
curlEnables support for libcurl. Enable this if you want to transcode online content with transcoders such as FFmpeg that don't support URL's as input. (Recommended)
debugEnables support for debug output. Enable this if you are trying to trace down a bug or a problem.
exifEnables support for libexif. It is used to extract metadata from image files. (Recommended)
expatEnables support for the Expat XML parser. Enable this if you don't want to use the internal XML parser. (Recommended)
ffmpegEnables support for FFmpeg. It is used to extract metadata from video files. (Recommended)
javascriptEnables support for the SpiderMonkey JavaScript engine. It is used to create a virtual container layout based on the metadata extracted from media files. (Recommended)
libextractorEnables support for libextractor. It is used to extract metadata from video files.
mysqlEnables support for the MySQL database engine. Enable this if you don't want to use the default SQLite database engine.
taglibEnables support for TagLib. It is used to extract metadata from audio files. Enable this if you don't want to use id3lib. (Recommended)
  • If you enable the ffmpeg and libextractor USE flags then libextractor support will be disabled.
Note: Make sure to substitute use with the required values e.g. curl exif expat ffmpeg javascript taglib
# echo "net-misc/mediatomb use" >> /etc/portage/package.use

Installation

To install MediaTomb:

# emerge mediatomb

Configuration

Network Interface

Note: Make sure to substitute interface with the network interface that you want MediaTomb to bind to e.g. MEDIATOMB_INTERFACE="wlan0"
File: /etc/conf.d/mediatomb
MEDIATOMB_INTERFACE="interface"

MySQL Support

Note: MySQL support requires that MediaTomb is built with the mysql USE flag enabled.

To enable MySQL support open the MediaTomb configuration file and set the mysql tag enabled attribute to yes.

File: /etc/mediatomb/config.xml
      <mysql enabled="yes">

You need to set the sqlite3 tag enabled attribute to no.

File: /etc/mediatomb/config.xml
      <sqlite3 enabled="no">

You need to specify values for the host, database, username and password tags.

File: /etc/mediatomb/config.xml
        <host>host</host>
        <database>database</database>
        <username>username</username>
        <password>password</password>

You also need to login to MySQL and create the MediaTomb database and user.

Note: Make sure to substitute host, database, username and password with the values you specified in the MediaTomb configuration file.
mysql> CREATE DATABASE database;
mysql> GRANT ALL ON database.* TO 'username'@'host' IDENTIFIED BY 'password';

Transcoding Support

MediaTomb allows you to transcode unsupported media files to formats that are supported by your UPnP device. MediaTomb's transcoding support is very flexible and any application capable of transcoding can be used. The following configuration uses VLC to transcode FLAC, Flash, Theora and Vorbis files. Please consult the MediaTomb Transcoding documentation for more information.

Edit the Configuration File

To enable transcoding support open the MediaTomb configuration file and add the following section in between the </import> and </config> tags.

Note: Updated 2008-07-08
File: /etc/mediatomb/config.xml
  <transcoding enabled="yes">
    <mimetype-profile-mappings>
      <transcode mimetype="application/ogg" using="audio-common"/>
      <transcode mimetype="application/ogg" using="video-common"/>
      <transcode mimetype="audio/x-flac" using="audio-common"/>
      <transcode mimetype="video/x-flv" using="video-common"/>
    </mimetype-profile-mappings>
    <profiles>
      <profile name="audio-common" 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="mediatomb-transcode-audio" arguments="%in %out"/>
        <buffer size="1048576" chunk-size="131072" fill-size="262144"/>
      </profile>
      <profile name="video-common" 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="mediatomb-transcode-video" arguments="%in %out"/>
        <buffer size="10485760" chunk-size="262144" fill-size="524288"/>
      </profile>
    </profiles>
  </transcoding>

You also need to add the following section in between the <mimetype-profile-mappings> and </mimetype-profile-mappings> tags for every additional mimetype that requires transcoding.

Note: Make sure to substitute mimetype and profile with the required values e.g. <transcode mimetype="video/divx" using="video-common"/>
File: /etc/mediatomb/config.xml
      <transcode mimetype="mimetype" using="profile"/>
AVI FourCC Support

MediaTomb allows you to restrict AVI file transcoding to certain FourCC's. There are three FourCC configuration modes: disabled, process and ignore. The disabled mode will transcode all AVI files. The process mode will transcode AVI files that have their FourCC listed. The ignore mode will not transcode AVI files that have their FourCC listed. The following configuration will transcode all AVI files except those with the DX50 FourCC. Please consult Section 3.3 of the MediaTomb Transcoding documentation for more information.

To enable AVI FourCC support open the MediaTomb configuration file and add the following section in between the <profile name="video-common" enabled="yes" type="external"> and </profile> tags.

File: /etc/mediatomb/config.xml
        <avi-fourcc-list mode="ignore">
          <fourcc>DX50</fourcc>
        </avi-fourcc-list>

Create the Transcoding Scripts

VLC Transcoding Scripts
Note: VLC has been reported to output white noise when transcoding FLAC files. Please consider using FFmpeg if you need to transcode FLAC files.

The VLC audio transcoding script will produce a RAW formatted PCM audio stream, while the VLC video transcoding script will produce a PS formatted MPEG-2 video stream. You can adjust the output stream by modifying the relevant transcoding script variables. Please consult Chapter 3 of the VLC Streaming HOWTO for more information.

To enable VLC audio transcoding create the following audio transcoding script.

Note: Updated 2008-07-05
File: /usr/bin/mediatomb-transcode-audio
#!/bin/bash

VLC_PATH="/usr/bin/vlc"
INPUT="$1"
OUTPUT="$2"
AUDIO_CODEC="s16l"
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{mux=${FORMAT},access=file,dst=${OUTPUT}}" vlc:quit >/dev/null 2>&1

You also need to make the audio transcoding script executable.

# chmod +x /usr/bin/mediatomb-transcode-audio

To enable VLC video transcoding create the following video transcoding script.

Note: Updated 2008-07-05
File: /usr/bin/mediatomb-transcode-video
#!/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="44100"
AUDIO_CHANNELS="2"
FORMAT="ps"
SUBTITLE_LANGUAGE="eng"

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},soverlay,audio-sync}:\
standard{mux=${FORMAT},access=file,dst=${OUTPUT}}" --sub-language=${SUBTITLE_LANGUAGE} \
vlc:quit >/dev/null 2>&1
Note: With VLC 0.8.6 it has been reported that the 'mp2v' codec in the above script needs to be changed to 'mpgv' in order for transcoding to work.

You also need to make the video transcoding script executable.

# chmod +x /usr/bin/mediatomb-transcode-video
FFmpeg Transcoding Scripts
Note: If you want to transcode online content such as YouTube with FFmpeg then MediaTomb needs to be built with the curl USE flag enabled. You will also need to set the value of the accept-url tag to no for every transcoding profile that uses FFmpeg. Please consult Section 3.2.4 of the MediaTomb Transcoding documentation for more information.

The FFmpeg audio transcoding script will produce a RAW formatted PCM audio stream, while the FFmpeg video transcoding script will produce a PS formatted MPEG-2 video stream. You can adjust the output stream by modifying the relevant transcoding script variables. Please consult Section 3 of the FFmpeg documentation for more information.

To enable FFmpeg audio transcoding create the following audio transcoding script.

Note: Updated 2008-07-05
File: /usr/bin/mediatomb-transcode-audio
#!/bin/bash

FFMPEG_PATH="/usr/bin/ffmpeg"
INPUT="$1"
OUTPUT="$2"
AUDIO_CODEC="pcm_s16le"
AUDIO_BITRATE="192k"
AUDIO_SAMPLERATE="44100"
AUDIO_CHANNELS="2"
FORMAT="s16le"

exec "${FFMPEG_PATH}" -i "${INPUT}" -acodec ${AUDIO_CODEC} -ab ${AUDIO_BITRATE} \
-ar ${AUDIO_SAMPLERATE} -ac ${AUDIO_CHANNELS} -f ${FORMAT} - > "${OUTPUT}" 2>/dev/null

You also need to make the audio transcoding script executable.

# chmod +x /usr/bin/mediatomb-transcode-audio

To enable FFmpeg video transcoding create the following video transcoding script.

Note: Updated 2008-07-05
File: /usr/bin/mediatomb-transcode-video
#!/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="44100"
AUDIO_CHANNELS="2"
FORMAT="dvd"

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} -f ${FORMAT} - > "${OUTPUT}" 2>/dev/null

You also need to make the video transcoding script executable.

# chmod +x /usr/bin/mediatomb-transcode-video

Install the Transcoder

If you're using the VLC transcoding scripts:

Note: Transcoding support requires that VLC is built with the stream USE flag enabled. It also requires that FFmpeg is built with the encode USE flag enabled. Subtitle support requires that VLC is built with the truetype USE flag enabled.
# emerge vlc

If you're using the FFmpeg transcoding scripts:

Note: Transcoding support requires that FFmpeg is built with the encode USE flag enabled.
# emerge ffmpeg

PlayStation 3 Support

Note: The PlayStation 3 will not play transcoded audio streams as it is not possible to seek streams with an unknown content length. This issue has been fixed in SVN and will be available in MediaTomb 0.12.0.

To enable PlayStation 3 support open the MediaTomb configuration file and set the protocolInfo tag extend attribute to yes.

File: /etc/mediatomb/config.xml
    <protocolInfo extend="yes"/>

PlayStation 3 DivX Support

To enable PlayStation 3 DivX support open the MediaTomb configuration file and add the following section in between the <extension-mimetype ignore-unknown="no"> and </extension-mimetype> tags.

File: /etc/mediatomb/config.xml
        <map from="avi" to="video/divx"/>
        <map from="divx" to="video/divx"/>

You also need to add the following section in between the <mimetype-contenttype> and </mimetype-contenttype> tags.

File: /etc/mediatomb/config.xml
       <treat mimetype="video/divx" as="avi"/>

PlayStation 3 Thumbnail Support

To enable PlayStation 3 thumbnail support open the MediaTomb configuration file and change the <transcoding enabled="no"> to yes, then add the following section in between the <profiles> and </profiles> tags.

Note: Updated 2008-03-03
File: /etc/mediatomb/config.xml
      <profile name="video-thumbnail" enabled="yes" type="external">
        <mimetype>image/jpeg</mimetype>
        <accept-url>yes</accept-url>
        <thumbnail>yes</thumbnail>
        <resolution>128x128</resolution>
        <agent command="ffmpegthumbnailer" arguments="-i %in -o %out -s 128"/>
        <buffer size="524288" chunk-size="512" fill-size="1024"/>
      </profile>

You need to add the following section in between the <mimetype-profile-mappings> and </mimetype-profile-mappings> tags for every mimetype that requires thumbnails.

Note: Make sure to substitute mimetype with the required value e.g. <transcode mimetype="video/divx" using="video-thumbnail"/>
File: /etc/mediatomb/config.xml
      <transcode mimetype="mimetype" using="video-thumbnail"/>

You also need to install FFmpeg Thumbnailer.

# emerge ffmpegthumbnailer

Starting

To start MediaTomb:

# /etc/init.d/mediatomb start

To start MediaTomb at boot:

# rc-update add mediatomb default

See Also

External Links

Retrieved from "http://www.gentoo-wiki.info/MediaTomb"

Last modified: Thu, 11 Sep 2008 11:13:00 +1000 Hits: 38,763

Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.