Hacker News new | comments | ask | show | jobs | submit login
How to send local files to Chromecast with Python (rinzewind.org)
242 points by rinze 9 months ago | hide | past | web | favorite | 55 comments



I'm surprised no one has mentioned Videostream! Works so smooth, and there's an iOS app so you don't need your computer for play back control.

https://getvideostream.com/

I also recently downloaded Soda Player for OSX to stream, and it also has similar capabilities.


> so you don't need your computer

.. which I have. Now I need an iOS device.

Or set up a GET endpoint with the python library and access that from my mobile device of choice


I should have said mobile app.

My TV is not in the same room as my computer setup, so it is more convenient for me to control with a smartphone.


You can also control from the computer or an Android device


VideoStream has also successfully played every filetype I've thrown at it. My only gripe is that it will lag on high bitrate videos (e.g. 9GB for a 2 hour long movie).


+1 for videostream, it's an amazing app that I use almost daily. I paid for the premium version (playlists, download notifications etc) and it's well worth it.



When I read the original article, my first thought was: wow, someone could or should really build an interface on top of this that let's you cast all things.

Looking at this GitHub project, looks like it lets you do exactly that.


Yep, I had the same thought a while ago, which is why I built catt! It's come along very nicely, it works well and it's especially suitable if you run it as part of some automation (for example, you can make an Alexa skill to cast videos to your TV from various sources).


VLC also has similar functionality as of version 3.0.


VLC also does transcoding of video formats that Chromecast does not support. For the python script, you have to ensure the video format is supported by Chromecast [1].

[1] https://developers.google.com/cast/docs/media


There is also nice app: http://getvideostream.com/


You can just cast anything using Chrome anyway...if you expand the dropdown in the top right there is a "Cast..." menu item right there.


That's not the same. If websites don't implement a cast app themselves, then Chrome will just mirror the tab to the TV. Whereas catt and similar tools will actually direct the chromecast to download the video file directly and play it. This makes a big difference to quality and performance.


While this is true, newer Chrome versions have a feature where if you fullscreen a video in a tab, it will (within a few seconds, if the video is in a directly supported format) attempt to send the video directly to the Chromecast instead of mirroring the tab. It doesn't always work, but it's much smoother when it does.


That's nice; historically when i did that I'd lose the borders but quality would suffer. Admittedly i mostly did it with streaming content that was not CC compatible though.


So what you're saying is that it's probably better to use a browser, because your bandwidth between your PC and your TV is likely to be much better, as well as having the capability to cast not only web content but also anything on your desktop. Plus a mirror is much easier to control, and some cast capable devices may not have the memory to "download" video files.

What am I missing here? You seem to think it's a bad thing.


You're double encoding, and you're not saving bandwidth because you still have to download from the remote source.

It's like one of those old FM adaptors for cars, or more pertinently - making a JPG of a GIF - everything gets worse.


sending a video stream from a file on your disk on a computer results in higher quality video on the television than playing a video in your browser and encoding a stream of your browser window and sending that to the chromecast to display on the TV.


Why would the bandwidth be better? I don't see a difference between a Chromecast making network requests or my PC doing it.

Also casting your desktop is encoding the desktop. The quality is worse.

The only advantage is for casting content with no native support.


Unless of course I don't have chrome on my headless computer? Solutions like this are far better.


Fantastic. Is there a library like this for Roku?


I'm using castnow, a cli in nodejs and has support for streaming torrents and local files

https://github.com/xat/castnow

Edit: from Python to nodejs


Castnow is great, but it is written in node.js not python.


You are right, i thought it had a dependency on Python (checked it in the past) and interpreted it as Python.

While checking it, no idea where that came from.


What about the opposite? Are there any good server libraries to cast content to as opposed to casting content from?


This used to be possible, but IIRC Google locked things down and the cast receiver apps for Android stopped working.


Look for miraclecast


Another alternative that worked pretty well for me with Linux: http://mkchromecast.com/


a GUI that does exactly that (and the occasional transcoding / reboxing when necessary, to handle mkv files, etc.): https://github.com/keredson/gnomecast


Yey! Note that, much to my unhappiness (see issue #42) transcoding is a process that blocks the streaming from starting, which can take several minutes at 100% CPU.


yeah, that's a sticky problem unfortunately. on the plus side real transcoding is pretty rare given h264 is pretty much everywhere now. most of the "transcoding" gnomecast does is repackaging an unmodified h264 stream from one container format to another, which FFMPEG can do at 30-100x (rather than 1-2x for real transcoding).


Woah this is really, really cool! I've been meaning to mess with chromecast and this does all the heavy lifting for me!

I think I'm going to wrap the script to get a REPL so that I don't loose access to the object, similar to what I did for AWS: https://github.com/russellballestrini/botoform/blob/master/b...


SimpleHTTPServer is no longer part of python 3. On Python 3 this `python -m SimpleHTTPServer` should be `python -m http.server`


python2 will work for many years to come.

     python2 -m SimpleHTTPServer


I normally just use LocalCast (http://www.localcast-app.com/), although there may be a use case for a kind of "jukebox" application using PyChromecast.


I have http://movies.foamsnet.com/url/ bookmarked. Give it a URL, and it will send it to Chromecast and provide playback controls in your browser.


I am using a tool called AirFlow - has built in support for subtitles which was the first thing I look for when chromcasting. Even though it's not free, it's an amazing tool. (not affiliated with them at all)


Interesting. Is it known which libraries the Chromecast uses under the hood? Given that RCE exploits are commonplace for media/codec libraries, this can easily be used to get a decent jailbreak on the thing...


It has been semi-jailbroken in the past, but Google has always very quickly closed anything.

Chromecast (device, protocol, libraries, firmware) are Google’s most user-hostile and restrictive project so far.


Chromecast even stops working if you do not have a working outside internet connection. On many occasions I've been unable to cast movies to chromecast simply because my internet connection was broken.

After some time it bothered me that I had a machine plugged in 24/7 connected to both my local LAN and Internet, owned by Google. So, every night I unplug the chromecast and then plug it again whenever I want to cast something.


If physically disconnecting it is easy enough then I'd agree that is preferable. Only plug it in when required.

How about creating a firewall rule and then toggling that instead of physically disconnecting the Chromecast? I found a likely configuration: https://blog.g3rt.nl/allow-google-chromecast-host-firewall-i...


Chromecast basically just uses Chrome under the hood. I imagine this tool is just creating a video tag.


AFAIK it is actually using a proprietary streaming protocol called CASTv2. It has been a community effort to reverse engineer the protocol and write implementations.

Some useful links:

https://github.com/vincentbernat/nodecastor // one of the earliest attempts of figuring out CASTv2

https://github.com/thibauts/node-castv2 // one of the first libraries to support chromecast streaming based on the works of vincentbernat.


This would be great if it worked. It's pretty simple, just pip install pychromecast and call pychromecast.get_chromecasts() in the repl. This returns an empty list for me every time.


Is your Chromecast on the same subnet as your computer? If not, autodiscovery won't work.


I believe so, it works for my browser and phone.


This is awesome! I gave up on my hopes of doing custom stuff with my chromecast when I discovered there was a pricetag on the developer license, but this could be handy!


Does this also work with the Chromecast audio? and if not does anyone know of any great open tools for that hardware?


It looks like pychromecast implements the Google Chromecast API, so any Chromecast audio devices should show up in the list for pychromecast.get_chromecasts()

https://github.com/balloob/pychromecast


Nice, I'll have to try and play around with that to see if I can create some Sonos/Heos like functionality.


Great. Casting is broken on Chromium from the Debian stretch stable repos.


generally, you can cast anything from a Chrome browser tab, so just open those files in a new tab and cast away.


im pretty sure you can open chrome and just drag a local video into a tab and then chromecast the tab.


The quality of doing that however, is not great




Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: