# Live Camera Setup > Take a USB or built-in webcam live 24/7 for free, and watch it from the Live Camera page — the cost-effective ffmpeg → YouTube Live runbook plus HLS and Cloudflare alternatives. --- ## How the Live Camera page works The **[Live Camera](/camera)** page renders whatever you point `CONFIG_STREAM_URL` at — a **YouTube Live** URL or an **HLS** (`.m3u8`) playlist — as the public 24/7 feed. Delivery is free (the platform/CDN bears the bandwidth) and needs **no extra backend**. With no URL set, the page falls back to a **local webcam monitor** (`getUserMedia`) that only ever runs in your own browser. ```bash # .env CONFIG_STREAM_URL=https://www.youtube.com/watch?v=YOUR_LIVE_VIDEO_ID ``` .. toc:: ## Go live for free — webcam → YouTube Live This is the cheapest robust 24/7 path: YouTube hosts and delivers the stream at no cost, and the page embeds it. 1. In **YouTube Studio → Go Live → Stream**, create a stream and copy the **Stream URL** (`rtmp://a.rtmp.youtube.com/live2`) and **Stream key**. 2. Push your webcam to it with a single always-on `ffmpeg` process: ```bash # macOS (AVFoundation). List devices first: ffmpeg -f avfoundation -list_devices true -i "" ffmpeg -f avfoundation -framerate 30 -i "0:0" \ -c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k -bufsize 6000k \ -pix_fmt yuv420p -g 60 \ -c:a aac -b:a 128k -ar 44100 \ -f flv "rtmp://a.rtmp.youtube.com/live2/YOUR-STREAM-KEY" ``` ```bash # Linux (V4L2 webcam at /dev/video0) ffmpeg -f v4l2 -framerate 30 -i /dev/video0 -f alsa -i default \ -c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k -bufsize 6000k \ -pix_fmt yuv420p -g 60 -c:a aac -b:a 128k -ar 44100 \ -f flv "rtmp://a.rtmp.youtube.com/live2/YOUR-STREAM-KEY" ``` 3. Set `CONFIG_STREAM_URL` to the broadcast's watch URL and reload the page. 4. **Keep it alive.** Run the `ffmpeg` line as a service so it restarts on failure — e.g. a `systemd` unit with `Restart=always`, a `launchd` agent on macOS, or a small `while true; do ffmpeg ...; sleep 2; done` supervisor. > **Trade-offs:** free delivery and minimal plumbing, but ~10–30 s latency, platform > branding/ads, and YouTube's unattended-stream quirks. Best as the cost-effective > default; swap in a route below if you need lower latency or full product control. ## Alternative — self-host (lowest cost, more control) Run **[MediaMTX](https://github.com/bluenviron/mediamtx)** on a small VPS; push the webcam in with `ffmpeg` and serve **HLS** or sub-second **WHEP**: ```yaml # mediamtx.yml — pull an RTSP camera, or accept an ffmpeg/RTMP publish paths: cam: source: publisher # ffmpeg publishes to rtmp://:1935/cam ``` Then point `CONFIG_STREAM_URL` at the HLS playlist (`http://:8888/cam/index.m3u8`); the page attaches `hls.js` automatically. You own the 24/7 process, TLS, and restarts. ## Alternative — managed (lowest ops) **Cloudflare Stream Live**: create a Live Input (RTMP/SRT ingest), push the webcam to it with `ffmpeg`, and set `CONFIG_STREAM_URL` to the HLS playback URL. Managed, robust, signed URLs, near-zero maintenance — billed by usage. ## What's deferred WHIP browser-publish, a `/whip-token` mint, Cloudflare `/cf-webhook` + a viewer-count websocket, and recording/DVR all belong to the later streaming control-plane phase (which moves the app to the FastAPI backend). v1 keeps the camera free, embeddable, and backend-light. --- *Source: /live-camera*