Stream Audio to Chromecast in Linux

Very few pieces of tech have exploded in popularity quite like Chromecast, the $35 media streaming dongle from Google. Consumers bought 3.2 million Chromecasts in Q3 of 2015 alone, giving Google 35% of the global digital media streaming device marketshare. (source: http://variety.com/2015/digital/news/chromecast-apple-tv-roku-sales-numbers-1201649970/)

When the Chromecast was first released in July of 2013, it supported 4 apps: Netflix, Google Play Music, Google Play Movies, and YouTube. This list is somewhat embarrassing when compared to, say, Roku’s list of available apps/channels. But, for people like myself, the Chromecast was perfect. I never invested in a Roku because it was pretty expensive for what I would get out of it. I have a subscription to Netflix, I use Google Music, and occasionally YouTube. I can use my Xbox to play Netflix, listen to music (with last.fm), and watch YouTube videos. While the Xbox doesn’t have the greatest UI, and using a gaming controller for these kinds of tasks is less than a great experience, it does work. And I couldn’t bring myself to spend the money on a device that would make performing these tasks just a little bit easier.

But I could definitely bring myself to spend a measly $35 for a device so small nobody will ever know it’s there, and can be controlled with my phone, and/or laptop computer. No extra cords to manage, no device taking up more real estate on my entertainment center, no more remotes to lose under the couch. And even tho it only supported 4 apps, it supported the 4 apps I happen to use most! It was a no-brainer for me, and many others.

Fast forward to today, Google has long-since released the Google Cast API, allowing anybody to build Google Cast support into their own app, and suddenly this $35 dongle supports tons of apps and is about a thousand times more useful.

Speaking of Chromecasts being more useful, I’d like to share with you something I learned recently, which is how to stream audio from your Linux machine to a Chromecast (or any DLNA or UPnP device) using pulseaudio-dlna.

For this to work, you will need pulseaudio-dlna installed:

Ubuntu 16.04, 15.10 and 14.04, Linux Mint 17.x and derivatives

To install pulseaudio-dlna using PPA, use the following terminal commands:

sudo add-apt-repository ppa:qos/pulseaudio-dlna
sudo apt-get update
sudo apt-get install pulseaudio-dlna

Other Linux distributions, see the pulseaudio-dnla instructions.

Once pulseaudio-dlna is installed, it’s time to run it, using the following command:

pulseaudio-dlna

Now that pulseaudio-dlna is installed and running, make sure your DLNA / UPnP / Chromecast device is powered on.

Then, if you’re using the Unity desktop, open the Sound Menu and select Sound Settings, and your DLNA / UPnP / Chromecast device should show up in the output list:

Select the device, and that’s it!

If you’re using the XFCE desktop, start playing your audio file. For instance, navigate to spotify in your browser and start playing your favorite playlist. Then, click on the speaker icon in the system tray in the bottom-right corner, and hover over Playback Streams. You should see your Chromecast in the list of devices. It might be a few levels in. For example, I’m playing Spotify in Chrome. So when I hover over Playback Streams, I see Chrome. Then, if I hover over Chrome I see my Chromecast device.

NOTE: If you notice that audio quality on the Chromecast is poor, you may need to run pulseaudio-dlna with mp3 as the codec and ffmpeg as the encoder backend:

pulseaudio-dlna --codec mp3 --encoder-backend=ffmpeg

This command might be a little redundant, as a recent pulseaudio-dlna update made mp3 the default codec for Chromecast, but you may still want to make ffmpeg the encoder backend.

Enjoy!

Leave a Reply

Your email address will not be published.