112

I just saw the video about Chromecast and I am interested in knowing how can I enable this on my Ubuntu PC. My TV has an HDMI port.

Zanna
  • 70,465
Luis Alvarado
  • 211,503
  • 2
    Which video did you watch? Could you link to it in your question? – Kevin Bowen Jul 26 '13 at 20:27
  • None yet, but the addon did install (And I actually took my time to read the information about "How to use Chromecast) which I accidentally skipped yesterday. Was too tired). When I get the chance to test it with a device I will let you know immediately. – Luis Alvarado Jul 26 '13 at 20:39
  • ok. I just thought that you had a specific video in mind that would be useful for others. I've found a few for my own edification. Cheers! – Kevin Bowen Jul 26 '13 at 22:39
  • https://github.com/keredson/gnomecast lets you cast a video file to your chromecast. (disclaimer: my project) – keredson Mar 01 '18 at 05:35
  • 1
    Many options and work-arounds are posted here including a now deprecated Chromium extension and several reports that the functionality has been added to Chrome and Chromium and therefore available by default. I think we're losing track of the main question. Should I buy a Chromecast to use with Ubuntu? Answer: No. Chromecast does not currently work with Ubuntu out of the box. There may be some suggested work-arounds, but the fact remains. It's not supported by Google or anyone on the Ubuntu side. It doesn't work out of the box and there's nobody working to make sure any unrelated changes don't – jorfus Oct 01 '18 at 19:54
  • @jorfus Hi buddy, well I would disagree with your comment. I have here 2 Chromecast that I have used through Ubuntu (Using Google Chrome with Videostream app) and 2 Chromecast Ultra which I use via smplayer or VLC. Or simply using Google Chrome with youtube and from there I share it to any of the TVs that have Chromecast. If you need any assistance with this, let me know so we can do a quick online meeting to guide you about issues with chromecast itself, networking configurations and other minor things that after they are known, you save a lot of time when sharing to, in my case, to the kids. – Luis Alvarado Oct 01 '18 at 20:53
  • Thanks Luis, your question generically asks, how to connect from Ubuntu to Chromecast. The most basic way this should work is casting a tab from Chrome. That's the use case it might be most beneficial to post as an answer if you have gotten it to work. All other answers to that specific use case refer to a discontinued plugin. Thanks. – jorfus Oct 01 '18 at 22:17
  • @jorfus yes boss will do this week. – Luis Alvarado Oct 02 '18 at 01:39
  • @jorfus Hi buddy, done, hope you like the answer. – Luis Alvarado Oct 05 '18 at 00:13
  • 1
    After the merge of this PR will add Chromecast support to GND (Gnome Network Displays) – Pablo Bianchi Apr 24 '23 at 13:32

13 Answers13

89

The documentation from Google indicates that the Google Cast extension is not supported in Linux, but it actually does work.

To get this working in Ubuntu:

  • Make sure you are running either Chromium or Chrome version 28 or higher. Earlier versions will get a "This application is not supported on this computer. Installation has been disabled." error. The 'chromium-browser' package in Ubuntu 13.04 works fine.

  • Make sure iptables is configured to allow the UPnP/SSDP traffic used by the Google Cast browser extension to discover the ChromeCast device.

    The browser will send a multicast UDP packet from the local IP and an ephemeral (random) port to 239.255.255.250 port 1900. The ChromeCast device will respond with a unicast UDP packet from the ChromeCast device's IP and another ephemeral port to the source IP/port of the multicast packet. Note that this is slightly different than most other UPnP devices, which will usually respond with a unicast UDP packet from port 1900 instead of an ephemeral port.

    The typical iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT rule WILL NOT match the response packet, as iptables does not currently have a conntrack helper that supports SSDP. In addition, the iptables -A INPUT -p udp --sport 1900 -j ACCEPT rule typically used for UPnP/SSDP will not work since the replies from the ChromeCast device do not come from port 1900.

    Therefore, you will need to add a rule to accept UDP packets on all ephemeral ports. The ephemeral port range for the initial multicast packet should be 32768-61000 (Verify with cat /proc/sys/net/ipv4/ip_local_port_range), so the following rule should work (note it inserts at the top of the input rules):

    iptables -I INPUT -p udp -m udp --dport 32768:61000 -j ACCEPT

    After the ChromeCast device has been discovered (each time the browser starts), the browser will control it using TCP (HTTP) connections to port 8008, which should not require any special iptables rules.

  • Install the Google Cast browser extension in either Chromium or Chrome. Note that an app/extension called ChromeCast is available, but this is not what you want.

  • If you have not yet set up your ChromeCast device, follow the instructions that come with the device to set it up.

  • Once your device is configured, you should be able to simply click the Cast button in Chromium to Cast your current tab.

Paul Donohue
  • 1,027
  • 1
  • 6
  • 5
  • 2
    Thanks for the info on IP tables. I wasn't aware of Chromecast's different behavior from other uPnP devices. – Fred Thomsen Aug 24 '13 at 23:15
  • 1
    To get this solution to work in Fedora using the GUI, go to the Zones tab in "Firewall configuration", select the public zone, go to the ports tab, and add the udp port range 32768-61000 – CamelBlues Jun 20 '14 at 01:07
  • Sadly, this does not work for Nexus Player. – abergmeier Feb 03 '15 at 19:17
  • The castv2 protocol seems to use mDNS + Cast(s) protocol on port 8009 instead of the original approach. Additionally, when Mirroring your screen it will send traffic on a separate UDP port for the screen data which is announced dynamically during the handshake. – Roberto Andrade Sep 13 '15 at 14:13
  • You still need to unblock your incoming port for TCP connections, e.g. 8080, in iptables. – ApolloLV Oct 25 '15 at 22:55
  • I did not need to change iptables. I guess in the 3 years since this answer, Google found a way to control iptables, or it found another way around. – trysis Mar 27 '16 at 18:14
  • I recently discovered that it doesn't work anymore. My Chromium has the "Cast" icon, but the extension can't install (it says it's installed, but in Preferences/Extensions it says "no extension installed"). It used to work up until a few weeks ago... – wazoox Dec 10 '16 at 16:52
  • In my case Chrome wasn't able to detect the device. Issuing iptables -I INPUT -p udp -m udp --dport 32768:61000 -j ACCEPT solved the problem. – Immanuel Weihnachten Jun 25 '17 at 19:15
  • 3
    All this is no longer necessary as of current Chrome/Chromium versions. – Dan Dascalescu Jun 28 '18 at 00:10
42

This answer no longer works because the extension has been discontinued; this answer is, however, being left as-is for historical reasons.

It looks as if all you need is the browser Chrome or Chromium and the extension below: https://chrome.google.com/webstore/detail/google-cast/boadgeojelhgndaghljhdicfkmllpafd

Thomas Ward
  • 74,764
azra
  • 437
  • 4
  • 2
19

pulseaudio-dlna

This project is in active development. From version >= 0.4.6 Chromecast is supported in addition to DLNA.

From Ubuntu >=16.10 pulseaudio-dlna is in the Universe repository.

For older versions the ppa ppa:qos/pulseaudio-dlna needs to be added first:

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

We can then install pulseaudio-dlna it with:

sudo apt-get install pulseaudio-dlna

It then can be run from a terminal or script with

pulseaudio-dlna [options]

It will add all DLNA and Chromecast client(s) available in the local network as an audio output device to select from the sound settings menu.

We can then stream the audio from any media player (or browser) to our Chromecast client.

For all options see the project's documentation at GIT.

Takkat
  • 142,284
7

Since this question was asked 2 years ago, it may be worth mentioning that after Feb 2016, on Xubuntu 15.10, it was as easy as:

  1. Install Chrome or Chromium for Linux
  2. Install the Google Cast browser extension from within Chrome

Cast the tab you want. Easy as that.

EDIT: Now the feature is built in:

screenshot

Pablo Bianchi
  • 15,657
dez93_2000
  • 1,201
5

I'm running Ubuntu 14.04 on my PC & Android 4.3 on my Phone.

First you need to plug the Chromecast in and change the TV source to that HDMI port.

Next install the Phone app from here on play store

Then use the Phone app to connect the Chromecast to your wifi and then it will update and reboot.

After that, go to your Ubuntu PC and open Chromium and install this app from the Chrome web store The Chrome-cast device is now listed. It's that simple.

For video file playback : Go to File > Open File locate the video and open. The Chromium browser has a media player built in. Then you can stream it. Remember to go "full screen" (press F11) :) That's it.

Here are the codecs that work in Chromium : http://www.chromium.org/audio-video

There are other projects like VLC or XBMC that are working on Chromecast compatability, so it won't be long until we can stream everything. If you use Steam you can install VLC or XBMC and stream from one Steam box to another already.

Zanna
  • 70,465
Michael
  • 91
  • Can we add subs to this build in player? Vlc chromecast suppor only in windos for now. – Vasil Valchev Dec 21 '16 at 17:59
  • I have not yet bought or tried Chromecast-2. If VLC do not support Chromecast for now, can 3D- HSBS movies be played through Bino, or SMPlayer to cast on TV? – bluepearlsky Jan 02 '18 at 18:26
4

I just got my chromecast device. It can stream YouTube and tabs from Chrome. Because Netflix is not available on Ubuntu you cannot stream movies from Ubuntu. Tab streaming gives you a lot of cool features. I already tried: streaming photos from Flickr, streaming videos from Vimeo, streaming music from SoundCloud or Google Music (I connected it to Receiver, so experience is awesome).

I did not see any issues with music streaming, but in video you can see some dropped frames (but not really, I watched some imdb.com trailers and overall it was fine).

I could not make Chrome with Chromecast play avi files from my local PC. It allows to stream it, but I see black screen on TV (I guess this is not supported).

And I did not do anything special to install Chromecast plugin on Chrome, it just works.

outcoldman
  • 141
  • 4
3

This was tested using Ubuntu 18.04+

There are several ways of sharing and streaming using either Chromecast or Chromecasr Ultras:

  1. Using Google Chrome with the Videostream App)
  2. Using SMPlayer or VLC, both of which have the option to Stream to Chromecast

SMPlayer enter image description here

VLC enter image description here

  1. Using Youtube (In Google Chrome):

enter image description here

This helps a lot when you are managing multiple rooms, kids, NetFlix accounts and more. Do note that if Chromecast is not detected, 99% of the time is the network configuration. You can find a lot of helpful advice at the Chromecast Help Page or going to the Troubleshooting Guide.

You can also share your desktop by using the Cast option in Google Chrome:

enter image description here

And after selecting any of the Chromecasts you would see something like this:

enter image description here

Luis Alvarado
  • 211,503
3

mkchromecast

sudo apt install mkchromecast
mkchromecast --video -i "~/Videos/Example.mkv"

Reference

Pablo Bianchi
  • 15,657
3

Chromium Version 70.0.3538.77 (Official Build) Built on Ubuntu, running on Ubuntu 18.04 (64-bit)

https://support.google.com/chromecast/answer/3228332?co=GENIE.Platform%3DDesktop&hl=en

enter image description here

enter image description here

3

You need Google Cast server app on the Ubuntu based PC or your NAS.

Chromecast device is new...
The question is: "Does this app exist yet?" It is a new opportunity for Linux developers.

More info on the Google developers page

Zanna
  • 70,465
  • 5
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Eliah Kagan Jul 29 '13 at 21:40
  • I tried to install http://mkchromecast.com/ on my 14.04.3 LTS system, but it did not work. Report on Package Installer :"Status : Error: Dependency is not satisfiable: python3-pychromecast." – bluepearlsky Jan 02 '18 at 18:46
2

I just recently managed to get my chromecast working with Chrome in Ubuntu, quite simply, I added the device with my mobile phone, and it magically appeared in Chrome in Ubuntu.

Zanna
  • 70,465
user167582
  • 41
  • 1
  • 1
  • 4
1

Simply click the Chrome Tools menu in the top right corner of your Chrome browser window. Then click Cast… More detail from google support

once
  • 175
0

With firewalld I had just to open a port range in your current zone:

firewall-cmd --get-active-zones
work
    interfaces: wlp0s20f3

In this case the zone is work.

firewall-cmd --permanent --zone=work --add-port=32768-61000/udp
firewall-cmd --reload

After this, chromecast worked without problem.

Zioalex
  • 151