Stream2Chromecast is a command line Chromecast media streamer for Linux. The tool can transcode unsupported formats in real time and play them on the Chromecast.
Those who prefer a GUI for for streaming videos to Chromecast can use Videostream for Google Chromecast, a Chrome extension that allows playing local videos (including formats that aren't directly supported by Chromecast) on your Chromecast. It supports subtitles, comes with iOS and Android remote controls, and more.
Stream2Chromecast features:
- cast audio and video to a Chromecast device;
- pass an URL to be played on the Chromecast; the file must be streamable and a Chromecast supported format since it can't be transcoded;
- can transcode any formats not supported by the Chromecast in real time (using FFmpeg or Libav), so you don't have to convert any video manually;
- provides basic control commands: pause / unpause / stop playback (currently this only works when not transcoding), set or mute volume;
- allows specifying a device when multiple Chromecasts are connected on the same network;
- supports passing custom custom transcoder parameters to ffmpeg or avconv (thanks to this, you can set the quality, add subtitles even though Stream2Chromecast doesn't directly support it, etc.);
- supports specifying the port to use for streaming media.
For audio-only files, no metadata (artist, title, cover image, etc.) is displayed by Chromecast.
You may be wondering how Stream2Chromecast compares to castnow, another command-line Chromecast player.
I initially wanted to write about both castnow and Stream2Chromecast. However, castnow had quite a few issues in my test under Ubuntu 16.04, such as stuttering playback for MKV files, subtitles didn't work with the "--tomp4" flag (which transcodes the video to MP4), and more.
Furthermore, castnow is currently looking for a new maintainer, and its last GitHub commit dates back to April, 2016, so it doesn't look like it will receive any improvements or bug fixes anytime soon.
Basic Stream2Chromecast usage
Notes:
- the instructions below assume you've installed Stream2Chromecast from the main WebUpd8 PPA (see the installation instructions below). If you install Stream2Chromecast manually, you'll need to use the full path to stream2chromecast.py (e.g.: "/path/to/stream2chromecast.py /path/to/my_media.mp4") for the commands below;
- the computer running Stream2Chromecast and the Chromecast device must be in the same network;
- ffmpeg or libav-tools are required for transcoding. If both are installed, ffmpeg is used by default.
To stream a supported media file (you can find a list of the media supported by Google Cast, HERE)
to your Chromecast, simply use the following command:stream2chromecast "/path/to/some-video.mp4"
Replacing "/path/to/some-video.mp4" with the exact path and filename of the video you want to play (e.fg.: stream2chromecast "/home/andrei/Videos/VIDEO1.mp4").In my test, Stream2Chromecast failed to connect to my Chromecast if I didn't specify the Chromecast IP address, while other tools, such as pulseaudio-dnla, didn't have this issue, so I'm guessing this is a bug.
If that's the case for you too, you can specify the Chromecast IP by adding the "-devicename" flag followed by the Chromecast IP address, to the stream2chromecast command, like this:
If that's the case for you too, you can specify the Chromecast IP by adding the "-devicename" flag followed by the Chromecast IP address, to the stream2chromecast command, like this:
stream2chromecast -devicename CHROMECAST_IP_ADDRESS "/path/to/some-video.mp4"
Where "CHROMECAST_IP_ADDRESS" is the Chromecast IP address. You can find out your Chromecast IP address either by looking at your router's connected devices list or from the Google Cast mobile app, under "Device settings", under "Information" (at the bottom of the Device Settings).
Note that if you're having the same issue as me, and you need to enter the device IP address, you must do this for all Stream2Chromecast commands!
In the same way, you can also specify the Chromecast name:
stream2chromecast -devicename CHROMECAST_NAME "/path/to/some-video.mp4"
If you want to play an unsupported format (you can find a list of the media supported by Google Cast, HERE) on your Chromecast, you need to add the "-transcode" flag and have either Libav or FFmpeg installed:
stream2chromecast -transcode "/path/to/some-video.avi"
Where "/path/to/some-video.avi" is the exact path and filename of the media file you want to play on your Chromecast. You can append other flags to this command, like "-devicename CHROMECAST_IP_ADDRESS", which I've mentioned above.
Stream2Chromecast also supports specifying custom transcoder parameters. As an example, here's a command that passes the device IP address, transcodes the video, and adds subtitles via a custom FFmpeg parameter (for FFmpeg only):
stream2chromecast -devicename CHROMECAST_IP_ADDRESS -transcodeopts '-vf subtitles="/path/to/some-video.srt"' -transcode "/path/to/some-video.avi"
Where CHROMECAST_IP_ADDRESS is your Chromecast IP address, "/path/to/some-video.avi" is the exact path and filename of the video you want to play on the Chromecast, and "/path/to/some-video.srt" is the exact subtitle path and filename of the subtitle file you want to use.More about the FFmpeg subtitle filters, HERE.
Update: the app now allows playing a supported file from an URL (the file must be streamable and cannot be transcoded). To play a file from an URL, simply use:
stream2chromecast -playurl URL
Where URL is the video file URL, e.g. "http://www.example.com/my_media.mp4".To stop stream2chromecast from streaming, either press Ctrl + C in the terminal where you ran the Stream2Chromecast (sometimes this can throw an exception / error - ignore it), or run the following command in a different terminal window:
stream2chromecast -stop
To view all the Stream2Chromecast options, run it in a terminal without any parameters:
stream2chromecast
Or visit the Stream2Chromecast GitHub page.Download / Install Stream2Chromecast
Ubuntu 16.04 and 14.04 / Linux Mint 18 or 17.x users can install Stream2Chromecast by using the main WebUpd8 PPA. Add the PPA and install it using the following commands:
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt update
sudo apt install stream2chromecast
If you don't want to add the PPA or you don't use Ubuntu, you can grab the deb from HERE or download Stream2Chromecast from GitHub (either via Git or by downloading the latest code as a .tar.gz archive - HERE's a direct link).
Report any bugs you may find @ GitHub.
Also see: How To Stream Audio To A Chromecast Or DLNA / UPnP Device From Linux (Using pulseaudio-dnla)
Thanks to Mahdi for the tip! Image via Wikipedia.