1. Home
  2. Linux
  3. Stream to chromecast on linux via the command line

How To Stream Videos To Chromecast On Linux Via The Command Line

Most people wouldn’t be surprised if they found out that Google’s $35 Chromecast dongle is the best selling media streaming device of all time. It’s true, and for good reason. For a very low amount of money, users can “cast” their favorite content from their mobile phones, tablets and even web browsers. There’s one drawback with this technology though: local content playback is challenging, and discouraged. Instead, Google wants users to buy into “cloud services”. This is annoying, especially for Linux users as we’re the type of technology users most likely to want to host and play our own content. Not to worry, though. There is a way to play local media files to the device. You can stream videos to the Chromecast on Linux via command line. In this article, we’ll go over exactly how to do it!

Installing NodeJS and NPM

Castnow works with the help of NodeJS, and it installs with the NPM tool. These two critical pieces of tech aren’t on many Linux distributions by default. As a result, you’ll need to install it in order to stream videos to Chromecast on Linux.

Ubuntu

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Arch Linux

sudo pacman -S npm

Debian

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Fedora

curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
sudo dnf install nodejs npm

OpenSUSE

sudo zypper install nodejs4

Other

Other Linux distributions not mentioned also have NodeJS. To install it, it’s best to go to the NodeJS website, and read through for the directions specific to your Linux-based operating system. Alternatively, search your package manager and install NPM/NodeJS.

Castnow

Castnow is on Github, and the source code is freely available for compilation and installation by hand. However, there’s really no need to do this, as the developer of this project makes it available as an NPM package. Installing an NPM tool is pretty easy.

sudo npm install castnow -g

When the Castnow tool is finished installing, you can start casting.

Using Castnow

If you’ve only got one Chromecast, Castnow will automatically detect it and use it as the default. As most people usually have one Chromecast, there’s not a real need to go into detail on how to connect to multiple devices. That being said, some people definitely do have multiple Chrome devices. If that’s you, and you’ve got more than one, use this command to specify what one to cast to on the command line: castnow --device "name of Chromecast".

Stream video

Videos can be streamed with Castnow to the Chromecast from any remote or local URL. To do this, first find out if your video is using the right codec, as the streaming software has a problem with certain video codes. This is why it’s best to use Mp4 video files with this tool.

Stream remote video with:

castnow https://website-with-mp4file.com/videofile.mp4

Play local video

Playing a local video is done best from your Linux PC. Try not to stream MP4 files over the network with remote directories, as this won’t work as well. Playback is best done with MP4 files, as Chromecast supports this format the best. However, Castnow does support live conversion with FFMPEG.

castnow /path/to/video.mp4

Or, convert the video to MP4 as it plays:

castnow /path/to/video.avi --tomp4

Play Music

You can play music with Castnow just like you would a video file. It works the same way as video.

castnow /path/to/song.mp3

or Stream the music file with:

castnow https://songwebsite.com/song.mp3

Other Options

There are many other things that Castnow can do to interact with your Chromecast, outside of just playing a video or song here and there. All of the options are various switches that are available to use. For example, want subtitles with your local video? Use the –subtitles switch. Want to loop the current video, or shuffle the queue? Use –loop and –shuffle respectively.

Suffice it to say, there are many different options that advanced users can dig into, to get the most out of Castnow and their Chromecast.  That being said: if all you want is the ability to play local and remote media files the directions above arre all that you need.

You can access Castnow’s full command list by going to a terminal window, and entering castnow –help. Alternativly, save the entire help file to a text file that you can refer to at any time with:

castnow --help >> ~/castnow-help.txt

This will put castnow-help.txt in /home/username/.

Conclusion

In the browser, Google’s Chromecast is a powerful tool. With it, users can broadcast anything from their favorite web pages, to music, movies and everything in between. Unfortunately, Google is an internet company. As a result, they’ve got no interest in allowing users to play local content. This doesn’t matter though, as Linux users are a creative bunch.

With the help of Castnow, users can get around Google’s wishes of a Cloud and “paid-content” only media consumption experience. Instead, they’re able to make good use of the Chromecast, and take it to the potential we all know it has hidden away.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.