25 C
Jaipur
Friday, November 27, 2020

How To Use pulseaudio-dlna To Stream Audio From Ubuntu 20.10 To Chromecast Devices

Must read

Sony is Permanently Banning PS5 Owners For Selling Their PlayStation Plus Collection

Sony offers access to 20 PlayStation 4 games through PlayStation Plus Collection, a new benefit to PlayStation Plus subscribers with PlayStation 5. The company...

cPanel 2FA Bypass Exposes Tens of Millions of Websites to Hack

Digital Defense, Inc., a leader in vulnerability and threat management solutions, announced that its Vulnerability Research Team (VRT) exposed a previously undisclosed vulnerability affecting the cPanel &...

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.

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, 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).

It’s worth noting that Ubuntu 20.04 does not have pulseaudio-dlna in its repositories, and using the same Python 3 branch doesn’t work on this Ubuntu version. 

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.

Chromecast-related articles you might like:

How to install the Python3 pulseaudio-dlna (patched) branch on Ubuntu 20.10 / Pop!_OS 20.10

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

sudo apt install 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

2. Remove python3-pychromecast and pulseaudio-dlna if you had them installed from the Ubuntu repositories:

sudo apt remove python3-pychromecast pulseaudio-dlna

3. Install pychromecast 6.0.1

The pulseaudio-dlna Python 3 branch does not work with pychromecast 7, which is available in the Ubuntu 20.10 repositories. So we’ll have to install pychromecast 6 instead.

To make it easier to install, I’ve uploaded a python3-pychromecast 6.0.1 DEB here. Download and install that package on your Ubuntu 20.10 / Pop!_OS 20.10 machine. You can also install it in some other way if you wish.

You’ll also need “hold” this python3-pychromecast package version, so it’s not upgraded. This can be done using the following command:

sudo apt-mark hold python3-pychromecast

In case you later want to upgrade this package, use the same command but with “unhold” instead of “hold”.

4. Install the pulseaudio-dlna Python 3 branch

For the installation instructions below we’ll use wget and git, so make sure they are installed:

sudo apt install wget git

Now you can clone the pulseaudio-dlna Python 3 branch, patch it with a fix to wait for the Chromecast device to be ready, and install it:

git clone https://github.com/masmu/pulseaudio-dlna

cd pulseaudio-dlna

git checkout python3

wget https://github.com/masmu/pulseaudio-dlna/commit/d46f419abd5105e48342ee45219cbf557d342af4.patch

patch -p1 -i d46f419abd5105e48342ee45219cbf557d342af4.patch

sudo python3 setup.py install --record=installed_files.txt

Make sure you save the installed_files.txt created by the last command from above (it should be created in the pulseaudio-dlna folder) as you can use that to uninstall pulseaudio-dlna later. To remove pulseaudio-dlna installed using the instructions mentioned above, run sudo rm $(cat installed_files.txt) in the folder where the installed_files.txt is placed.

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)

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Sony is Permanently Banning PS5 Owners For Selling Their PlayStation Plus Collection

Sony offers access to 20 PlayStation 4 games through PlayStation Plus Collection, a new benefit to PlayStation Plus subscribers with PlayStation 5. The company...

cPanel 2FA Bypass Exposes Tens of Millions of Websites to Hack

Digital Defense, Inc., a leader in vulnerability and threat management solutions, announced that its Vulnerability Research Team (VRT) exposed a previously undisclosed vulnerability affecting the cPanel &...