7

I'd like to use my raspberry pi as media renderer so I can select playlists on my control point to play music from the media server. I've found some questions to gmediarender but no direct answer how to install it. How can I do that in an easy way?

7

Tested on a Raspberry Pi 4B with
Raspbian Buster With Desktop 2020-02-13 updated on 2020-04-18.
Raspbian Buster Lite 2020-02-13 updated on 2020-03-26.
Updates done with sudo apt update && sudo apt full-upgrade && sudo reboot.

With the raspi you should be connected to your local network and to your audio output (earphone, amplifier etc). First you can check your audio output with this small audio file working.wav. Of course you can take any other audio output test.

pi ~$ sudo apt install alsa-utils
pi ~$ aplay working.wav

If you hear that it's working then install gmediarender with needed plugins:

pi ~$ sudo apt install gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-gl gmediarender

Running the test: be sure that you are member of the groups audio and video. You can cancel the test with Ctrl+C.

pi ~$ /usr/bin/gmediarender --friendly-name Test --uuid 42 --gstout-initial-volume-db -20 --logfile /dev/stdout

On your control point (bubbleUPNP or something like this) you should find a renderer named Test. Select it and play music from your media server if you have one. This works on Raspbian Buster Light but on Raspbian Buster With Desktop the debug output on the screen shows that everything should do, but there was no sound to hear. It seems that the Desktop version installs some more additional libraries that confuse gmediarender what output to use. I had to append --gstout-audiosink alsasink to the test call shown above.

I also found a confusing warning:

** (gmediarender:4222): CRITICAL **: 11:38:55.673: file gstdtlsagent.c: line 192 (gst_dtls_agent_init): should not be reached
** (gmediarender:4222): CRITICAL **: 11:38:55.673: gst_dtls_agent_set_property: assertion 'self->priv->ssl_context' failed

With some googling I found that it isn't critical (3) and you can suppress it by setting an empty string to OPENSSL_CONF="". So a complete test call on my Buster Desktop installation looks like this:

OPENSSL_CONF="" /usr/bin/gmediarender --friendly-name Test --uuid 42 --gstout-initial-volume-db -20 --logfile /dev/stdout --gstout-audiosink alsasink

If it works then configure /etc/default/gmediarender, set UPNP_DEVICE_NAME and the INITIAL_VOLUME_DB if you like. Don't use "special" characters like umlaut or so. Startup will quit with an error message. Seems gmediarender still does not understand UTF-8 :-(

If you have more than one raspi with gmediarender running on your network, you should give each a different UUID. Control points can then distinguish different media renderer in upnp messages. Append something like this to /etc/default/gmediarender:

DAEMON_EXTRA_ARGS="--uuid f4f7681c-3056-11e8-86bd-87a6e4e2c42d"

You can get new UUIDs with the program uuid (install with sudo apt install uuid).

If you have only one interface on your RasPi then you are finished with the setup. Just start gmediarender as service:

pi ~$ sudo systemctl enable gmediarender.service
pi ~$ sudo systemctl start gmediarender.service



I had the problem that I use gmediarender on a RasPi with a wired network connection and with an access point so I have two interfaces with an ip address. Gmediarender binds to one of them and of course to the wrong one. You have to specify the ip address of the interface in /etc/default/gmediarender that should be used. But my interface is configured by DHCP so the ip address may change from time to time. To solve this problem I have made a small bash script that gets the current ip address from the interface and write it to /etc/default/gmediarender. This is the script:

rpi ~$ cat /usr/local/sbin/gmediarender-setip.sh
#!/bin/bash
# This script binds gmediarender to an interface given in "$1".
# Gmediarender needs the ip address of the interface. The current ip address
# is taken from the interface and set in /etc/default/gmediarender.

if [ $# -eq 0 ]; then
    echo 'no interface name given'
    exit 1
fi
IPADDR="0.0.0.0"
IPADDR=$(/sbin/ip -4 -br addr show $1 | /bin/grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")
CMD="s/\(DAEMON_EXTRA_ARGS=.*--ip-address=*\)[^ \"]*/\1$IPADDR/"
/bin/sed -i "$CMD" /etc/default/gmediarender

Don't forget to set permissions and make it executable only for root:

rpi ~$ sudo chown root:root /usr/sbin/gmediarender-setip.sh
rpi ~$ sudo chmod 754 /usr/sbin/gmediarender-setip.sh

Then execute this script just before starting gmediarender by extending its service with:

rpi ~$ sudo systemctl edit gmediarender.service

In the empty editor insert these statements using your own interface name, save them and quit the editor:

[Service]
ExecStartPre=/usr/local/sbin/gmediarender-setip.sh eth0

In /etc/default/gmediarender set at least

DAEMON_EXTRA_ARGS="--ip-address=0.0.0.0"
# or e.g.
DAEMON_EXTRA_ARGS="--uuid f4f7681c-3056-11e8-86bd-87a6e4e2c42d --ip-address=0.0.0.0"

Otherwise the script will not find the ip address to be changed. Then start gmediarender as service:

pi ~$ sudo systemctl enable gmediarender.service
pi ~$ sudo systemctl start gmediarender.service


references:
[1] https://github.com/hzeller/gmrender-resurrect
[2] https://joachim-wilke.de/blog/2016/07/10/UPNP-Renderer-auf-dem-Raspberry-Pi/
[3] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/811#note_117235

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.