Guia de Instalação do Mediatomb v0.1

16
Pag. 1 de 16 Guia de Instalação do MediaTomb Autor: Alexsander Loula ([email protected]) Data: 14/07/2010 Versão: 0.1 1. Introdução O MediaTomb é um servidor UPnP de código aberto (GPL) que permite fazer streaming de mídia digital (vídeo, áudio, foto) via rede. Ele é compatível com uma grande variedade de dispositivos compatíveis com o UPnP, como: PS3, XBOX 360, TV, Receiver, etc. A lista completa de dispositivos testados pode ser encontrada aqui: http://mediatomb.cc/pages/devices Seguem abaixo algumas características do MediaTomb: Extração do metadata de arquivos MP3, OGG, FLAC, JPEG, etc; Suporta thumbnail EXIF; Definição de layout baseado em scripts customizáveis pelo usuário; Transcodificação de formatos via plugins e scripts. 2. Material utilizado Segue abaixo o material utilizado para os testes: 01 - Computador com Ubuntu 9.10 – Server Edition 01 - PS3 (Firmware v3.40) 01 - Router WRT54GL (Firmware Tomato v1.27) 01 - TV/Monitor 01 - Receiver (opcional, o áudio pode ser reproduzido na TV)

Transcript of Guia de Instalação do Mediatomb v0.1

Page 1: Guia de Instalação do Mediatomb v0.1

Pag. 1 de 16

Guia de Instalação do MediaTomb

Autor: Alexsander Loula ([email protected])

Data: 14/07/2010

Versão: 0.1

1. Introdução

O MediaTomb é um servidor UPnP de código aberto (GPL) que permite fazer streaming de

mídia digital (vídeo, áudio, foto) via rede. Ele é compatível com uma grande variedade de

dispositivos compatíveis com o UPnP, como: PS3, XBOX 360, TV, Receiver, etc. A lista completa

de dispositivos testados pode ser encontrada aqui: http://mediatomb.cc/pages/devices

Seguem abaixo algumas características do MediaTomb:

• Extração do metadata de arquivos MP3, OGG, FLAC, JPEG, etc;

• Suporta thumbnail EXIF;

• Definição de layout baseado em scripts customizáveis pelo usuário;

• Transcodificação de formatos via plugins e scripts.

2. Material utilizado

Segue abaixo o material utilizado para os testes:

• 01 - Computador com Ubuntu 9.10 – Server Edition

• 01 - PS3 (Firmware v3.40)

• 01 - Router WRT54GL (Firmware Tomato v1.27)

• 01 - TV/Monitor

• 01 - Receiver (opcional, o áudio pode ser reproduzido na TV)

Page 2: Guia de Instalação do Mediatomb v0.1

Pag. 2 de 16

3. Instalação e configuração

O MediaTomb é muito flexível e customizável, portanto as instruções e configurações

abaixo podem variar de acordo com as necessidades de cada usuário e devem servir somente

como referência.

a. Atualize do sistema operacional e instale as dependências:

sudo password root

su

aptitude update

aptitude safe-upgrade

reboot

/etc/init.d/apparmor stop

update-rc.d -f apparmor remove

aptitude remove --purge apparmor apparmor-utils

aptitude install build-essential autoconf ffmpeg ffmpegthumbnailer \

libavcodec-extra-52 libavdevice-extra-52 libavfilter-extra-0 \

libavformat-extra-52 libavutil-extra-49 libavcodec-dev libavdevice-dev \

libavfilter-dev libavformat-dev libavutil-dev libffmpegthumbnailer-dev \

libdvdread-dev libdvdnav-dev libfaac-dev libfaad-dev libmp3lame-dev \

libmp4v2-dev libopencore-amrnb-dev libopencore-amrwb-dev \

libxvidcore4-dev libx264-dev libexif-dev libtag1-dev \

libcurl4-gnutls-dev libexpat1-dev \

libmagic-dev libmozjs-dev libmysqlclient-dev libsqlite3-dev \

x264 zlib1g-dev subversion

b. Baixe e compile o MediaTomb:

svn co https://svn.mediatomb.cc/svnroot/mediatomb/trunk/mediatomb mediatomb

cd mediatomb

autoreconf -i

./configure --prefix=/usr/local

CONFIGURATION SUMMARY ----

sqlite3 : yes

mysql : yes

libjs : yes

libmagic : yes

inotify : yes

libexif : yes

id3lib : disabled

taglib : yes

libmp4v2 : yes

ffmpeg : yes

ffmpegthumbnailer : yes

lastfmlib : missing

Page 3: Guia de Instalação do Mediatomb v0.1

Pag. 3 de 16

external transcoding : yes

curl : yes

YouTube : yes

Weborama : yes

Apple Trailers : yes

SopCast : disabled

libextractor : disabled

db-autocreate : yes

make

make install

adduser --add_extra_groups --disabled-login --shell /usr/sbin/nologin

mediatomb

sudo -u mediatomb -s -H

c. Execute o MediaTomb:

mediatomb

MediaTomb UPnP Server version 0.12.0 - http://mediatomb.cc/

==========================================================================

Copyright 2005-2008 Gena Batsyan, Sergey Bostandzhyan, Leonhard Wimmer.

MediaTomb is free software, covered by the GNU General Public License version

2

2010-02-04 14:36:08 INFO: MediaTomb configuration was created in:

/home/mediatomb/.mediatomb/config.xml

2010-02-04 14:36:08 INFO: Loading configuration from:

/home/mediatomb/.mediatomb/config.xml

2010-02-04 14:36:08 INFO: UUID generated: 39f7268a-f88f-418a-80d7-

99c4233e9dd7

2010-02-04 14:36:08 INFO: Checking configuration...

2010-02-04 14:36:08 INFO: Setting filesystem import charset to UTF-8

2010-02-04 14:36:08 INFO: Setting metadata import charset to UTF-8

2010-02-04 14:36:08 INFO: Setting playlist charset to UTF-8

2010-02-04 14:36:08 WARNING: You enabled the YouTube feature, which allows

You to watch YouTube videos on your UPnP device!

Please check http://www.youtube.com/t/terms

By using this feature you may be violating

YouTube service terms and conditions!

2010-02-04 14:36:08 INFO: Configuration check succeeded.

2010-02-04 14:36:09 WARNING: Sqlite3 database seems to be corrupt or doesn't

exist yet.

2010-02-04 14:36:09 INFO: no sqlite3 backup is available or backup is

corrupt. automatically creating database...

2010-02-04 14:36:09 INFO: database created successfully.

2010-02-04 14:36:09 INFO: Initialized port: 49152

Page 4: Guia de Instalação do Mediatomb v0.1

Pag. 4 de 16

2010-02-04 14:36:09 INFO: Server bound to: 192.168.1.100

2010-02-04 14:36:10 INFO: MediaTomb Web UI can be reached by following

this link:

2010-02-04 14:36:10 INFO: http://192.168.1.100:49152/

Com o MediaTomb sendo executado, acesse a interface WEB através de algum navegador

(http:// 192.168.1.100:49152):

Verifique no PS3 se o mesmo pode ser encontrado em Music, Video e Photo:

d. Configure o MediaTomb para execução automática:

Edite do arquivo ‘/etc/default/mediatomb’ conforme abaixo:

# Set whether the daemon should be started. Set this value to anything

# but 'yes' to enable the daemon

NO_START="no"

# Additional options that are passed to the daemon.

Page 5: Guia de Instalação do Mediatomb v0.1

Pag. 5 de 16

# Vai fazer o bind na porta 50500

OPTIONS="-p 50500"

# The network interface for MediaTomb to bind to and for which the multicast

# routing entry should be added; "" if the route shouldn't be added at all.

# For example: INTERFACE="eth0"

INTERFACE="eth0"

# The route command and arguments to be used if INTERFACE is defined.

# These variables should normally be left unmodified.

ROUTE_ADD="/sbin/route add -net 239.0.0.0 netmask 255.0.0.0"

ROUTE_DEL="/sbin/route del -net 239.0.0.0 netmask 255.0.0.0"

# The user and group that MediaTomb should be run as.

USER="mediatomb"

GROUP="mediatomb"

Crie o script de inicialização:

vi /etc/init.d/mediatomb

Copie o conteúdo abaixo e cole no novo arquivo ‘/etc/init.d/mediatomb’:

#! /bin/sh

#

# MediaTomb initscript

#

# Original Author: Tor Krill <[email protected]>.

# Modified by: Leonhard Wimmer <[email protected]>

# Modified again by Andres Mejia <[email protected]> to

# base it off of /etc/init.d/skeleton

# Modified again by Flexion.Org <[email protected]> to

# reference /usr/local/ and ~/ for a simple from source build

#

#

### BEGIN INIT INFO

# Provides: mediatomb

# Required-Start: $all

# Required-Stop: $all

# Should-Start: $all

# Should-Stop: $all

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: upnp media server

### END INIT INFO

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script

PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin

Page 6: Guia de Instalação do Mediatomb v0.1

Pag. 6 de 16

DESC="upnp media server"

NAME=mediatomb

DAEMON=/usr/local/bin/$NAME

PIDFILE=/var/run/$NAME.pid

LOGFILE=/var/log/$NAME.log

SCRIPTNAME=/etc/init.d/$NAME

DEFAULT=/etc/default/$NAME

# Exit if the package is not installed

[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present

[ -r $DEFAULT ] && . $DEFAULT

# Load the VERBOSE setting and other rcS variables

[ -f /etc/default/rcS ] && . /etc/default/rcS

# Define LSB log_* functions.

# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.

. /lib/lsb/init-functions

# Start the daemon if NO_START is disabled in DEFAULT

if [ "$NO_START" = "yes" ]; then

test "$1" = "start" && \

{

log_warning_msg "$NAME: Not starting $DESC."

log_warning_msg "$NAME: Disabled in $DEFAULT."

}

exit 0

fi

# Run as root if USER not specified

if [ ! $USER ]; then

USER=root

fi

# Check for an invalid user or one without a home directory

eval USERHOME=~$USER

if [ "${USERHOME#/}" = "${USERHOME}" ]; then

log_failure_msg "$NAME: The user '$USER' specified in $DEFAULT is

invalid."

exit 1

fi

if [ "$INTERFACE" != "" ] ; then

INTERFACE_ARG="-e $INTERFACE"

else

INTERFACE_ARG=""

fi

Page 7: Guia de Instalação do Mediatomb v0.1

Pag. 7 de 16

DAEMON_ARGS="-c /home/$USER/.mediatomb/config.xml -d -u $USER -g $GROUP -P

$PIDFILE -l $LOGFILE $INTERFACE_ARG $OPTIONS"

#

# Function that starts the daemon/service.

#

do_start() {

# Return

# 0 if daemon has been started

# 1 if daemon was already running

# 2 if daemon could not be started

touch $PIDFILE

chown $USER:$GROUP $PIDFILE

touch $LOGFILE

chown $USER:$GROUP $LOGFILE

start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \

--test > /dev/null \

|| return 1

start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --

\

$DAEMON_ARGS \

|| return 2

}

#

# Function that stops the daemon/service.

#

do_stop() {

# Return

# 0 if daemon has been stopped

# 1 if daemon was already stopped

# 2 if daemon could not be stopped

# other if a failure occurred

start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile

$PIDFILE --name $NAME

RETVAL="$?"

[ "$RETVAL" = 2 ] && return 2

rm -f $PIDFILE

return "$RETVAL"

}

#

# Function that sends a SIGHUP to the daemon/service.

#

do_reload() {

start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name

$NAME

return 0

Page 8: Guia de Instalação do Mediatomb v0.1

Pag. 8 de 16

}

case "$1" in

start)

if [ -n "$INTERFACE" ]; then

# try to add the multicast route

if [ "$VERBOSE" != no ]; then

{

log_action_begin_msg \

"$NAME: Trying to add the multicast route"

$ROUTE_ADD $INTERFACE \

&& log_action_end_msg 0

} || {

true && \

log_warning_msg "Failed to add multicast route.

skipping."

}

else

$ROUTE_ADD $INTERFACE >/dev/null 2>&1 || true

fi

fi

log_daemon_msg "Starting $DESC" "$NAME"

do_start

case "$?" in

0) log_end_msg 0 ;;

1) log_warning_msg "$DESC" "'$NAME'" "was already started" ;;

2) log_end_msg 1 ;;

esac

;;

stop)

log_daemon_msg "Stopping $DESC" "$NAME"

do_stop

case "$?" in

0)

log_end_msg 0

if [ -n "$INTERFACE" ]; then

# try to add the multicast route

if [ "$VERBOSE" != no ]; then

{

log_action_begin_msg \

"$NAME: Trying to delete the multicast route"

$ROUTE_DEL $INTERFACE \

&& log_action_end_msg 0

} || {

true && \

log_warning_msg \

"Failed to delete multicast route. skipping."

}

else

Page 9: Guia de Instalação do Mediatomb v0.1

Pag. 9 de 16

$ROUTE_DEL $INTERFACE >/dev/null 2>&1 || true

fi

fi

;;

1) log_warning_msg "$DESC" "'$NAME'" "was already stopped" ;;

2) log_end_msg 1 ;;

esac

;;

reload|force-reload)

log_daemon_msg "Reloading $DESC" "$NAME"

do_reload

log_end_msg $?

;;

restart)

#

# If the "reload" option is implemented, move the "force-

reload"

# option to the "reload" entry above. If not, "force-reload" is

# just the same as "restart".

#

log_daemon_msg "Restarting $DESC" "$NAME"

do_stop

case "$?" in

0|1)

sleep 1

do_start

case "$?" in

0) log_end_msg 0 ;;

1) log_end_msg 1 ;; # Old process is still running

*) log_end_msg 1 ;; # Failed to start

esac

;;

*)

# Failed to stop

log_end_msg 1

;;

esac

;;

*)

#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2

echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2

exit 3

;;

esac

:

Torne-o executável:

chmod 755 /etc/init.d/mediatomb

Page 10: Guia de Instalação do Mediatomb v0.1

Pag. 10 de 16

Teste-o:

/etc/init.d/mediatomb start

* Starting upnp media server mediatomb [ OK ]

Verifique no log se o mesmo está sendo executado:

tail -f -n 20 /var/log/mediatomb.log

Crie um link para o script de inicialização:

update-rc.d mediatomb defaults 95

e. Crie o arquivo de configuração:

Crie o um backup do arquivo original:

mv /home/mediatomb/.mediatomb/config.xml

/home/mediatomb/.mediatomb/config.xml_original

Altere o arquivo ‘/home/mediatomb/.mediatomb/config.xml’ conforme suas necessidades

(principalmente as linhas em negrito):

<?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" show-tooltips="yes">

<accounts enabled="no" session-timeout="30">

<account user="mediatomb" password="mediatomb"/>

</accounts>

</ui>

<name>MediaTomb</name>

<udn>uuid:c539d7b0-e27e-4b06-a47a-a450772c4675</udn>

<home>/home/mediatomb/.mediatomb</home>

<webroot>/usr/local/share/mediatomb/web</webroot>

<storage>

<sqlite3 enabled="yes">

<database-file>mediatomb.db</database-file>

</sqlite3>

<mysql enabled="no">

<host>localhost</host>

<username>user</username>

<password>password</password>

<database>mediatomb</database>

</mysql>

</storage>

<protocolInfo extend="yes"/><!-- For PS3 support change to "yes" -->

<!--

Page 11: Guia de Instalação do Mediatomb v0.1

Pag. 11 de 16

Uncomment the lines below to get rid of jerky avi playback on the

DSM320 or to enable subtitles support on the DSM units

-->

<!--

<custom-http-headers>

<add header="X-User-Agent: redsonic"/>

</custom-http-headers>

<manufacturerURL>redsonic.com</manufacturerURL>

<modelNumber>105</modelNumber>

-->

<!-- Uncomment the line below if you have a Telegent TG100 -->

<!--

<upnp-string-limit>101</upnp-string-limit>

-->

<extended-runtime-options>

<ffmpegthumbnailer enabled="yes">

<thumbnail-size>128</thumbnail-size>

<seek-percentage>10</seek-percentage>

<filmstrip-overlay>yes</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>

<content>video</content>

</mark>

</mark-played-items>

</extended-runtime-options>

</server>

<import hidden-files="no">

<filesystem-charset>UTF-8</filesystem-charset>

<metadata-charset>UTF-8</metadata-charset>

<playlist-charset>UTF-8</playlist-charset>

<autoscan use-inotify="auto">

<directory location="/home/user/music" mode="inotify" recursive="yes"

hidden-files="no"/>

<directory location="/home/user/picture" mode="inotify" recursive="yes"

hidden-files="no"/>

<directory location="/home/user/video" mode="inotify" recursive="yes"

hidden-files="no"/>

</autoscan>

<scripting script-charset="UTF-8">

<common-script>/usr/local/share/mediatomb/js/common.js</common-script>

<playlist-script>/usr/local/share/mediatomb/js/playlists.js</playlist-

script>

<virtual-layout type="js">

Page 12: Guia de Instalação do Mediatomb v0.1

Pag. 12 de 16

<import-script>/usr/local/share/mediatomb/js/import.js</import-

script>

<dvd-script>/usr/local/share/mediatomb/js/import-dvd.js</dvd-script>

</virtual-layout>

</scripting>

<mappings>

<extension-mimetype ignore-unknown="no">

<map from="mpg" to="video/mpeg"/>

<map from="mp3" to="audio/mpeg"/>

<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="mts" to="video/mpeg"/>

<map from="ts" to="video/mpeg"/>

<map from="m2ts" to="video/mpeg"/>

<map from="mkv" to="video/mpeg"/>

<map from="mkv" to="video/x-matroska"/>

<map from="flac" to="audio/x-flac"/>

<map from="mov" to="video/x-quicktime"/>

<map from="vob" to="video/mpeg"/>

<map from="m4v" to="video/mp4"/>

<map from="iso" to="application/x-iso9660-image"/>

</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/mp4" as="mp4"/>

Page 13: Guia de Instalação do Mediatomb v0.1

Pag. 13 de 16

<treat mimetype="audio/mp4" as="mp4"/>

<treat mimetype="video/quicktime" as="mov"/>

<treat mimetype="video/x-quicktime" as="mov"/>

<treat mimetype="application/x-iso9660" as="dvd"/>

<treat mimetype="application/x-iso9660-image" as="dvd"/>

</mimetype-contenttype>

</mappings>

<online-content>

<!-- Make sure to setup a transcoding profile for flv -->

<YouTube enabled="yes" refresh="28800" update-at-start="yes" purge-

after="604800" racy-content="exclude" format="mp4" hd="no">

<favorites user="youtubeuser"/>

<playlists user="youtubeuser"/>

<uploads user="youtubeuser"/>

<standardfeed feed="most_viewed" time-range="today"/>

<standardfeed feed="recently_featured" time-range="today"/>

<standardfeed feed="top_rated" time-range="this_week"/>

</YouTube>

<Weborama enabled="no" refresh="28800" update-at-start="no">

<playlist name="Active" type="playlist" mood="active"/>

<playlist name="Metal" type="playlist">

<filter>

<genres>metal</genres>

</filter>

</playlist>

</Weborama>

<AppleTrailers enabled="yes" refresh="43200" update-at-start="yes"

resolution="640"/>

</online-content>

</import>

<transcoding enabled="yes">

<mimetype-profile-mappings>

<transcode mimetype="application/ogg" using="audio-generic"/>

<transcode mimetype="audio/x-flac" using="audio-generic"/>

<transcode mimetype="video/x-ms-asf" using="video-generic"/>

<transcode mimetype="video/x-flv" using="video-generic"/>

<transcode mimetype="video/x-matroska" using="video-generic"/>

<transcode mimetype="video/mpeg" using="video-generic"/>

<transcode mimetype="video/quicktime" using="video-mov-mpeg"/>

<transcode mimetype="video/x-quicktime" using="video-mov-mpeg"/>

</mimetype-profile-mappings>

<profiles>

<profile name="audio-generic" enabled="yes" type="external" >

<mimetype>audio/L16</mimetype>

<first-resource>yes</first-resource>

<accept-url>yes</accept-url>

<sample-frequency>44100</sample-frequency>

<audio-channels>2</audio-channels>

Page 14: Guia de Instalação do Mediatomb v0.1

Pag. 14 de 16

<hide-original-resource>yes</hide-original-resource>

<agent command="/usr/bin/ffmpeg" arguments="-ac 2 -ar 44100 -y -i

%in -f s16be %out"/>

<buffer size="1048576" chunk-size="4096" fill-size="1024"/>

</profile>

<profile name="video-generic" enabled="yes" type="external">

<avi-fourcc-list mode="ignore">

<fourcc>DX50</fourcc>

<fourcc>DM4V</fourcc>

<fourcc>M4S2</fourcc>

</avi-fourcc-list>

<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-video-generic" arguments="%in

%out"/>

<buffer size="1048576" chunk-size="26214" fill-size="52428"/>

</profile>

<profile name="video-mov-mpeg" 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-mov-mpeg" arguments="%in

%out"/>

<buffer size="262144" chunk-size="6553" fill-size="13108"/>

</profile>

</profiles>

</transcoding>

</config>

f. Crie os scripts para transcodificação:

Crie o arquivo ‘/usr/local/bin/mediatomb-video-generic’ e cole o conteúdo abaixo:

#!/bin/bash

INPUT="$1"

OUTPUT="$2"

VIDEO_CODEC="mpeg2video"

VIDEO_BITRATE="4096k"

AUDIO_CODEC="mp2"

AUDIO_BITRATE="128k"

AUDIO_SAMPLERATE="48000"

AUDIO_CHANNELS="2"

FORMAT="dvd"

Page 15: Guia de Instalação do Mediatomb v0.1

Pag. 15 de 16

exec /usr/bin/ffmpeg -threads 2 -i "${INPUT}" -vcodec ${VIDEO_CODEC} -b

${VIDEO_BITRATE} \

-acodec ${AUDIO_CODEC} -ab ${AUDIO_BITRATE} -ar ${AUDIO_SAMPLERATE} -ac

${AUDIO_CHANNELS} \

-f ${FORMAT} - > "${OUTPUT}" 2>/dev/null

Torne-o executável:

chmod 755 /usr/local/bin/mediatomb-video-generic

Crie o arquivo ‘/usr/local/bin/mediatomb-mov-mpeg’ e cole o conteúdo abaixo:

#!/bin/bash

INPUT="$1"

OUTPUT="$2"

VIDEO_CODEC="mpeg2video"

VIDEO_BITRATE="4096k"

AUDIO_CODEC="mp2"

AUDIO_BITRATE="128k"

AUDIO_SAMPLERATE="48000"

AUDIO_CHANNELS="2"

FORMAT="dvd"

FPS="ntsc"

exec /usr/bin/ffmpeg -threads 2 -i "${INPUT}" -vcodec ${VIDEO_CODEC} -b

${VIDEO_BITRATE} \

-acodec ${AUDIO_CODEC} -ab ${AUDIO_BITRATE} -ar ${AUDIO_SAMPLERATE} -ac

${AUDIO_CHANNELS} \

-f ${FORMAT} -r ${FPS} - > "${OUTPUT}" 2>/dev/null

Torne-o executável:

chmod 755 /usr/local/bin/mediatomb-mov-mpeg

g. Teste o MediaTomb

/etc/init.d/mediatomb restart

tail -f -n 20 /var/log/mediatomb.log

2010-02-02 13:41:58 INFO: Loading configuration from:

/home/mediatomb/.mediatomb/config.xml

2010-02-02 13:41:58 INFO: Checking configuration...

2010-02-02 13:41:58 INFO: Setting filesystem import charset to UTF-8

2010-02-02 13:41:58 INFO: Setting metadata import charset to UTF-8

2010-02-02 13:41:58 INFO: Setting playlist charset to UTF-8

2010-02-02 13:41:58 WARNING: You enabled the YouTube feature, which allows

you

to watch YouTube videos on your UPnP device!

Please check http://www.youtube.com/t/terms

Page 16: Guia de Instalação do Mediatomb v0.1

Pag. 16 de 16

By using this feature you may be violating

YouTube

service terms and conditions!

2010-02-02 13:41:58 INFO: Configuration check succeeded.

2010-02-02 13:41:59 INFO: Initialized port: 50500

2010-02-02 13:41:59 INFO: Server bound to: 192.168.1.100

2010-02-02 13:42:00 INFO: MediaTomb Web UI can be reached by following

this link:

2010-02-02 13:42:00 INFO: http://192.168.1.100:50500/

4. Conclusão

O MediaTomb é uma boa opção como servidor UPnP para streaming de mídia.

Teoricamente ele pode fazer streaming de qualquer formato mídia a partir do uso de scripts,

conforme os exemplos mostrados nesse tutorial. As possibilidades de customização são

imensas e dependem somente da criatividade e necessidade de casa usuário.

5. Referências

http://mediatomb.cc/

http://www.upnp.org/

http://wiki.flexion.org/InstallingMediaTomb012.html