How To Use pulseaudio-dlna To Stream Audio To Chromecast Devices On Ubuntu 20.10 / Ubuntu 20.04 / Linux Mint 20.x


pulseaudio-dlna is a streaming server which allows streaming audio from your Linux computer to a Chromecast or DLNA / UPNP device in the same network, via PulseAudio.

This article explains how to install and get pulseaudio-dlna to stream audio from Ubuntu 20.10, Pop_OS! 20.10, and other Linux distributions based on this Ubuntu release, to Chromecast devices. [[Edit]] The now updated instructions below also work on Ubuntu 20.04, Linux Mint 20.x, Pop!_OS 20.04, etc.

The last pulseaudio-dlna release uses Python 2, which is no longer available in many Linux distributions, which means it can no longer be used on modern Linux distributions. There is, however, a Python 3 branch that you can use, but that too is unmaintained for some time, and it has some issues, for example it's not compatible with the latest pychromecast 7.* (which is what Ubuntu 20.10 has in its repositories).

Ubuntu 20.10 (and Linux distributions based on it, like Pop!_OS 20.10) does have pulseaudio-dlna in its repositories, but this package does not work properly, at least not with Chromecast devices (I can't test it with DLNA devices - it might work with those). And since Ubuntu 20.10 has pychromecast 7 in its repositories, that complicates things a bit if you want to use the Python 3 branch. 

But I got it to work with the help of a Python 3 branch fork, and this article explains everything to get pulseaudio-dlna to work in Ubuntu 20.10 / Pop!_OS 20.10 with Chromecast devices (it should also work with DLNA devices but like I said, I did not try it). [[Edit]] This now also works on Ubuntu 20.04, Linux Mint 20.x, Pop!_OS 20.04, etc.

It's worth noting that Ubuntu 20.04 does not have pulseaudio-dlna in its repositories at all, but it does have pychromecast 4.1.0.

Also, I didn't add instructions for other Linux distributions because this doesn't seem to work in a virtual machine (even though it's in the same network), so I couldn't test it properly. There are third-party packages for Fedora and Arch Linux (which use the same Python 3 branch and patch used in the instructions below), among others, so if you use those Linux distributions you can give those packages a try. If that doesn't work, use the Python 3 branch for of pulseaudio-dlna from here.

Chromecast-related articles you might like:


How to install the Python3 pulseaudio-dlna Python branch fork on Ubuntu 20.10 / Pop!_OS 20.10 Or Ubuntu 20.04 / Linux Mint 20.x / Pop!_OS 20.04


1. Install the pulseaudio-dlna Python 3 dependencies (minus pychromecast, that's in step):

sudo apt install python3-pychromecast python3-setuptools python3-pip python3-docopt python3-chardet python3-gi python3-dbus python3-docopt python3-requests python3-setproctitle python3-protobuf python3-lxml python3-netifaces python3-zeroconf python3-urllib3 python3-psutil python3-pyroute2 python3-notify2 python3-distutils sox vorbis-tools lame flac opus-tools ffmpeg

In case you've used the previous instructions about holding the pychromecast package to an older version, remove the apt hold (so the package can be updated) and upgrade the package using:

sudo apt-mark unhold python3-pychromecast

sudo apt install python3-pychromecast

2. Remove pulseaudio-dlna if you had it installed from the Ubuntu repositories (only for Ubuntu 20.10; Ubuntu 20.04 / Linux Mint 20.x doesn't have this package in its repositories):

sudo apt remove pulseaudio-dlna

4. Install the pulseaudio-dlna Python 3 branch fork

Download the latest pulseaudio-dlna Python 3 branch fork release from here. Extract the downloaded archive in your home folder (after extracting it, you should have a new folder ~/pulseaudio-dlna-0.6.1 - the version can be a newer one, in case new versions are released since I write this).

Now you can install pulseaudio-dlna:

cd ~/pulseaudio-dlna-0.6.1/man #the version number may be different if a new version is released

gzip pulseaudio-dlna.1

cd ..

python3 -m pip install --user .

The gzip command used above is needed to gzip the pulseaudio-dlna.1 file to pulseaudio-dlna.1.gz, and it will probably not be needed in the future. The setup.py file expects the pulseaudio-dlna.1.gz file to exist in the man directory, but it doesn't come in the 0.6.1 release archive, so this fixes it.

This installs pulseaudio-dlna in ~/.local/bin. You may not have this directory in your PATH. If that's the case, after using the python3 -m pip install... command, you'll see a warning saying that ~/.local/bin is not in PATH. 

To add that folder to your PATH (come on Ubuntu, just add this to the user's PATH by default!), open ~/.bashrc (or ~/.zshrc if you use Zsh) with a text editor (example: open a terminal and type gedit ~/.bashrc), and at the bottom of this file, add the following line without modifying anything else:

export PATH="$HOME/.local/bin:$PATH"

Then source ~/.bashrc or ~/.zshrc so the changes are used by your current terminal:

source ~/.bashrc #for Bash; or:

source ~/.zshrc #for Zsh

In case you want to uninstall pulseaudio-dlna later, you can do that using:

python3 -m pip uninstall pulseaudio-dlna

How to use pulseaudio-dlna


To launch pulseaudio-dlna, open a terminal and type:

pulseaudio-dlna

Next, open your system settings, head to the Sound settings and change the Output Device to your Chromecast / DLNA / UPNP device. This is how my Chromecast shows up in the Output Device section of the Sound settings:


It's important to note that pulseaudio-dlna has quite a bit of lag, so it may take a while until the sound starts on your Chromecast / DLNA device.

This streams all the sounds from your computer to the remote device. In case you want to stream the sound from a particular application only, install pavucontrol:

sudo apt install pavucontrol

Then launch pavucontrol (either by typing pavucontrol in a terminal, or launching PulseAudio Volume Control from the applications menu), and on the playback tab you can change the stream individually, for each application.

pulseaudio-dlna pavucontrol

For example, in the screenshot above, VLC is set to stream to my Chromecast while Chromium does not.

pulseaudio-dlna has quite a few options. For example, you can get it to use a different port (it uses port 8080 by default), like this:

pulseaudio-dlna --port <PORT>

Where PORT is the port you want to use for pulseaudio-dlna.

You can also specify the codec to use:

pulseaudio-dlna --codec <CODEC>

Where CODEC can be mp3, ogg, flac, wav, opus, aac and more.

You can also specify a different encoder backend (by default it uses a generic encoder), like ffmpeg, by running pulseaudio-dlna like this:

pulseaudio-dlna --encoder-backend ffmpeg

In case more than 1 device is discovered, you can specify which one to use using:

pulseaudio-dlna --filter-device '<Device name>'

For more options, check out the application help:

pulseaudio-dlna --help

You might also like: How To Enable Echo / Noise Cancellation Of Microphone Input On Your Linux Desktop (PulseAudio)

Thanks to Sinan H for pointing out the new pulseaudio-dlna Python3 branch fork, which is now used in this article, instead of the original instructions.