How to use Cast to TV to cast GNOME Shell desktop to Chromecast (with audio, Wayland/X11 support)

Cast to TV , It is an extension of GNOME Shell, used to cast files and more content to Chromecast devices (and more devices), recently updated, it supports projecting desktop with sound, and can be used with Wayland and X11. This is done through an auxiliary add-on called Cast to TV-Desktop Streaming Add-on , The file was first published on the GNOME extension website recently.
In order for desktop streaming to work properly, you need Cast to TV version 14 or higher, which only supports GNOME Shell 3.36 and 3.34 (for example, Ubuntu 20.04 and 19.10, and Fedora 31 and 32). This means that this does not apply to older Linux distributions that use older GNOME Shell versions, such as Ubuntu 18.04 or Fedora 30.

This article describes how to use “cast to TV” (and its auxiliary plug-ins) to project the GNOME Shell desktop to a Chromecast device with sound, which can be used with X11 and Wayland. Step by step instructions for Debian /Ubuntu/Pop! _OS, Fedora, and Arch Linux/Manjaro (on any GNOME Shell-based Linux distribution, the steps should be the same, but the name of the package may be different).
Officially, you can use Google Chrome to stream a Linux desktop to Chromecast. However, casting to TV has some advantages over Google Chrome browser streaming via Chromecast desktop:

  • It has nothing to do with Google’s browser
  • It can provide a valid audio stream to your desktop, which is not available on Linux with Google Chrome
  • It supports Wayland, which may be the only way to cast the desktop from Wayland to Chromecast device
  • It has customizable video bitrate and fps
  • It has hardware acceleration function (VAAPI for Intel/AMD and NVENC for Nvidia graphics card)
  • You can also choose to show or hide the mouse cursor.

Compared with Cast to TV, Google Chrome browser also has two advantages: low streaming delay (Cast to TV currently delays about 3 seconds), and it can be used in desktop environments other than GNOME Shell. Therefore, please use the solution that best suits your needs.
Compared to casting the desktop to the Chromecast, casting to the TV can do a lot. It can also project local pictures, videos and audio files through optional code conversion, GPU accelerated video encoding (which can reduce CPU usage), subtitles, etc. Check out its project page for details You might also like: Chromecast extension fx_cast 0.0.5 for Firefox adds support for YouTube and subtitles for local media.

On Debian/Ubuntu/Pop! Set up Cast to TV in _OS, Fedora or Arch Linux / Manjaro, cast your desktop to Chromecast

To use Cast to TV to stream the GNOME Shell desktop (version 3.34 or 3.36 only!) to Chromecast, you need to install Cast to TV version 14 (or later) and the Cast to TV Desktop add-on, and install some GStreamer Plug-in and adjust some PulseAudio settings. This is the detailed operation you need to do on Debian/Ubuntu, Fedora or Arch Linux/Manjaro.
Using these steps, the entire “cast to TV” feature will be enabled, so you can not only cast the desktop, but also cast videos, music and pictures from the GNOME Shell desktop. More ways to stream from Linux to Chromecast:

  • CATT, command line Chromecast player
  • Gnomecast, a GUI application for streaming local audio and video files to Chromecast

1. Install the required Cast to TV and Cast to TV-Desktop Add-on dependencies.
Casting to the TV extension requires npm and Node.js for some modules, while FFmpeg is used for transcoding. Casting to the TV-Desktop Streaming add-on also has some dependencies: GStreamer basics, good, bad and ugly plugins.
PulseAudio (and pacmd) are also required, but in most cases they should already be installed.
Use the following command to install the dependencies:

  • Debian / Ubuntu / Pop! _OS:
                        sudo apt install ffmpeg npm nodejs gstreamer1.0-plugins-{base,good,bad,ugly}
  • Fedora:

You need to enable the RPM Fusion repository to install FFmpeg and some GStreamer plugins (in case you have not enabled this repository), then install the package:

                        sudo dnf install$(rpm -E %fedora).noarch.rpm$(rpm -E %fedora).noarch.rpm

sudo dnf install ffmpeg gstreamer1-plugins{base,good,bad-free,ugly}
  • Arch Linux / Manjaro:
                        sudo pacman -S ffmpeg npm nodejs gst-plugins-{base,good,bad,ugly}

2. Install optional dependencies.
There are also some optional dependencies. When using hardware accelerated recording through the Nvidia driver (NVENC), you do not need to install any additional software package, because it is already provided in the GStreamer1-plugins-bad package (it depends on whether your Linux distribution is enabled The package, but it may not be available), for VAAPI (Intel/AMD), you need to install the GSttreamer1-vaapi package:

  • Debian / Ubuntu / Pop! _OS:
                        sudo apt install gstreamer1.0-vaapi
  • Fedora:
                        sudo dnf install gstreamer1-vaapi
  • Arch Linux / Manjaro:
                        sudo pacman -S gstreamer-vaapi

The Cast to TV Desktop Add-on Wiki points out that considering the hardware-accelerated GStreamer implementation (both VAAPI and NVENC are “experimental”), this is very important, and using it may crash GNOME Shell. In the test of streaming GNOME Shell 3.36 desktop to Chromecast, I did not try to use hardware acceleration because my Nvidia graphics do not support NVENC.
Therefore, if your desktop crashes or cannot be cast to Chromecast when using hardware acceleration, please disable it ( Cast to TV preferences -> Add-ons > Desktop -> Hardware acceleration: None ).
On Debian/Ubuntu, there is also an optional dependency. GStreamer plugin does not fdkaac with faac By default, only the AAC audio encoder is enabled voaacenc Available, it is quite old. In order to get better audio streaming on Debian/Ubuntu, you can use the FFmpeg GStreamer plugin (although recent Debian/Ubuntu versions use FFmpeg, although libav In the package name) for avenc_aac AAC audio coding. Install this package:

                        sudo apt install gstreamer1.0-libav

3. Install “cast to TV” and “cast to TV desktop stream add-on”.
These extensions can be found on the GNOME Shell extension website. If you allow the installation of GNOME Shell extensions on Linux distributions, you can install Cast to TV using the GNOME software, and then install the Cast to TV Desktop Stream add-on.
Alternatively, you can follow the instructions in the GNOME Wiki to Integrate GNOME Shell with Google Chrome and Firefox , And then you can install the GNOME Shell extension using these two web browsers. After following these instructions, please visit Cast to TV extension page From the GNOME Shell extension website, click the OFF button in the upper right corner of the page to install. Then right Cast to TV-Desktop Streaming Add-on .
The extension installation has not been completed at this time because you need to install some npm modules. You need to open the “Cast to TV” preferences.
I need to make an important note here. The release notes for Cast to TV v14 mentioned that a bug in GNOME Shell 3.36.1 prevented the opening of extended preferences from the GNOME system menu (“Broadcast Settings”). However, this does not happen to me on Ubuntu 20.04 with GNOME Shell 3.36.1, this may be due to some patches that make it work, but if you happen to be on another Linux distribution If this problem is found, please use the new GNOME extension application (introduced in GNOME 3.36). Project to TV install npm module

In the Cast to TV preferences, switch to Modules Label and click Install npm modules At the bottom of the window (screenshot above). Do this after installing the Cast to TV and Cast to TV Desktop add-ons at the same time, as both require some npm modules to be installed. 4. Enable streaming of desktop audio to Chromecast.
There are two requirements for streaming the GNOME Shell desktop to a Chromecast device to use audio. The first requirement is to select the AAC plug-ins available on the system in the “Cast to TV” extension preferences. To view the AAC GStreamer plugins available on the system, use (you don’t need all of them, one is enough):

                        gst-inspect-1.0 fdkaac
gst-inspect-1.0 faac
gst-inspect-1.0 avenc_aac
gst-inspect-1.0 voaacenc

If you get “No such elements or plugins” as output, for example on Ubuntu:

                        $ gst-inspect-1.0 faac
No such element or plugin 'faac'

This means that the plugin is not available, so you cannot use it in the “Cast to TV” setting to stream desktop audio to Chromecast.
Instead, if you get some output, like this:

                        $ gst-inspect-1.0 avenc_aac
Factory Details:
Rank                     none (0)
Long-name                libav AAC (Advanced Audio Coding) encoder
Klass                    Codec/Encoder/Audio
Description              libav aac encoder
Author                   Wim Taymans <[email protected]>, Ronald Bultje <[email protected]>

Plugin Details:
Name                     libav
Description              All libav codecs and formats (system install)
Filename                 /usr/lib/x86_64-linux-gnu/gstreamer-1.0/
Version                  1.16.2
License                  LGPL
Source module            gst-libav
Binary package           GStreamer libav Plugins (Ubuntu)
Origin URL     

This means that there are specific plugins on your system, you can choose from the “cast to TV” extension preferences ( Add-ons -> Desktop -> Audio encoder ). Also enable Stream with audio Used to cast audio for the desktop: Launch desktop Linux preferences

On Debian and Ubuntu, fdkaac with faac Not available in GStreamer, that’s why I recommend installing gstreamer1.0-libav To be able to use avenc_aac . On Arch Linux/Manjaro, both fdkaac with faac After installing the GStreamer basic version, you should be able to use plug-ins, good or bad or ugly, so please use one of them. On Fedora, after installing the GStreamer plugin, you should fdkaac Use it whenever possible.
If you don’t select an available AAC encoder in the “cast to TV” preferences, casting your desktop to the Chromecast will fail (you won’t even be able to cast videos). If for any reason there is no AAC encoder available on your system, please disable audio streaming (available in the “cast to TV” preferences) to at least make desktop streaming work. And you can change PulseAudio by casting GNOME Shell desktop to Chromecast with audio /etc/pulse/ Configuration rooted in any text editor, for example, the default GNOME text editor Gedit (text editor):

                        gedit admin:///etc/pulse/

And change the line containing the following:

                        load-module module-stream-restore


                        load-module module-stream-restore restore_device=false

Save the file, and then restart PulseAudio:

                        pulseaudio -k

It is planned to select the native audio receiver in GJS in the future for future projection to TV desktop plug-in use, but before that, you need to use the manual adjustment of the PulseAudio configuration file. 5. Cast your GNOME Shell desktop to Chromecast device. Cast to TV desktop stream Cast to TV remote desktop stream

Now you can cast the Linux GNOME Shell desktop to Chromecast. From the GNOME Shell system menu, expand the Cast Media item, and then click Desktop.
After starting to cast the desktop to the Chromecast device, you will see an orange dot (this means that the GNOME Shell built-in screen recorder is active), and the “cast to TV” remote control on the top panel-you can pass it here Press the “Stop” button to stop casting the desktop (this button will not appear until you start casting).


Related Posts