Terminalcast
Command line tool to cast local video files to your chromecast.
Inspired by https://github.com/keredson/gnomecast
Supported media types
Checkout https://developers.google.com/cast/docs/media for your Chromecast model.
Use ffmpeg to convert unsupported files to a supported format:
ffmpeg -i '{input_file}' -metadata title="{title}" -map 0 -c:v {video_codec} -c:a {audio_codec} -c:s copy '{output_file}'
Supported Chromecast versions
In principle this should work with any Chromecast which is supported by https://github.com/home-assistant-libs/pychromecast.
In practice, I discovered that a Chromecast with Google TV enables you to control the player via the remote control, which is very nice.
Installation
pip install terminalcast
Usage
Basic Usage
terminalcast my_video.mp4
Port Configuration
By default, a random free port is chosen. You can specify a fixed port if needed (e.g. for firewall rules):
terminalcast my_video.mp4 --port 8080
Alternatively, set the environment variable TERMINALCAST_PORT:
export TERMINALCAST_PORT=8080
terminalcast my_video.mp4
Reverse Proxy / Custom URL
If you are running terminalcast behind a reverse proxy (e.g. Nginx, Traefik) and want to expose the video via a specific full URL:
terminalcast my_video.mp4 --video-url https://my-server.com/cast/video
Alternatively, set the environment variable TERMINALCAST_VIDEO_URL:
export TERMINALCAST_VIDEO_URL="https://my-server.com/cast/video"
terminalcast my_video.mp4
Note: You must ensure that your proxy forwards requests from this URL to the local terminalcast server (default path is /video).
Known Hosts
If network discovery fails (e.g. due to network restrictions), you can specify known Chromecast IPs:
terminalcast my_video.mp4 --known-hosts 192.168.1.50,192.168.1.51
Alternatively, set the environment variable TERMINALCAST_KNOWN_HOSTS:
export TERMINALCAST_KNOWN_HOSTS="192.168.1.50,192.168.1.51"
terminalcast my_video.mp4
Temporary File Location
When selecting a different audio track, a temporary file is created. To speed this up, you can specify a directory for these files, ideally a RAM disk. A progress bar will be shown during this process.
The default priority is:
TERMINALCAST_TMP_DIRenvironment variable/dev/shm(RAM disk on Linux)/var/tmp- System default
Example:
export TERMINALCAST_TMP_DIR="/my/fast/disk"
terminalcast my_video.mp4 --audio-title "English"
Using as a Library
You can also use terminalcast as a library in your own projects. Environment variables like TERMINALCAST_PORT or TERMINALCAST_KNOWN_HOSTS are automatically respected.
from terminalcast import FileMetadata, TerminalCast, create_tmp_video_file
# 1. Get file metadata
filepath = "my_video.mp4"
media_file = FileMetadata(filepath=filepath)
print(media_file.details())
# 2. Select an audio stream (e.g., the first one)
audio_stream = media_file.audio_streams[0]
# 3. (Optional) Create a temporary file if a different audio track is needed
# This shows a progress bar and can take a callback for progress updates
def my_progress_callback(progress: float):
print(f"Conversion progress: {progress:.2f}%")
tmp_filepath = create_tmp_video_file(
filepath=filepath,
audio_index=audio_stream.index[-1:],
duration=media_file.duration,
progress_callback=my_progress_callback
)
# 4. Initialize TerminalCast
# You can pass known_hosts as a list of IPs and a specific port,
# or rely on environment variables.
tcast = TerminalCast(
filepath=tmp_filepath or filepath,
select_ip=False, # or True for interactive selection, or a specific IP string
# known_hosts=["192.168.1.50"], # Optional: overrides env var
# port=8080, # Optional: overrides env var
# video_url="..." # Optional: overrides env var
)
# 5. Start the server and play
print(f"Casting to: {tcast.cast.cast_info.friendly_name}")
tcast.start_server()
tcast.play_video()
# The video is now playing. The script will block here until playback is active.
# You might want to add logic to handle server shutdown, etc.
Contributing
Contributions are welcome! To set up your development environment:
- Clone the repository
- Install dependencies: This will install the project in editable mode with all development tools.
make install - Install the pre-commit hook: This will run quick checks before each commit.
pre-commit install - Run all checks: You can run all linters, type checks, and tests manually at any time.
make check
How is it working?
Terminalcast creates a little HTTP Server at your current machine and serves your media file there. Then it tells the Chromecast the play the stream served at your IP with the corresponding path. That's it! (The devil is in the details.)
Terminalcast uses Bottle to create a small app providing the media file. This app is served by Waitress.
On the other hand Terminalcast detects and plays the media via PyChromecast.
For file information and conversion ffmpeg-python is used.
Metadata
Release files for terminalcast 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| terminalcast-1.3.2.tar.gz | 11.6 kB | With provenance | Details for terminalcast-1.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| terminalcast-1.3.2-py3-none-any.whl | Python 3 | none | any | Details for terminalcast-1.3.2-py3-none-any.whl |
Total release size: 22.0 kB
Release files / terminalcast-1.3.2.tar.gz
| Download URL | terminalcast-1.3.2.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9043274d8e9eb8beb5d44d8cd2bffe4070bee533f9e9b5fdb893855a14750e78
|
|
BLAKE2b-256 checksum How to use checksums |
7d566795b55c8c05f049cdf6b1b4b507684abf7a025df1a60dc3c1acd14100c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 7, 2026.
Transparency logRelease files / terminalcast-1.3.2-py3-none-any.whl
| Download URL | terminalcast-1.3.2-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a78288b22ca8dc9f291015eeb9fcb0aa11db2e9a545142bc3ec4247abd34792
|
|
BLAKE2b-256 checksum How to use checksums |
67765198c21464252ec3d3525adbe5c1760c278303b70fc8d4ead730383b0759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 7, 2026.
Transparency logSecurity for terminalcast 1.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for terminalcast-1.3.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 7, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.