subeichen1

casthub

CastHub is an open-source LAN casting tool that streams local videos from a Windows PC straight to Android TV and DLNA televisions, with no cloud upload, cable or USB drive involved.

v0.3.6
Published at
1d ago
59
Stars
1.4k
Download

Latest release

v0.3.6Dec 4, 2026, 05:58 AM
Downloads slow? Switch the source anytime above

README

Project Overview

CastHub is a LAN casting tool for home users who want to put a local video from a PC onto a TV without a USB stick or a cloud upload. It has three parts: a PC hub, a browser console, and an Android TV client. The hub serves REST, media streams and the control channel on port 9420, while the TV app listens on 9417 for instructions. When a TV cannot install apps, the same hub degrades into a DLNA/UPnP control point and drives the TV's built-in player instead.

Item Value
Platform Windows 10/11, macOS, Linux, Android TV 6.0+
Stack Node.js 22 + TypeScript + Fastify + ws; TV app in Kotlin + Media3
Ports Hub on 9420 (HTTP/WS), TV app on 9417 (WS)
License MIT
TV app size About 8 MB

Media never leaves the local network, and it never passes through a third-party relay.

Key Features

  • One-click casting: browse the library in the console and push a video to the TV, with play, pause, seek and stop taking effect immediately
  • Pick subtitles first: probe embedded and sidecar tracks before casting and list them by language tag such as Simplified Chinese, Traditional Chinese or English; the chosen track wins over the default policy
  • Resume by path: positions are stored per absolute file path and shared between the app and DLNA devices, so re-casting the same file continues where it stopped
  • DLNA fallback: an SSDP M-SEARCH every 60 seconds finds renderers on the same subnet, no pairing code needed, so older TVs still work
  • TV assistant: reads ro.build.version.sdk and ro.product.cpu.abilist over ADB to match a variant, then installs CastHub TV, Aerial, TVBox or Hongguo Drama TV
  • Pairing memory: the 8-digit code lives on the TV and in data/devices.json, so a restart on either side reconnects automatically
  • Play queue: DLNA only; after the current item ends the hub waits DLNA_AUTO_NEXT_DELAY_MS (1500 ms by default) before the next one
  • Episode detection: the library recognises names like S01E02, "episode 3" or EP4 and shows an episode badge

Console and Cast Path

  • Device cards: add a TV by entering ws://<TV IP>:9417 and its 8-digit code; a TV that drops mid-cast shows as offline, and a rotated code shows a re-pair action that asks only for the new code while keeping devices, history and queue
  • Control-plane auth: the hub generates a console token into console-token.txt, while media URLs are HMAC-signed
  • Endpoint split: /api/files lists folders, /media/* serves HTTP Range requests (seeking depends on it), and /console is the WebSocket control channel
  • Where data lands: data/casthub.db by default, falling back to data/casthub-history.json when better-sqlite3 cannot be installed
browser console --WS /console--> PC hub (9420) --WS--> TV app (9417)
                                     |--HTTP /media (Range)--> ExoPlayer

Quick Start

  1. Install Node.js 22.19 or newer, clone the repo, then run cd server && npm install && npm start
  2. Open http://<PC LAN IP>:9420 and paste the token from console-token.txt
  3. Put videos in server/media, or point the MEDIA_DIR environment variable at your own folder
  4. Install CastHub-TV.apk on the TV and note the ws://<TV IP>:9417 address and 8-digit code it shows
  5. Add the TV under Devices, wait for it to turn online, then pick a video and press Cast
  6. On the remote: OK plays or pauses, left and right seek by 10 seconds, back stops and returns to the pairing screen

System Requirements

Item Requirement
PC hub (desktop build) Windows 10/11, no Node.js needed
PC hub (from source) Node.js 22.19 or newer on Windows, macOS or Linux
TV app Android 6.0 (API 23) or newer
Network PC and TV on the same LAN, AP isolation disabled
Optional ffmpeg and ffprobe for extracting embedded subtitles

Notes

  • Port 9420 must be allowed: the Windows firewall prompt on first run has to be accepted, otherwise the console opens but the TV cannot pull the stream
  • No transcoding: a DTS track usually plays as picture without sound, so swap in a source with AAC audio
  • Subtitles lock at start: tracks cannot be switched during playback, and image subtitles (PGS/VobSub) fail outright in server-subtitle mode
  • TCL and Thunderbird TVs need USB: those firmwares refuse adb install, so the TV assistant skips ADB and shows USB or multiscreen-push steps
  • Single-user design: playback state is kept in memory and the queue is cleared on restart, which suits home LAN use

Release history

Sort