Skip to content
shellbearPublic

About

🦫 Stream any video from your Mac to Apple TV, Chromecast, and Smart TVs. Native, open source.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

36 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Castor app icon: a close-up beaver face with two big front teeth
Castor

Stream any video from your Mac to Apple TV, Chromecast, and TVs with AirPlay or Google Cast built in β€” native, fast, open source.

Castor lives in your menu bar. Queue videos, pick a device, and they play on your TV at the highest quality the device can decode β€” bit-exact original streams whenever possible, and a conversion that never leaves the GPU when one is unavoidable.

Latest release CI Platform License: MIT

⚠️ Early development. The core works; edges are rough. Issues and PRs welcome.

Install

Homebrew

brew install shellbear/tap/castor
castor            # opens Castor in the menu bar

Nothing else to install: the app carries its own ffmpeg.

Download a build

Latest release β€” a universal build, or a smaller per-arch slice:

Mac Download
Apple Silicon castor-arm64.tar.gz
Intel castor-x86_64.tar.gz
Universal castor-universal.tar.gz

The builds are ad-hoc signed, so clear the quarantine flag on first run:

tar -xzf castor-*.tar.gz                           # β†’ castor + Castor.app (keep them together)
xattr -dr com.apple.quarantine castor Castor.app   # ad-hoc signed β†’ clear Gatekeeper

Every release ships SHA-256 checksums; see the releases page for all versions.

From source

See Building; make install puts castor and Castor.app into your Homebrew prefix (or /usr/local).

Features

  • πŸ“Ί AirPlay & Chromecast β€” Google Cast protocol implemented natively in Swift; AirPlay through AVKit external playback
  • 🎯 Quality first β€” a decision engine picks the cheapest path: direct play (serve original bytes) β†’ remux (repackage, no re-encode) β†’ transcode (last resort). A transcode keeps what the device can show: 10-bit HEVC for devices that decode it, so bit depth and HDR survive; H.264 scaled to 1080p for those that don't, with HDR tone-mapped to SDR on the GPU so colours stay right instead of going grey
  • ⚑ Fast and light β€” remuxing runs at hundreds of times realtime; a full movie is ready to seek in seconds. Transcodes decode, scale and encode on the GPU without frames ever visiting main memory
  • 🎞️ Playlist β€” queue videos or drop a whole folder; the next one starts by itself on the same device
  • πŸ” Full seeking, even mid-transcode β€” a predicted VOD playlist plus keyframe-aligned encoder restarts means the seek bar always spans the whole film, and every restart lands on the same clock so sound stays with the picture
  • πŸ’¬ Subtitles β€” text tracks (SRT/ASS) inside the file or in files next to it, on Chromecast and AirPlay alike, switchable while watching. Blu-ray and DVD picture subtitles (PGS/VobSub) are burned into the video. Forced tracks are enabled automatically to match the audio language
  • πŸ”Š Audio tracks β€” pick the language. Over AirPlay every track is sent side by side and switching is instant; a Chromecast gets the chosen track and restarts at the same spot when it changes
  • 🧠 Remembers β€” the playlist, and the audio and subtitle tracks you picked for each video, are there at the next launch; optionally what was playing when you quit resumes by itself
  • 🎬 AV1 β€” decoded by the AV1 chip on Macs that have one (M3 and later) and in software everywhere else
  • ⌨️ Media keys β€” the keyboard's play/pause, headphone buttons and Control Center drive the TV
  • ⏯️ Resumable β€” progress is saved continuously; quit mid-movie and pick up where you left off, on any device
  • 😴 Stays out of the way β€” keeps the Mac awake only while a video plays, cleans up after itself when the film ends or you quit, and can open at login
  • πŸ”— Scriptable β€” a castor command and a castor:// URL scheme (cast, toggle, stop, resume-last) for Raycast, Shortcuts, or shell scripts

How it works

Casting protocols don't push video β€” they hand the TV a URL and the TV pulls. Castor runs a local HTTP server and tells each device to fetch from it:

 file ──► ffprobe ──► planner ──┬──► direct play (Range requests, bit-exact)
                                β”œβ”€β”€β–Ί remux-ahead (-c copy β†’ fMP4 HLS, ~500Γ— realtime)
                                └──► transcode  (VideoToolbox HEVC/H.264, seekable VOD HLS)
                                          β”‚
                              local HTTP server (CORS + Range)
                                          β”‚
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 Chromecast          Apple TV            other Smart TVs
              (CASTv2 protocol)  (AVPlayer external      (DLNA β€” roadmap)
                                     playback)

Measured on an M3 Pro:

Path Speed Cost
Remux to fMP4 HLS (-c copy), 82 min 1080p 10-bit HEVC Blu-ray rip 517Γ— realtime β€” whole movie in 9.5 s ~1 s of CPU in total
1080p 10-bit HEVC β†’ H.264 12 Mbps 8Γ— realtime 0.05 s of CPU per second of video, 157 MB
2160p 10-bit HEVC β†’ 1080p H.264 7Γ— realtime 0.05 s of CPU per second of video, 468 MB
1080p 10-bit HEVC β†’ H.264 with Blu-ray subtitles burned in 8Γ— realtime 0.45 s of CPU per second of video, 657 MB

The transcode rows use generated 20–40 s test clips. Their speed is set by the hardware encoder; the cost is low because decoded frames go from VideoToolbox's decoder through its scaler to its encoder without being copied to main memory. The same 1080p transcode with ffmpeg's default frame handling takes 4.7Γ— the CPU time and twice the memory for the same speed. Burning in picture subtitles is the exception: ffmpeg draws them on the CPU, so frames come down once.

Because compatible files are never re-encoded, what your TV decodes is the same bitstream a Blu-ray player would send over HDMI. When transcoding is required, color metadata is preserved and bitrate is spent generously β€” the LAN doesn't care.

Requirements

  • macOS 14+
  • Nothing else for the release builds. Builds from source use Homebrew's ffmpeg (brew install ffmpeg) unless you build Castor's own with make ffmpeg

From the terminal

The castor command opens the app and forwards commands to it:

castor                                         # open Castor in the menu bar
castor cast ~/Movies/film.mkv                  # pick a video
castor cast film.mkv --device "Living Room TV" # ...and cast it there once the device is found
castor toggle                                  # play or pause
castor stop
castor resume-last                             # resume the last unfinished video

The same commands exist as URLs (castor://toggle, castor://cast?path=/path/to/film.mkv&device=Living%20Room%20TV) for Shortcuts and Raycast. Videos and folders can also be opened with Castor from Finder (Open With) or dropped on its menu.

If something misbehaves, Castor's activity log helps:

log show --last 10m --info --predicate 'subsystem == "com.shellbear.Castor"'

Building

brew install xcodegen ffmpeg   # ffmpeg here also generates the test clips
git clone https://github.com/shellbear/castor && cd castor
make build   # generates Castor.xcodeproj, builds the app
make run

make install builds the release app and installs castor + Castor.app into your Homebrew prefix (make install PREFIX=~/.local installs elsewhere); make app just builds them into build/release/.

make test runs the engine test suite: protocol codec, planner matrix, HTTP range serving, and real conversions through VideoToolbox (10-bit HEVC output, GPU scaling with its software fallback, burned-in subtitles checked in the output pixels, AVFoundation reading subtitle renditions from the local server).

Release builds carry their own ffmpeg, built from source by scripts/build-ffmpeg.sh as an LGPL, dependency-free pair of programs with only the encoders, muxers and filters Castor uses. make ffmpeg builds it for your Mac; make dist builds exactly what a release publishes (it needs brew install nasm for the Intel half). To run the tests against it:

CASTOR_FFMPEG_DIR="$PWD/build/ffmpeg/bin" make test

CASTOR_FFMPEG_DIR works for the app too, if you want it to use a particular ffmpeg.

On first cast, macOS will ask for Local Network permission β€” Castor needs it to discover devices and serve them media.

Architecture

The repo is a thin SwiftUI app over a UI-free Swift package:

App/                      menu bar UI (SwiftUI MenuBarExtra)
Packages/CastorEngine/
  Discovery/              Bonjour browsing (_googlecast._tcp)
  Probe/                  ffprobe wrapper β†’ MediaInfo; what this ffmpeg can do
  Planner/                direct play / remux / transcode decisions
  Streamer/               ffmpeg sessions and arguments, HLS playlists, seek-restart
  Server/                 HTTP server: Range, CORS, HLS routes
  Cast/                   CASTv2: protobuf codec, TLS channel, media controller
  AirPlay/                AVPlayer external playback
  History/                resume positions (JSON)
  Subtitles/              tracks and sidecar files β†’ WebVTT, burn-in choices
  Commands/               castor:// URLs β†’ commands

Everything protocol-shaped is unit-tested; CastorEngine never imports UI frameworks.

Releasing

MARKETING_VERSION in project.yml is the single source of truth for the version, and CHANGELOG.md for the release notes. To release: bump the version, rename [Unreleased] to ## [X.Y.Z] - YYYY-MM-DD, commit, then run make release. It pushes main and waits for CI to pass there, then tags, waits for the Release workflow to publish the universal and per-arch archives, and points the Homebrew tap (shellbear/tap/castor) at them. CI cannot push to the tap, so that last step runs with your own git credentials; ./scripts/update-tap.sh --dry-run shows the formula change first.

Releases are ad-hoc signed unless the repository has these secrets, in which case they are signed with a Developer ID, notarized and stapled, and open on any Mac without the quarantine step:

Secret What it is
DEVELOPER_ID_P12 "Developer ID Application" certificate and key, exported as .p12, base64-encoded
DEVELOPER_ID_P12_PASSWORD the password chosen for that export
NOTARY_KEY App Store Connect API key (.p8), base64-encoded
NOTARY_KEY_ID, NOTARY_ISSUER_ID that key's ID and issuer ID

The signing path has only been exercised with an ad-hoc identity so far (the hardened runtime included); the first release with real credentials is its first real test.

Roadmap

Before 1.0:

  • Proof on real hardware: the Chromecast and AirPlay paths are covered by tests against recorded protocol messages and local players, not yet by a matrix of actual devices
  • A Developer ID for notarized builds (the pipeline is ready, see Releasing)

Later:

  • DLNA/UPnP for Smart TVs without Cast or AirPlay
  • Screen mirroring
  • Styled-ASS fidelity
  • Instant audio switching on Chromecast too (AirPlay has it; Chromecast's needs a device to verify against)
  • Raycast extension on top of the castor:// scheme
  • Sparkle auto-updates

Why "Castor"?

Castor is French for beaver β€” an industrious builder who lives in streams. It's also a star in Gemini and happens to contain "cast". The name was too good to pass up.

License

MIT

About

🦫 Stream any video from your Mac to Apple TV, Chromecast, and Smart TVs. Native, open source.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages