Streaming audio from Ubuntu Linux to a DLNA player (Blu Ray or PS3) using Rygel
10 Jan 2012This project started out of researching how to play sound from spotify or rhythmbox from my laptop running ubuntu 11.10 through my hifi. Initially I set out to see if an airport express would work using raop and pulseaudio but it seems that support for the new 802.11 version is flakey so I didn't wish to invest £80 in a device that might not work. During my research I found that DLNA supported streaming, DLNA is a protocol commonly used for sharing media files with devices such as networked dvd players, internet tvs and consoles like the ps3 so I explored further.
DLNA is supported in Ubuntu (and other modern linux distros) by Rygel, part of the Gnome project. Rygel provides a DLNA server which also has the capability to capture a pulseaudio sink (an input or output stream) and stream it to a DLNA enabled device.
Below are the steps I took to enable me to stream audio from my computer to my Sony BDP-S370, they should be applicable to any similar device: <!--more-->
- Install required packages:
sudo apt-get install rygel rygel-gst-launch wavpack - Find the name of the pulseaudio sink which you wish to capture:
To list the choices, use:
pacmd list-sinksThen make a note of the name attribute (minus surrounding brackets), in my case it was:
alsa_output.usb-C-Media_INC._USB_Sound_Device-00-Device.analog-stereoI found that adding .monitor to this was required for the next stage, this can be achieved in one command:
pactl list | egrep -A2 '^(\*\*\* )?Source #' | grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -n1 - Edit /etc/rygel.conf:
Replace (or comment out)
[GstLaunch] enabled=true launch-items=audiotestsrc;videotestsrc;videotestoverlay audiotestsrc-title=Audiotestsrc audiotestsrc-mime=audio/x-wav audiotestsrc-launch=audiotestsrc ! wavenc videotestsrc-title=Videotestsrc videotestsrc-mime=video/mpeg videotestsrc-launch=videotestsrc ! ffenc_mpeg2video ! mpegtsmux videotestoverlay-title=Videotestsrc with timeoverlay 2 videotestoverlay-mime=video/mpeg videotestoverlay-launch=videotestsrc ! timeoverlay ! ffenc_mpeg2video ! mpegtsmuxwith
[GstLaunch] enabled=true launch-items=mypulseaudiosink mypulseaudiosink-title=Audio on @HOSTNAME@ mypulseaudiosink-mime=audio/x-wav mypulseaudiosink-launch=pulsesrc device=alsa_output.usb-C-Media_INC._USB_Sound_Device-00-Device.analog-stereo.monitor ! wavpackencreplacing the device on the last line with the output from the previous stage.
- Start Rygel (type rygel in the terminal)
- Connect your player to the DLNA device which should have appeared (probably as GstLaunch) and you should hear any audio played on your computer through your DLNA device.
- If you wish (I don't) add rygel to run at startup.
Alternatives
- If you just wish to share audio and video files then something like mediatomb with be much more simple (although rygel also shares files).
- There is meant to be a simpler way to link rygel and pulseaudio where everything works out of the box and rygel appears as a separate audio out but it's currently broken with the supplied pulseaudio/rygel combination in ubuntu.