Turn an Android TV into a second screen for a Windows PC, over Wi-Fi or Ethernet. No cloud, no accounts, no browser tab — one small exe, one APK, and the TV behaves like a monitor you can use from the sofa.
host/— runs on the Windows PC. Captures a display with FFmpeg, encodes H.264, and serves it on the LAN. Also injects the TV remote as a real mouse/keyboard on Windows.android/— the Android TV app. Finds the PC, decodes the stream with hardware H.264 decoding, and forwards remote-control input back.
No cloud, no accounts, no drivers required for mirroring. Everything stays on your local network.
Windows PC (host) Android TV (app)
───────────────── ────────────────
FFmpeg: capture → H.264 ──── TCP 47900 ──────────► MediaCodec → SurfaceView
user32: mouse/keyboard ◄──── TCP 47901 ────────── remote / D-pad → JSON
UDP 47811 discovery ◄──────── broadcast ────────► "which PC is out there?"
Download them from the Releases tab — v1.0.0
ships the APK and both Windows zips. Building from source puts the same files in
dist/; the scripts in tools/ cache their toolchains in .build/.
| Asset | What it is |
|---|---|
beambox-windows-x64.zip |
Start here on the PC. BeamBox.exe (Node and the host embedded), ffmpeg.exe, and a quickstart. Unzip the whole archive, keep both files together, run the exe. |
beambox-windows-portable.zip |
Packer-free fallback: node.exe, the host sources, koffi's Windows binding and start.cmd. Use it if the single exe ever fails to load its native input binding. |
beambox-tv.apk |
The Android TV app. Sideload it with adb install or a file manager. |
beambox-1.0.0-source.zip |
Source snapshot of the tagged release. |
The Windows zips are not byte-reproducible — the packer embeds build timestamps — so a rebuild from the same commit behaves identically but hashes differently.
bash tools/build-android.sh # JDK 17 + Android SDK + Gradle, then the APK
bash tools/build-exe.sh # BeamBox.exe + zip with FFmpeg
bash tools/build-portable.sh # node.exe folder bundle
python3 tools/make-icons.py # only after editing the icon drawingThe icon (and the Windows exe icon plus its Properties tab) is generated from one
drawing by tools/make-icons.py, so design/icon-1024.png, the Android launcher
icons and the TV banner always match.
The APK is a debug build, so it is signed with a debug key: fine for a TV box
you own, not for the Play Store. The exe needs no Node.js install; the portable
bundle ships its own node.exe.
Windows PC
- Windows 10 or 11 (64-bit)
- Node.js 18 or newer
- FFmpeg with H.264 support. The easiest option:
winget install Gyan.FFmpeg(the "full" build includesddagrab), or- download from https://www.gyan.dev/ffmpeg/builds/ and add
bintoPATH
- PC and TV on the same network (Ethernet on either side is best; 5 GHz Wi-Fi is fine)
Android TV
- Android 5.0 (API 22) or newer, with an H.264 decoder (every TV box has one)
- Android Studio 2022+ (Hedgehog or newer) and JDK 17 to build the APK
cd host
npm install
npm startThen allow the Windows Firewall prompt (tick Private networks). If you miss the prompt, add the rules from an administrator PowerShell/CMD:
netsh advfirewall firewall add rule name="BeamBox TCP" dir=in action=allow protocol=TCP localport=47900-47901
netsh advfirewall firewall add rule name="BeamBox UDP" dir=in action=allow protocol=UDP localport=47811Double-clicking the exe on Windows opens a control panel in your browser at
http://127.0.0.1:47902; from a source checkout, npm start -- --gui does the
same. It drives the running host:
- live status — which TV is connected, the encoder actually in use, throughput and uptime
- a display picker (it reads the real monitor list) plus a hand-editable capture region
- encoder, frame rate, bitrate and output size, applied immediately without restarting
- remote input on/off, auto-discovery on/off, start-streaming and open-panel options, PC name and ports
- Open firewall ports adds the rules above for you (run elevated)
- restart the encoder, or disconnect the TV
- the host log, so a black screen shows its reason right in the panel
The panel only listens on loopback and every launch gets a fresh token, so no
other machine — and no random web page — can drive it. Settings are saved to
%APPDATA%\BeamBox\config.json and reused next time.
The host prints its LAN addresses and the ports it listens on. Options:
| Option | Meaning |
|---|---|
--bounds x,y,w,h |
Capture only this rectangle of the desktop and keep the TV pointer inside it |
--source gdigrab |
Default. Grabs the desktop surface (works with virtual displays) |
--source ddagrab |
DXGI Desktop Duplication — much faster, needs FFmpeg 6+ |
--display N |
Monitor index for ddagrab |
--encoder qsv|libx264|nvenc|amf |
Default qsv (Intel QuickSync); nvenc for NVIDIA, amf for AMD, libx264 for any CPU |
--fps 60 |
Frame rate (30 halves CPU load) |
--bitrate 12M |
Video bitrate |
--height 720 |
Send a smaller picture (native, 1080, 720, 480 or 360) |
--ffmpeg C:\path\ffmpeg.exe |
Explicit FFmpeg path |
--no-input |
Stream only; ignore remote input (view-only) |
--no-discovery |
Disable UDP discovery (connect by IP) |
--gui |
Open the control panel (the exe does this when double-clicked) |
--no-gui |
Console only, never open the browser panel |
--gui-port 47902 |
Port for the control panel |
--probe |
Print the detected config and exit |
--list-displays |
List each display's bounds and print a ready-to-paste --bounds command |
List your monitors first — the host does this for you on Windows:
node src\index.js --list-displaysIt prints a table plus a ready-to-paste command. The same information by hand:
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens | % { $_.DeviceName + ' ' + $_.Bounds }"Then capture just the second monitor — e.g. a monitor at 1920,0 sized 1920x1080:
npm start -- --source gdigrab --bounds 1920,0,1920,1080 --encoder nvenc --fps 60 --bitrate 12MWithout --bounds the whole desktop (all monitors) is mirrored.
The TV can ask for the size it wants from its own menu (hold OK → Picture
size): native, 1080p, 720p, 480p or 360p. The host scales the encoded video
and leaves the PC's capture alone, so 720p roughly halves the bandwidth without
changing what is on the desktop. The same setting is in the control panel under
Quality → Output size, and on the command line as --height 720.
Changing it makes the host restart the encoder and reconnect the TV once, so the decoder always starts from a fresh SPS/PPS and keyframe instead of being handed a new resolution mid-stream. That is the quickest fix for a stuttering picture on Wi-Fi, and it is remembered on both ends.
Both apps can connect without you touching them:
- TV — Auto-connect at startup (on by default) opens straight into the last PC. Auto-reconnect retries by itself when the stream drops; after four failures it searches the network again, so a PC that got a new IP address is still found. Both are toggles in the app menu, next to Reconnect now.
- PC — Start streaming as soon as the host starts and Open this panel automatically, both in the control panel's Connection card and saved with the rest of the settings.
Windows needs a display to drive before it will let you drag windows onto it. Use a free virtual display driver:
- Install Virtual Display Driver (or any Indirect Display Driver).
- In Settings → System → Display, select the new virtual display, choose Extend these displays, and set its resolution (e.g. 1920×1080).
- Run
node src\index.js --list-displays. The new display appears as a second entry; the host prints the exact--boundscommand to use. For example, if it reports#1 DISPLAY2 1920x1080 at 1920,0 (secondary), start the host with--source gdigrab --bounds 1920,0,1920,1080.
Windows now behaves as if a second monitor exists: windows can be moved onto it
and it has its own taskbar. Use --source ddagrab --display N instead when the
display is a physical monitor attached to the same GPU — it is significantly
cheaper to capture.
Since the app can inject input, you can drive that second display from the sofa with the TV remote (movement is kept inside the captured rectangle, so the pointer never disappears onto your main monitor).
Dragging the mouse off the virtual display: enable "Ease cursor to the desktop when it hits the edge", or simply switch to the other screen with the pointer confined by
--bounds.
These are this repo's defaults, because they are the fastest pair for that combination:
| Setting | Value | Why |
|---|---|---|
--encoder qsv |
Intel QuickSync H.264 | Encodes on the iGPU instead of the CPU |
| capture region | 1920×1080 | The Mi Box 4 (Amlogic S905X) decodes H.264 up to 1080p60 comfortably; its 4K strength is HEVC, and H.264 at 4K is capped at 30 fps |
--fps 60 |
60 | Smooth pointer; --fps 30 halves encoder and network load |
--bitrate 12M |
12–16M | Plenty for 1080p60, and light enough for 5 GHz Wi-Fi |
npm start -- --source gdigrab --bounds 1920,0,1920,1080 --encoder qsv --fps 60 --bitrate 12MNotes for this pair:
- The Mi Box 4 has no Ethernet port; use 5 GHz Wi-Fi, or a USB-to-Ethernet adapter (these work well with the box) if you want a wired link.
--source gdigrabis the dependable capture backend on Intel iGPUs, virtual displays included.ddagrabalso works, but with QSV it has to download the GPU frames before they are uploaded again.- If QuickSync cannot open an MFX session (a sign of an old Intel driver), the
host switches to
libx264on its own and says so in the console, so the TV still gets a picture. Update the Intel driver to get the iGPU back. - The Mi Box remote has no Menu button, so the app menu opens by holding OK (a short press is still a left click).
Android Studio (recommended)
- File → Open… → select the
android/folder. - Let Gradle sync (it downloads the SDK 34 platform on first sync).
- Build → Build App Bundle(s) / APK(s) → Build APK(s).
- The APK is at
android/app/build/outputs/apk/debug/app-debug.apk.
Command line
cd android
gradle wrapper --gradle-version 8.7 # once, if you have Gradle installed
./gradlew assembleDebugInstall on the TV — any of these:
adb connect <tv-ip>:5555(enable Developer options → Network debugging), thenadb install -r android/app/build/outputs/apk/debug/app-debug.apk- Copy the APK to a USB stick and open it with a file manager on the TV
- Serve it locally (
python -m http.server 8000in the folder holding the APK) and download it on the TV with the Downloader app
Start BeamBox from the TV's app row. It discovers the PC automatically; if discovery is blocked (guest Wi-Fi, AP isolation), pick Change PC address in the menu and type the PC's IPv4 address.
| TV remote | Pointer mode (default) | Arrow-key mode |
|---|---|---|
| D-pad | Move the mouse pointer | Arrow keys |
| OK / Enter | Left click | Enter |
| Back | Right click | Esc |
| Rewind / Fast-forward | Page Up / Page Down | same |
| Play/Pause | Space | same |
| Menu / Settings | App menu (mode, address, exit) | same |
| Hold OK | App menu — for remotes without a Menu key | — |
| Hold ↑ or ↓ | App menu — the easiest one on a Mi Box remote | same |
| OK while nothing is streaming | App menu (there is nothing to click yet) | same |
The menu (Menu key, hold OK, hold ↑/↓, or OK while the status text is up because nothing is streaming yet) also switches between the two input modes, picks the picture size the TV wants (native/1080p/720p/480p/360p), reconnects immediately, toggles auto-connect and auto-reconnect, changes the PC address, re-runs discovery, and exits the app. Volume keys still control the TV.
Your normal keyboard and mouse on the PC keep working — this is a genuine extended display, not a remote-desktop session.
| Symptom | Fix |
|---|---|
| Laggy / stuttery | Use Ethernet, or 5 GHz Wi-Fi; --fps 30 --bitrate 8M |
| CPU pegged on the PC | --encoder qsv (Intel iGPU), nvenc (NVIDIA), or amf (AMD) |
| Blurry text | Raise --bitrate 20M, keep --fps 60 |
| Latency grows over time | Something is saturating the link; prefer wired, lower bitrate |
| 4K desktop is too slow | Use --source ddagrab --encoder nvenc, or capture a 1080p region |
| Mi Box 4 stutters | Capture 1080p, not 4K — its H.264 decoder tops out at 4K/30, while HEVC is the format it handles at 4K |
Typical LAN latency with qsv (or libx264 ultrafast) and a wired PC: 40–90 ms
glass to glass. Decoding happens in the TV's hardware decoder, which is why the app talks
H.264 directly instead of using a media player wrapper.
- "Searching for the PC…" forever — the firewall rules above are the usual cause; also check the TV is not on an isolated guest network. Connect by IP.
- "Connected, waiting for video…" then nothing — FFmpeg failed. The host
console prints the reason plus a hint (e.g.
ddagrabneeds FFmpeg 6+, or the encoder is missing from your build). Runnpm run probeto see the exact command line used. Unknown filter 'ddagrab'— install a current FFmpeg build, or use--source gdigrab.- Green blocks or squares on the TV — the decoder painted macroblocks it never received. This build feeds whole frames, waits for the first keyframe and never drops a slice, so it should stay clean; if it ever appears, hit Restart encoder in the control panel to force a fresh keyframe.
Error while opening encoder— that hardware encoder is unavailable; drop back to--encoder libx264.- QuickSync / MFX session error — the Intel driver could not open the iGPU.
This needs no action: the host logs
falling back to the libx264 software encoderafter the first failure and keeps streaming on the CPU. Install the current Intel graphics driver to get hardware encoding back, and drop to--fps 30if the CPU-based picture stutters. - App shows the desktop but the pointer won't move — the host was started
with
--no-input, orkoffifailed to install (npm installinhost/). - Only part of the screen is visible —
--boundsdoes not match the monitor's real bounds; re-read them with the PowerShell command.
- Video only — no system audio is forwarded.
- One TV per host at a time.
- H.264 only, no encryption or authentication: run it on a network you trust and never expose ports 47900/47901 to the internet.
- Remote buttons map to a fixed key set; there is no on-screen software keyboard.
- Requires FFmpeg on the Windows side (it does the capturing and encoding).
host/
package.json
start.bat double-click launcher
src/index.js CLI, wiring, shutdown
src/args.js option parsing + help
src/capture.js FFmpeg capture/encode, restart with backoff
src/video.js TCP video server (JSON line + raw H.264)
src/control.js TCP control server (newline JSON → input)
src/input.js user32 injection via koffi
src/discovery.js UDP discovery responder
android/
app/src/main/java/com/beambox/tv/
MainActivity.kt UI, remote handling, reconnect logic
VideoClient.kt socket → Annex-B splitter → MediaCodec
H264.kt SPS parsing (real frame size)
ControlClient.kt input event sender
Discovery.kt UDP discovery client
MIT — see LICENSE. Use it, fork it, ship it on a USB stick.
The Windows build bundles FFmpeg (Gyan.dev essentials build, LGPL/GPL depending on the build options) next to the exe; it is a separate program, not linked into BeamBox.