Streaming audio from Ubuntu Linux to a DLNA player without Rygel

Recently, I became the proud owner of Onkyo TX-NR515 receiver. This device is DLNA MediaRenderer as upnp-inspector says. The A/V receiver is from the 2012 devices family (TX-NR414/TX-NR515/TX-NR616).

Streaming the sound from PC to my DLNA device over wlan was a tough task, but I managed to solve it the way I’ll describe below. The main idea is to pass the alsa/pulseaudio output stream over LAN to DLNA device. There are 2 ways of doing it: with DLNA server or without.

The rygel way worked on my Ubuntu 12.04 with 4-12 sec delay. I’m ok with such delay when listening to music. For video I used mplayer audio-video delay settings that easily allowed me to solve audio syncing problems. After upgrade to Ubuntu 12.10 the way with pulseaudio and rygel did not work for me.

The way I have it now: I pass the pulseaudio stream over HTTP, setup a ‘Favourite’ link on Onkyo receiver then play it. It works a lot more stable without DLNA server.

  • Get the name of your pulseaudio sink:
    pacmd list-sources | grep name
    
  • Start the HTTP streaming of pulseaudio sink (use your sink name from list-sources) with some transcoding (more on transcoding and streaming: http://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples)
    cvlc -vvv pulse://alsa_output.pci-0000_00_1b.0.analog-stereo.monitor --sout \
    '#transcode{acodec=mpga,ab=128,channels=2}:standard{access=http,dst=0.0.0.0:8080/pc.mp3}'
    
  • Test playing the stream on some PC within your LAN, then go to Onkyo’s web interface and save to Favourites the link to stream:
    http://your.ip:8080/pc.mp3
  • Via Onkyo interface go to Favourites and play the stream

Such solution is very stable for my network and transcoding config can be easily tweaked. Though it has some drawbacks: firstly, there’s still a delay (depends on transcoding settings). Secondly, VLC is a sledge-hammer to crack nuts. Using ffmpeg/avconv instead of VLC would be a better solution.

Tagged , , , , , , , , , , , , , , , . Bookmark the permalink.

16 Responses to Streaming audio from Ubuntu Linux to a DLNA player without Rygel

  1. RX A3010 says:

    I appreciate, lead to I found just what I used to be taking a look for. You’ve ended my 4 day lengthy hunt! God Bless you man. Have a great day. Bye

  2. Dawid Ciężarkiewicz says:
  3. Christian says:

    For some reasons my Onkyo refuses to play the stream.

    I use my raspberry pi for playing this stream.

    Thanks,
    Christian

  4. Heri Cahyono says:

    Thanks.

    This is the simplest method i can find 🙂

  5. Stefano Bolli says:

    Thank you. Your solution works fine with my Onkyo 3009

  6. wilks says:

    The cvlc route worked for me with a couple of Sonos Play:1, I just had to change the acodec from mpga to mp3 (that and install the Sonos desktop controller in VirtualBox simply to add the url to my radio list, I mean surely, it should be possible to do that from the phone app, right? Grrrr… )
    Anyways, thanks for your post, very useful stuff!

  7. Pingback: Ubuntu 13.10 on a Dell XPS 13 | In The Armchair

  8. keydon says:

    hey thanks, this works great with my ubuntu 13 laptop and my raspberry running openelec connected to my hifi. but i did not manage to mute my laptop without muting the output to the raspberry. how can i achieve that? Since there is a slight delay its kinda annoying hearing the music from both devices ;O

  9. pitjow says:

    Thanks dmitry for this very simple but clean solution! Three points to mention:

    1) I had first to unmute the output monitor.

    $ pacmd
    Welcome to PulseAudio! Use “help” for usage information.
    >>> set-source-mute alsa_output.pci-0000_00_1b.0.analog-stereo.monitor false
    >>> exit

    2) Second, as wilks discribes, I had to change the acodec from mpga to mp3 as well.

    3) Third, there is still the muting-problem keydon describes.

    • pitjow says:

      @keydon: Found the solution the muting-problem: Muting with the normal mute-button muetes the master of the alsa mixer. But we only want to muete the speakers of the laptop. So we can execute this command:

      amixer -c 0 set Speaker playback 0%

  10. Bert says:

    Hey. This seems the perfect solution for me, but I don’t get it working. 🙁

  11. Agge says:

    Hi.

    Looks like precisely the solution I am looking for, just a question what kind of delay do you get with this solution?

    • root says:

      When I tested this option in 2012 I had (0.5-1)s delay over Ethernet and (2-4)s over 802.11n. I don’t use this way at the moment because of constant PulseAudio problems: missing sinks, lost network connections, etc. I believe PA with Ubuntu are more stable now. I also didn’t have time to test it with my 802.11ac. As an alternative I use the UBT-1 dongle. With Chinese Dongles I get (900-1000)ms delay, and (50-100)ms with Nexus 4, Nexus 7 from Google and Plantronics BackBeat Go 2.

  12. mike says:

    Perfect solution.
    I get a 10 second delay via LAN streaming but can happily live with this.
    Many thanks for sharing this.

  13. Hold says:

    Hi Dmitry. This is still a great solution, but the delay (10sec over ethernet) is a bit annoying.
    I can’t seem te find any other solution, so is there a way to get rid of the delay, maybe by using ffmpeg?

  14. Bill says:

    I have a DLNA audio renderer, with built in hardware digital to analog converter. Which is supposed to be more HIFI than say an analog connection from a computer etc. I thought that finding clients that could play to a renderer would be very simple, but after trying many different pieces of software, I haven’t really gotten that far!
    Anyway I did find pulseaudio-dlna which is similar to what you have here. It lets you direct various audio inputs to your pulseaudio-dlna outputs that can include chromecasts. You can also link them up as well, so have multiple device output. First impressions are that it transcodes the computers audio output to mp3, and presents as a stream. You do get a delay. (I was hoping to bypass transcoding for supported formats.) The nice thing about pulse-dlna is that you can pretty much wire any audio output from any application to your renderer. Perhaps I need to just dig into the dlna spec, because in my mind it should be as easy as presenting a url to the renderer. Volume, play, pause and seek would be nice from multiple devices. Very disappointed in the userland apps for DLNA. Makes CD use, and flipping vinyl a doddle by comparison for us fat controllers.

Leave a Reply to Dawid Ciężarkiewicz Cancel reply

Your email address will not be published. Required fields are marked *