Gerbera

From Gentoo Wiki
(Redirected from MediaTomb)
Jump to: navigation, search
Resources

Gerbera is an open source (GPL) UPnP MediaServer that streams digital media through a home network to UPnP compatible devices. Gerbera is based on MediaTomb 0.12.1, which is no longer maintained.

Installation

Kernel

Gerbera requires IP multicast support for automatic discovery by UPnP devices.

KERNEL Enabling IP multicast support
[*] Networking support --->
            Networking options --->
              [*] TCP/IP networking
              [*]   IP: multicasting

Gerbera supports inotify, which is a file-monitoring mechanism that allows Gerbera to be notified about changes to files immediately. For more information, please consult Section 2.1.5 of the MediaTomb User Interface documentation.

KERNEL Enabling inotify support
    File systems --->
      [*] Inotify support for userspace

USE flags

USE flags for net-misc/gerbera UPnP Media Server (Based on MediaTomb)

curl Support YouTube and external media sources (e.g. internet radio) local
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces global
exif Add support for reading EXIF headers from JPEG and TIFF images global
ffmpeg Enable ffmpeg/libav-based audio/video codec support global
ffmpegthumbnailer Enable video thumbnail support with media-video/ffmpegthumbnailer local
javascript Enable javascript support global
lastfm Enable last.fm support local
libav Prefer libav over ffmpeg whenever both are supported global
magic Use libmagic to determine file types local
mysql Use dev-db/mysql as backend rather than SQLite3 local
protocol-extensions Enable partial DLNA support local
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking global
taglib Use media-libs/taglib for reading files' metadata rather than id3lib local

Emerge

After setting any USE configuration, proceed to install Gerbera:

root #emerge --ask net-misc/gerbera

Configuration

Network

  • To set the network interface that Gerbera binds to, add the following to the GERBERA_OPTIONS variable, and substitute network_interface with the appropriate value e.g. GERBERA_OPTIONS="-e eth0"
FILE /etc/conf.d/gerbera
GERBERA_OPTIONS="-e network_interface"
  • To set the IP address that Gerbera binds to, add the following to the GERBERA_OPTIONS variable, and substitute ip_address with the appropriate value e.g. GERBERA_OPTIONS="-i 192.168.0.1"
FILE /etc/conf.d/gerbera
GERBERA_OPTIONS="-i ip_address"

MySQL

Important
MySQL support requires the USE flag mysql to be enabled for the net-misc/gerbera package.
  • To enable MySQL support, set the enabled attribute to yes for the <mysql> element:
FILE /etc/gerbera/config.xml
      <mysql enabled="yes">
  • Set the enabled attribute to no for the <sqlite3> element:
FILE /etc/gerbera/config.xml
      <sqlite3 enabled="no">
  • Set the <host>, <database>, <username> and <password> elements:
FILE /etc/gerbera/config.xml
        <host>host</host>
        <database>database</database>
        <username>username</username>
        <password>password</password>
  • Login to MySQL and create the Gerbera database and user, using the host, database, username and password values set in the Gerbera configuration file:
mysql>CREATE DATABASE database;
mysql>GRANT ALL ON database.* TO 'username'@'host' IDENTIFIED BY 'password';

Transcoding

Gerbera supports transcoding media files to formats that are supported by the UPnP device being used. The default Gentoo configuration file uses FFmpeg to transcode FLAC, Flash, Theora and Vorbis files. For more information, please consult section 6.3 of the MediaTomb documentation.

  • To enable transcoding support, set the enabled attribute to yes for the <transcoding> element:
FILE /etc/gerbera/config.xml
  <transcoding enabled="yes">
  • For every additional mimetype that requires transcoding, add the following section in between the <mimetype-profile-mappings> and </mimetype-profile-mappings> elements and substitute mimetype and profile with the appropriate values e.g. <transcode mimetype="video/quicktime" using="video2mpeg"/>
FILE /etc/gerbera/config.xml
      <transcode mimetype="mimetype" using="profile"/>
  • Install FFmpeg:
Important
Transcoding support requires the USE flag encode to be enabled for the media-video/ffmpeg package.
root #emerge --ask --noreplace media-video/ffmpeg

Alternative transcoders

Gerbera's transcoding support is very flexible and any application capable of transcoding can be used. For more information, please consult the MediaTomb Transcoding documentation.

VLC

Audio

  • To enable VLC audio transcoding, replace the <agent> element for the audio2pcm profile with the following:
FILE /etc/gerbera/config.xml
        <agent command="vlc" arguments="%in -I dummy --sout=#transcode{acodec=s16b,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=raw,dst=%out} vlc://quit"/>
  • Set the <accept-url> element to yes for the audio2pcm profile:
FILE /etc/gerbera/config.xml
        <accept-url>yes</accept-url>

Video

  • To enable VLC video transcoding, replace the <agent> element for the video2mpeg profile with the following:
FILE /etc/gerbera/config.xml
        <agent command="vlc" arguments="%in -I dummy --sout=#transcode{vcodec=mp2v,vb=4096,fps=25,acodec=mpga,ab=192,samplerate=48000,channels=2,audio-sync}:standard{access=file,mux=ps,dst=%out} vlc://quit"/>
  • Set the <accept-url> element to yes for the video2mpeg profile:
FILE /etc/gerbera/config.xml
        <accept-url>yes</accept-url>
  • Install VLC:
Important
Transcoding support requires the USE flags ffmpeg and encode to be enabled for the media-video/vlc package. It also requires the USE flag encode to be enabled for the media-video/ffmpeg package.
root #emerge --ask --noreplace media-video/vlc
MPlayer

Video

  • To enable MPlayer video transcoding, replace the <agent> element for the video2mpeg profile with the following:
FILE /etc/gerbera/config.xml
        <agent command="mencoder" arguments="%in -o %out -ovc lavc -oac lavc -lavcopts vcodec=mpeg2video:vbitrate=4096:vrc_minrate=0:vrc_maxrate=9800:vrc_buf_size=1835:keyint=15:vstrict=0:acodec=mp2:abitrate=192 -vf harddup -af lavcresample=48000:channels=2 -srate 48000 -ofps 25 -of mpeg -mpegopts format=mpeg2:tsaf"/>
  • Set the <accept-url> element to yes for the video2mpeg profile:
FILE /etc/gerbera/config.xml
        <accept-url>yes</accept-url>
  • Install MPlayer:
Important
Transcoding support requires the USE flag encode to be enabled for the media-video/mplayer package.
root #emerge --ask --noreplace media-video/mplayer

DLNA

Note
Gerbera is not a DLNA media server. Gerbera does have partial DLNA support for some DLNA devices e.g. PlayStation 3.
Important
DLNA support requires the USE flag protocol-extensions to be enabled for the net-misc/gerbera package.
  • To enable DLNA support, set the extend attribute to yes for the <protocolInfo> element:
FILE /etc/gerbera/config.xml
    <protocolInfo extend="yes">
  • For DLNA enabled TVs (e.g. Samsung), add the following section in between the <server> and </server> elements:
FILE /etc/gerbera/config.xml
    <custom-http-headers>
      <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>
Note
Support for custom headers was added to net-libs/libupnp 1.8, but Gerbera has yet to implement it. This makes Gerbera unsuitable for DLNA devices that require custom header support[1].

Online services

Gerbera supports streaming online content to UPnP devices from services such as YouTube. For more information, please consult Section 6.2.1 of the MediaTomb documentation.

YouTube

Important
YouTube support is currently broken because of server-side changes made by YouTube[2].
Note
The content to be streamed needs to be specified beforehand. The default Gentoo configuration file only specifies sample content. For more information, please consult Section 6.2.2 of the MediaTomb documentation.
  • To enable YouTube support, set the enabled attribute to yes for the <YouTube> element:
FILE /etc/gerbera/config.xml
      <YouTube enabled="yes" refresh="28800" update-at-start="yes" purge-after="604800" racy-content="exclude" format="mp4" hd="no">
  • To enable high definition (if available) YouTube videos, set the hd attribute to yes for the <YouTube> element:
FILE /etc/gerbera/config.xml
      <YouTube enabled="yes" refresh="28800" update-at-start="yes" purge-after="604800" racy-content="exclude" format="mp4" hd="yes">
  • For UPnP devices that do not support MP4 video, enable transcoding and add the following section in between the <mimetype-profile-mappings> and </mimetype-profile-mappings> elements:
FILE /etc/gerbera/config.xml
      <transcode mimetype="video/mp4" using="video2mpeg"/>

Video thumbnails

Important
Video thumbnail support requires the USE flags ffmpeg and ffmpegthumbnailer to be enabled for the net-misc/gerbera package.
  • To enable video thumbnail support, set the enabled attribute to yes for the <ffmpegthumbnailer> element:
FILE /etc/gerbera/config.xml
      <ffmpegthumbnailer enabled="yes">
  • To overlay a filmstrip border on the generated thumbnail, set the <filmstrip-overlay> element to yes:
FILE /etc/gerbera/config.xml
        <filmstrip-overlay>yes</filmstrip-overlay>
  • For DLNA enabled devices that support video thumbnails (e.g. PlayStation 3), set the extend attribute to yes for the <protocolInfo> element:
FILE /etc/gerbera/config.xml
    <protocolInfo extend="yes">

Raw images

  • To enable (Canon CR2 and Nikon NEF) raw image support, enable transcoding and add the following section in between the <profile> and </profile> elements:
FILE /etc/gerbera/config.xml
      <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>
        <use-chunked-encoding>no</use-chunked-encoding>
        <agent command="/usr/local/bin/gerbera-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> elements:
FILE /etc/gerbera/config.xml
      <transcode mimetype="image/raw" using="raw2jpeg"/>
  • For every additional raw image format (supported by dcraw), add the following section in between the <extension-mimetype ignore-unknown="no"> and </extension-mimetype> elements, and substitute extension with the appropriate value e.g. <map from="kdc" to="image/raw"/>
FILE /etc/gerbera/config.xml
        <map from="extension" to="image/raw"/>
  • Since dcraw only outputs to stdout, the output will need to be redirected with the following script:
FILE /usr/local/bin/gerbera-raw2jpeg
#!/bin/sh

DCRAW_PATH="/usr/bin/dcraw"
INPUT="$1"
OUTPUT="$2"

exec "${DCRAW_PATH}" -e -c "${INPUT}" > "${OUTPUT}"
  • Install dcraw:
root #emerge --ask --noreplace media-gfx/dcraw

Service

OpenRC

  • To start Gerbera:
root #rc-service gerbera start
  • To start Gerbera at boot:
root #rc-update add gerbera default

Troubleshooting

Mimetype mapping

Important
After adding or changing a mimetype mapping, media needs to be imported again since mimetype mappings are only set during import.

Gerbera (via libmagic) may identify the mimetype of some files incorrectly. A common case is where videos with the mp4 extension are identified as the mimetype audio/mp4. To override the mimetype returned by libmagic, add the following section in between the <extension-mimetype ignore-unknown="no"> and </extension-mimetype> elements, and substitute extension and mimetype with the appropriate values e.g. <map from="mp4" to="video/mp4"/>

FILE /etc/gerbera/config.xml
        <map from="extension" to="mimetype"/>

References

  1. Stepperer. UE40KU6000UX Samsung TV not detecting a working Gerbera server, Gerbera GitHub, July 20th, 2017. Retrieved on December 2nd, 2017.
  2. Robert. Youtube Question, MediaTomb Forum, December 14th, 2010. Retrieved on June 9th, 2015.