How I built Casthop, an open-source live studio in the browser
I wanted a StreamYard-style studio I could run myself, and I couldn't find a good open-source one. So I built Casthop. Casthop is a live studio that runs in the browser. You sign in as the host, send guests a link (they
I wanted a StreamYard-style studio I could run myself, and I couldn't find a good open-source one. So I built Casthop.
Casthop is a live studio that runs in the browser. You sign in as the host, send guests a link (they don't need an account), put up to six people on stage, and send one mix to as many RTMP destinations as you want. While you're live you can clip the last 30 or 60 seconds, add a 9:16 output next to the 16:9, and record each person on their own track. YouTube, Twitch and Kick chat land in one place, and you can pin a comment on the video.
It's licensed AGPL-3.0. Self-hosting is free. The first public release, v0.1.0, came out on 27 November 2026.
The people in the screenshots were made for these shots.
How it's put together
The media path is LiveKit, Egress, Redis and an RTMP server. Those run in Docker on your machine. The app is a Cloudflare Worker with Durable Objects and D1. Stream keys stay in Durable Object storage and are never sent back to guests. The audio and video hot paths — noise suppression and the compositor — are Rust compiled to WebAssembly.
That split is the whole design. The Worker owns rooms, guests and "go live." The media servers do the heavy lifting.
Three problems that showed up once it was running
The 9:16 compositor was dying on first start
When you go live with a vertical destination, Casthop starts a second compositor for 9:16, next to the 16:9 one. The watch path gives a new compositor a short start grace, so a first heartbeat isn't treated as already gone.
That grace was only wired to the 16:9 egress id. On a cold first go-live, a watch that ran before the portrait compositor had joined treated it as dead and stopped it with "Compositor left." An earlier bug made this worse: the start path wrote a fake heartbeat, so a compositor that hadn't loaded yet looked stale in a three-second window, got restarted, and sometimes two portrait compositors ended up publishing to the same RTMP URL.
The start grace now covers the 9:16 egress too, the heartbeat is only set by a real beat, and a restart stops any extra portrait compositor in the room. That's #102 and #113.
One client could fill the studio's sockets
Studio state goes out over WebSockets: stage changes, chat, and, while you're live, a full public state at least once a second. We capped a room at 256 sockets, which is well above a real studio. The upgrade itself was still unauthenticated, and guests do need to connect before they have a session. One client could open all 256, and every real host or viewer after that got a 503.
The Worker now stamps each upgrade with the client network — an IPv4 address or an IPv6 /64 — and ignores a caller-supplied header. A ninth open socket from that network gets a 429. The 256 room cap stays as a backstop. That's #114, after the room cap in #99.
Two uploads could land on the same R2 key
Per-person recordings upload media in chunks to R2. The route used to validate with the studio, write the object, then ask the studio to count the bytes. Validation reserved nothing, so two PUTs to the same index both passed and both wrote to the same key. Only one was counted; the other got a 409, but its object stayed. A 1-byte body and an 8 MiB body to the same index could leave 8 MiB stored while only 1 byte counted toward the caps.
The upload now reserves that index for 20 seconds, with the byte count and a nonce. A second upload in flight gets 429, and the recorder already retries 429. If the R2 put fails, the Worker aborts and frees the index for a retry. Commit and abort both need the matching nonce and byte count. That's #80.
A related limit bit us on sign-in mail. The rate limits used the raw CF-Connecting-IP. One IPv6 host usually holds a whole /64, so each source address counted as a new client. Four addresses in one /64 could send a dozen real sign-in mails to one inbox, where a single client is allowed three. Limits now group IPv6 by /64, and one inbox can get at most 20 sign-in mails per 15 minutes, then at most one more per minute. That's #86.
Running it locally
You need Linux, Docker, and Bun 1.4.5 or newer. Do not use npm.
git clone https://github.com/casthop/casthop.git && cd casthop
cp .env.example .env
cp .dev.vars.example .dev.vars
mkdir -p data/recordings data/rtmp && chmod 777 data/recordings
docker compose up -d
bun install
bun run dev
The sign-in link is printed in the terminal (no email is sent locally). Open http://127.0.0.1:5173, create a studio, copy the guest link, and press Go live. Default destinations are local test servers, so nothing goes public. Step-by-step docs are at casthop.com.
What's still rough
Guests on strict networks may have a hard time until NAT traversal is better, and there's no X or LinkedIn chat yet. Expect other rough edges; this is an early release.
The repo is github.com/casthop/casthop.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.
