mac-screen-cast
Stream macOS screen to browser over LAN. Uses ScreenCaptureKit for zero-copy capture, VideoToolbox for hardware H.264 encoding, and WebRTC for low-latency delivery.
Requirements
- macOS 12.3+
- Screen Recording permission
Running the tool will automatically prompt for permission. If denied, reset and re-trigger:
Alternatively, grant manually in System Settings > Privacy & Security > Screen Recording.
Installation
Usage
Just run it — you'll be prompted to pick a window:
After selecting a window, open the printed URL (e.g. http://192.168.1.100:8080) in any browser on the same network.
No TURN server is configured, so streams only work within the local network.
Options
| Flag | Description | Default |
|---|---|---|
-w, --window-id |
Window ID to capture (skips picker) | (interactive) |
-l, --list |
List visible windows | |
--width |
Max output width in pixels | 1280 |
--fps |
Target frame rate (1-60) | 30 |
--port |
HTTP server port | 8080 |
--json |
JSON output (use with --list) |
|
-h, --help |
Show help |
Examples
# Interactive: pick from a list
# List windows (find window IDs)
# List windows as JSON (for scripting)
# Stream a specific window
# 720p at 60 fps
# Custom port
Performance
Measured at 1280×772 @ 30fps with VideoToolbox hardware encoding on Apple Silicon (M-series):
| Metric | Value |
|---|---|
| Pipeline latency (capture → send) | 8–16ms (measured via /latency) |
| CPU usage | ~3% of one core |
| Memory | ~22 MB RSS |
| Frame rate | Stable 30 fps |
The pipeline is entirely GPU-accelerated: ScreenCaptureKit delivers GPU-resident buffers, VideoToolbox encodes on the media engine, and the CPU is only used for RTP packetization (~1ms per frame). Total end-to-end latency (server → browser display) on LAN is typically 30–60ms.
How it works
ScreenCaptureKit → CVPixelBuffer → IOSurface
→ VideoToolbox (H.264 encode) → FU-A RTP packets
→ rustrtc (WebRTC) → Browser
ScreenCaptureKit delivers GPU-resident CVPixelBuffers directly, avoiding a CPU readback. The IOSurface is passed zero-copy to VideoToolbox for hardware encoding. Encoded H.264 NAL units are packetized into RTP (FU-A fragmentation per RFC 6184) and sent over WebRTC via rustrtc.
Dependencies
- rustrtc — pure Rust WebRTC
- screencapturekit-rs — ScreenCaptureKit bindings
- videotoolbox-rs — VideoToolbox bindings
License
MIT