Castnow streams music and movies on Chromecast
Linux Casting
![© Lead Image © Kiyoshi Takahase Segundo, 123RF.com © Lead Image © Kiyoshi Takahase Segundo, 123RF.com](/var/linux_magazin/storage/images/issues/2015/175/castnow/po-21519-123rf-kiyoshi_takahase_segundo_123rf-filmklappe_resized.png/650056-1-eng-US/PO-21519-123RF-Kiyoshi_Takahase_Segundo_123RF-Filmklappe_resized.png_medium.png)
© Lead Image © Kiyoshi Takahase Segundo, 123RF.com
Google's Chromecast device lets you stream content directly to your TV. Castnow connects to Chromecast from a Linux system.
Armed with an Android cellphone or tablet, you can easily feed content to the Chromecast dongle connected to your TV set. Just call a Chromecast-capable application, such as YouTube, Google Music, or the Vimeo Couch Mode app, tap the Chromecast icon, and a few seconds later, the desired content appears on your TV. Wouldn't it be great to be able to control Chromecast via your PC, though? Now, the Chromecast client Castnow [1] for Linux and Mac systems lets you control your Chromecast from a terminal window.
Casting with Castnow
Castnow is a command-line tool based on Node.js [2] that supports playing multimedia content on a Chromecast dongle – without having to touch an Android device. Castnow supports playing local music files or movies, YouTube clips, movies stored on the network, and even directly from torrents. The program also lets you connect to an existing Chromecast session and control it from your computer. You just need an Android or iOS device with the Chromecast application to set up the program.
The system requirements are a current version of Node.js and optionally a tool for recoding videos to Ffmpeg. On Ubuntu, you can install Node.js, including the matching package manager npm, in the Node.js package from the package sources – but even Ubuntu 14.10 has an ancient version of the framework. You will thus want to install Node.js from the PPA package source by Chris Lea [3] (Listing 1). The package source provided by NodeSource for Debian and Ubuntu [4], in contrast, takes you to a Node.js version that Castnow does not yet support.
Listing 1
Installing Castnow on Ubuntu
The Ffmpeg program for transcoding is also not entirely easy to install on Ubuntu because versions of the distribution since v12.04 rely on the Ffmpeg fork, Libav. You will have to wait for Ubuntu 15.04 "Vivid Vervet" for Ffmpeg to rejoin the package sources. Because Libav covers more or less all of the Ffmpeg feature scope, you can simply create a symlink on your system; Castnow now believes it has found Ffmpeg. Users of Arch Linux can install Node.js and Ffmpeg via the central Pacman package manager; alternatively, you will also find Castnow in the Arch User Repository AUR of late (Listing 2).
Listing 2
Installing Castnow on Arch Linux
Castnow is now ready for use. When you call it from a terminal window, as shown below, the program automatically grabs the first Chromecast dongle it finds on the network.
$ castnow <example-video>.mp4 $ castnow <example-video>.mp4 --device "<devicename>"
If you use multiple Chromecasts on your network, then you can address one of the devices specifically with the --device
option. You assign a name when you set up the dongle. You are shown the name in the Chromecast app on your phone (Figure 1). The name is also displayed on the Chromecast status screen unless it is playing something.
![](/var/linux_magazin/storage/images/issues/2015/175/castnow/figure-1/650059-1-eng-US/Figure-1_large.png)
Besides locally stored videos, Castnow also now streams web movies or YouTube clips directly off the web on your Chromecast. In addition to conventional sources, Castnow also supports BitTorrent downloads – for this to work, you need to add the URL for the torrent or a Magnet link to the Castnow command. Make sure you are not infringing on any copyrights. Because of the peer-to-peer protocol used by BitTorrent, you are automatically distributing what you download on the web. Be sure to download only non-copyrighted material in this way.
Amateur movie makers will appreciate the --tomp4
option that lets you convert virtually any video format with Ffmpeg to a format that Chromecast understands (typically H.264 or VP8). Thus, there's no need to convert movies from compact cameras or digital movie cameras to another format up front, thereby wasting storage space on your disk and potentially also wasting time. Listing 3 contains examples for populating your Chromecast with music or movies from your computer.
Listing 3
Populating Chromecast
While you are playing back a movie, you can press the Spacebar to pause; pressing it again restarts at the same point. Pressing M mutes the sound, and the Up and Down arrows increase and reduce the volume. You can tell from the cyan background how much of the movie is still missing (Figure 2). The Castnow developer has now added a feature for fast forwarding or rewinding movies with the Right and Left arrow keys. After appending multiple tracks to a pseudo-playlist, you can jump to the next title by pressing N. Pressing S quits the playback.
![](/var/linux_magazin/storage/images/issues/2015/175/castnow/figure-2/650062-1-eng-US/Figure-2_large.png)
Conclusions
As a command-line tool, Castnow logically lacks a neat interface, but it still fulfills its task well. Doing without a GUI makes the Castnow perfect for experimenting with your own developments and, for example, controlling a Chromecast device with a script. Even without a script, Castnow is very useful if you want to stream a movie on your TV set without detouring. For more complex projects, Castv2 [5] is also well worth looking into: It lets you implement Chromecast features in your own applications.
Infos
- Castnow: https://github.com/xat/castnow
- Node.js: http://nodejs.org
- Node.js PPA for Chris Lea: https://launchpad.net/~chris-lea/+archive/ubuntu/node.js
- NodeSource: https://chrislea.com/2014/07/09/joining-forces-nodesource
- Castv2: https://github.com/thibauts/node-castv2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.
-
SUSE Offers CentOS 7 Support with Liberty Linux Lite
SUSE's Liberty Linux support offering now includes CentOS 7, which means businesses won't be forced to migrate those servers for some time.
-
Ubuntu's App Center Finally Supports Local Installs Again
If you regularly download .deb files and would prefer a GUI method of installing, Ubuntu has your back.
-
AlmaLinux Now Supports Raspberry Pi 5
If you're looking to create with the Raspberry Pi 5 and want to use AlmaLinux as your OS, you're in luck because it's now possible.
-
Kubuntu Focus Releases New Iterations of Ir14 and Ir16 Laptops
If you're a fan of the Kubuntu Focus laptops or have been waiting for the right time to purchase one, that time might be now.
-
NixOS 24.05 Is Ready for Prime Time
The latest release of NixOS (Uakari) has arrived and offers its usual reproducible, declarative, and reliable goodness.
-
Linux Lite 7.0 Officially Released
Based on Ubuntu 24.04 and kernel 6.8, Linux Lite version 7 now offers more options than ever.
-
KaOS Linux 2024.05 Adds Bcachfs Support and More
With updates all around, KaOS Linux now includes support for the bcachefs file system.