As our homes fill up with streaming devices, we have to manage them from all of our machines, including Linux boxes. In this article, we show you how to stream audio and video from your Linux machine to Chromecast and Google Home.
Mkchromecast is a program for streaming audio and video from your macOS or Linux desktop to your Google Cast devices or Sonos speakers. It is written in Python and comes with packages for Debian and Ubuntu. If your repositories are up to date, you can open a terminal and type:
It is also available in Ubuntu software and can be installed with one click.
After installation, you will find Mkchromecast in your Applications folder. Launch it and you should see the service icon appear at the top right of your screen. By default, the icon is not set to match Ubuntu’s dark theme, but you can upgrade to a lighter icon set. Click on the icon and choose Preferences.
There are three options for icon colors. Choose the one you prefer and close the window. Surprisingly, nothing happens, but if you click the icon again and select “Search for streaming media devices” the change will take effect.
Select “Search for media streaming devices” to see everything that is accessible on your network. It may take about a minute for all of your devices to appear.
You can now select your destination from the list of available devices and the icon changes to include a small playhead. This means that the device is ready to take a stream. We noticed that by default Mkchromecast set the device’s volume to 0, so it’s a good idea to select the Volume option and set it to something reasonable.
Pulse Audio Control to manage the pipes
To direct the audio to the correct device, we choose to use a second software, called Pulse Audio software control (search for “pavucontrol”), available from Ubuntu Software. This has five tabs at the top. Start under “Output devices” to make sure Mkchromecast is listed and active. You will also see your standard output speakers as a hardware device. There is a volume slider to change the volume and a lock button to sync streams across multiple devices, although we’re pulling out one at a time.
Then you need a source. We use MPV Media Player for local playback. Launch the source and add a file such as MP3 or wav. Under Pulse Audio Playback in a tab, you should now see an entry for System Sounds and Media Player. By default, the media player will be configured for playback on your standard output.
Select the button next to the media player and choose Mkchromecast.
Now when you press play in media player, the sound will come out from the selected device. You can go back into the Mkchromecast system tray app and select different devices, and the audio should change.
Stream local files from Chrome
The second option is perhaps the easiest, but also uses more system resources as it runs in Chrome or in the open source Chromium browser.
Chrome has its own native streaming system, so you can open a web radio station or web app like Spotify, then go to the menu and select Cast to see a list of available devices. Select the device and the sound will start playing.
You can also select a device, click in the Sources list at the bottom, and select “Stream file” if you want to listen to a local file. A file selector appears and you can choose a track to start playing. The problem with this is that it’s all or nothing – there’s no real control over play or pause and no chance to adjust the volume except on the device itself.
A good alternative is the Local audio player extension, available on the Chrome Web Store. This allows you to select a file to play, adjust the volume, or set a sleep timer to go off after a certain amount of time. It’s great for audiobooks!
This extension requires a small adjustment before use, so once installed, go to “Menu -> Extensions”, select Local audio player and click on the Details button. Halfway down the page you will see a switch on “Allow access to file URLs”.
You can now drag a local file into the browser and a player will launch. You can do “Menu -> Cast” and select your device, then press Play. Again, you can select different devices and the audio should move to the correct location.
Now you can enjoy sound in any room in your home where you can plug in a Google Home or Chromecast device. Maybe you even want to enhance the experience with some PulseEffects to even out some of the dynamics in your music or boost the bass.
If you don’t have a Chromecast, you can also build it yourself using a Raspberry Pi.
Is this article useful?