keepcalculator

06 Numbers and Powers

Stream Local Media to Chromecast via Command Line

Card No. 06·42283 · Updated · Standard formula, shown below

You can stream local media files to a Chromecast device directly from the command line using tools like castnow, catt, or chromecast-cli. These tools let you send video, audio, and images from your computer to a Chromecast or Google TV without opening a browser or using a dedicated media server. Below is a practical guide covering the main options, how they work, common pitfalls, and how to pick the right one for your setup.

What You Need Before Starting

All command-line Chromecast tools work on the same basic principle: your computer acts as the sender, and the Chromecast pulls the media from a URL. This means the file you want to stream must be accessible over your local network. The easiest way is to run a simple HTTP server in the folder containing your media. For example, python3 -m http.server 8080 serves the current directory on port 8080. Then you give the tool a URL like http://192.168.1.50:8080/movie.mp4.

You also need to know your Chromecast’s IP address or hostname. Most tools can discover devices automatically using mDNS, but if you have multiple Chromecasts, specifying the IP avoids confusion. You can find the IP in the Google Home app under the device’s settings.

Main Command-Line Tools

Three tools are widely used, each with different strengths:

  • catt (Cast All The Things) – actively maintained, supports subtitles, and can cast from YouTube and other sites. It also has a cast subcommand for files and URLs.
  • castnow – older but simple, focuses on local files and offers playback controls (pause, seek, volume) from the terminal.
  • chromecast-cli – a Node.js tool that supports a wide range of media types and can also control playback.

All three are installed via package managers: pip install catt, npm install -g castnow (or via git), and npm install -g chromecast-cli. Check the project documentation for the latest installation instructions.

How Casting Actually Works

When you run a command like catt cast http://192.168.1.50:8080/video.mp4, the tool sends a message to the Chromecast using the Cast protocol (based on Protocol Buffers over TLS). The Chromecast then fetches the media from the URL you provided and plays it. The computer is not continuously sending the video data; it only sends the URL and control commands. This is why the file must be reachable via HTTP – the Chromecast downloads it directly.

Because of this, your computer and the Chromecast must be on the same network, and the HTTP server must be accessible from the Chromecast’s IP. Firewalls on your computer can block the Chromecast from reaching the server, so you may need to allow incoming connections on the port you chose.

Step-by-Step: Cast a Local Video with catt

  1. Install catt: pip install catt (or pip3 install catt on some systems).
  2. Navigate to the folder with your media: cd /path/to/videos.
  3. Start an HTTP server: python3 -m http.server 8080 (keep this terminal open).
  4. Find your computer’s local IP: ipconfig (Windows) or ifconfig (macOS/Linux).
  5. Find your Chromecast’s IP via the Google Home app or use catt scan to list devices.
  6. Cast the file: catt -d "Living Room" cast http://YOUR_IP:8080/video.mp4 (replace the device name and IP).
  7. Control playback with catt pause, catt resume, catt seek 10, etc.

If you have only one Chromecast, you can skip the -d flag.

Common Problems and Fixes

Here are the issues people run into most often:

  • No device found – Make sure your computer and Chromecast are on the same Wi-Fi network. Some routers isolate clients, which blocks discovery. Try specifying the IP address manually.
  • Media won’t play – The Chromecast supports a limited set of codecs. MP4 with H.264 video and AAC audio is the safest bet. MKV files often contain subtitles or codecs that the Chromecast cannot handle. Convert the file first with a tool like HandBrake, or use a Plex server that transcodes on the fly.
  • HTTP server not accessible – Windows Firewall or macOS’s application firewall may block incoming connections. Allow Python or Node.js to accept incoming connections, or try a different port.
  • Subtitles not showing – catt supports sidecar subtitle files (SRT) if you name them the same as the video and place them in the same folder. Use catt cast -s subtitle.srt video.mp4.
  • Buffering or lag – This is usually a network issue. Ensure your Wi-Fi signal is strong, and consider using an Ethernet connection for the computer if possible.

Comparing the Tools

catt is the most feature-rich and actively maintained. It handles subtitles, supports casting from YouTube (with catt cast https://youtu.be/...), and has a clean command structure. castnow is simpler but has not been updated in years; it may not work with newer Chromecast firmware. chromecast-cli is a good middle ground, but its development has slowed. For most users, catt is the recommended choice.

All three tools are free and open source. They work on Windows, macOS, and Linux, though you may need to install Python or Node.js first.

Alternative: Use a Media Server

If you frequently stream local media, a dedicated media server like Plex or Jellyfin provides a more robust solution. These servers transcode formats the Chromecast cannot handle natively and offer a web interface for browsing. However, they require more setup and resources. For occasional casting, the command-line approach is lighter and more direct.

Another alternative is to use the cast feature built into some video players like VLC, which can send a file to a Chromecast via a GUI. But that is not command-line.

Frequently Asked Questions

Can I cast a file from a remote server (not my computer)?

Yes, as long as the URL is accessible to the Chromecast. For example, you can cast a public URL like https://example.com/video.mp4 directly with catt cast. If the server requires authentication, you may need to use a tool that supports headers, but most simple tools do not.

Why does my Chromecast not see the HTTP server?

The most common cause is a firewall blocking the port. Also, ensure the HTTP server is listening on 0.0.0.0 (all interfaces) rather than just localhost. Python’s http.server binds to all interfaces by default, but other servers may not.

Can I cast a whole folder of videos?

catt does not have a batch mode, but you can write a simple shell loop to cast each file sequentially, or use a playlist feature if your media player supports it. Alternatively, use a media server like Plex to browse and cast multiple files.

Does this work with Google TV or Chromecast with Google TV?

Yes, these tools work with any device that supports the Cast protocol, including Google TV. The device appears in the discovery list just like a regular Chromecast.

Is it safe to use these tools?

Yes, they are open source and widely used. However, be cautious when casting from untrusted URLs, as the Chromecast will fetch whatever the URL points to. Also, running an HTTP server on your network exposes that folder to other devices on the same network – only run it when needed and turn it off when done.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →