Gerbera
Gerbera is [[Article description::an open source UPnP media server 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.
<nowiki />
[*] 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 the Gerbera trail operations documentation.
<nowiki />
File systems --->
[*] Inotify support for userspace
USE flags
USE flags for net-misc/gerbera UPnP Media Server
curl
|
Support HTTP media sources (e.g. internet radio) |
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 |
exif
|
Add support for reading EXIF headers from JPEG and TIFF images |
exiv2
|
Use media-gfx/exiv2 to extract EXIF information |
ffmpeg
|
Enable ffmpeg/libav-based audio/video codec support |
ffmpegthumbnailer
|
Enable video thumbnail support with media-video/ffmpegthumbnailer |
javascript
|
Enable javascript support |
lastfm
|
Enable last.fm support |
magic
|
Add support for file type detection via magic bytes (usually via libmagic from sys-apps/file) |
matroska
|
Add support for the matroska container format (extensions .mkv, .mka and .mks) |
mysql
|
Use dev-db/mysql as backend rather than SQLite3 |
systemd
|
Enable use of systemd-specific libraries and features like socket activation or session tracking |
taglib
|
Use media-libs/taglib for reading files' metadata |
Emerge
After setting any USE configuration, proceed to install Gerbera:
root #emerge --ask net-misc/gerberaConfiguration
Network
- To set the network interface that Gerbera binds to, add the following to the GERBERA_OPTIONS variable, and substitute
network_interfacewith the appropriate value e.g.GERBERA_OPTIONS="-e eth0"
/etc/conf.d/gerbera<syntaxhighlight lang="bash">GERBERA_OPTIONS="-e network_interface"</syntaxhighlight>
- To set the IP address that Gerbera binds to, add the following to the GERBERA_OPTIONS variable, and substitute
ip_addresswith the appropriate value e.g.GERBERA_OPTIONS="-i 192.168.0.1"
/etc/conf.d/gerbera<syntaxhighlight lang="bash">GERBERA_OPTIONS="-i ip_address"</syntaxhighlight>
MySQL
- To enable MySQL support, set the
enabledattribute toyesfor the<mysql>element:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<mysql enabled="yes"></syntaxhighlight>
- Set the
enabledattribute tonofor the<sqlite3>element:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<sqlite3 enabled="no"></syntaxhighlight>
- Set the
<host>,<database>,<username>and<password>elements:
/etc/gerbera/config.xml<syntaxhighlight lang="xml">
<host>host</host>
<database>database</database>
<username>username</username>
<password>password</password>
</syntaxhighlight>
- Login to MySQL and create the Gerbera database and user, using the
host,database,usernameandpasswordvalues 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 the Gerbera transcoding configuration documentation.
- To enable transcoding support, set the
enabledattribute toyesfor the<transcoding>element:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki /> <transcoding enabled="yes"></syntaxhighlight>
- For every additional mimetype that requires transcoding, add the following section in between the
<mimetype-profile-mappings>and</mimetype-profile-mappings>elements and substitutemimetypeandprofilewith the appropriate values e.g.<transcode mimetype="video/quicktime" using="video2mpeg"/>
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<transcode mimetype="mimetype" using="profile"/></syntaxhighlight>
- Install FFmpeg:
Transcoding support requires the USE flag
encode to be enabled for the media-video/ffmpeg package.root #emerge --ask --noreplace media-video/ffmpegAlternative transcoders
Gerbera's transcoding support is very flexible and any application capable of transcoding can be used. For more information, please consult the Gerbera transcoding documentation.
VLC
Audio
- To enable VLC audio transcoding, replace the
<agent>element for theaudio2pcmprofile with the following:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<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"/></syntaxhighlight>
- Set the
<accept-url>element toyesfor theaudio2pcmprofile:
/etc/gerbera/config.xml<syntaxhighlight lang="xml">
<accept-url>yes</accept-url>
</syntaxhighlight>
Video
- To enable VLC video transcoding, replace the
<agent>element for thevideo2mpegprofile with the following:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<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"/></syntaxhighlight>
- Set the
<accept-url>element toyesfor thevideo2mpegprofile:
/etc/gerbera/config.xml<syntaxhighlight lang="xml">
<accept-url>yes</accept-url>
</syntaxhighlight>
- Install VLC:
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/vlcMPlayer
Video
- To enable MPlayer video transcoding, replace the
<agent>element for thevideo2mpegprofile with the following:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<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"/></syntaxhighlight>
- Set the
<accept-url>element toyesfor thevideo2mpegprofile:
/etc/gerbera/config.xml<syntaxhighlight lang="xml">
<accept-url>yes</accept-url>
</syntaxhighlight>
- Install MPlayer:
Transcoding support requires the USE flag
encode to be enabled for the media-video/mplayer package.root #emerge --ask --noreplace media-video/mplayerDLNA
Gerbera is not a DLNA media server. Gerbera does have partial DLNA support for some DLNA devices e.g. PlayStation 3.
- To enable DLNA support, set the
extendattribute toyesfor the<protocolInfo>element:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<protocolInfo extend="yes"></syntaxhighlight>
- For DLNA enabled TVs (e.g. Samsung), add the following section in between the
<server>and</server>elements:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<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></syntaxhighlight>
Video thumbnails
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
enabledattribute toyesfor the<ffmpegthumbnailer>element:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<ffmpegthumbnailer enabled="yes"></syntaxhighlight>
- To overlay a filmstrip border on the generated thumbnail, set the
<filmstrip-overlay>element toyes:
/etc/gerbera/config.xml<syntaxhighlight lang="xml">
<filmstrip-overlay>yes</filmstrip-overlay>
</syntaxhighlight>
- For DLNA enabled devices that support video thumbnails (e.g. PlayStation 3), set the
extendattribute toyesfor the<protocolInfo>element:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<protocolInfo extend="yes"></syntaxhighlight>
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:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<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></syntaxhighlight>
- Add the following section in between the
<mimetype-profile-mappings>and</mimetype-profile-mappings>elements:
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<transcode mimetype="image/raw" using="raw2jpeg"/></syntaxhighlight>
- 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 substituteextensionwith the appropriate value e.g.<map from="kdc" to="image/raw"/>
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<map from="extension" to="image/raw"/></syntaxhighlight>
- Since dcraw only outputs to stdout, the output will need to be redirected with the following script:
/usr/local/bin/gerbera-raw2jpeg<syntaxhighlight lang="bash">#!/bin/sh
DCRAW_PATH="/usr/bin/dcraw"
INPUT="$1"
OUTPUT="$2"
exec "${DCRAW_PATH}" -e -c "${INPUT}" > "${OUTPUT}"</syntaxhighlight>
- Install dcraw:
root #emerge --ask --noreplace media-gfx/dcrawService
OpenRC
- To start Gerbera:
root #rc-service gerbera start- To start Gerbera at boot:
root #rc-update add gerbera defaultsystemd
Start Gerbera:
root #systemctl start gerberaStart Gerbera at boot:
root #systemctl enable gerberaTroubleshooting
Mimetype mapping
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"/>
/etc/gerbera/config.xml<syntaxhighlight lang="xml"><nowiki />
<map from="extension" to="mimetype"/></syntaxhighlight>
See also
- MiniDLNA — a media server aiming to be DLNA/UPnP-AV compliant.
References
- ↑ seppbiersack. Samsung TV Support, Gerbera GitHub, September 26th, 2018. Retrieved on March 7th, 2019.