mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
3.4 KiB
3.4 KiB
Video flow (SRT ingest, WHEP playback)
-
Raspberry Pi Zero 2 W
pi/bin/video-publisher.shcaptures the CSI camera withrpicam-vid/libcamera-vidusing the onboard H.264 encoder (--inline --profile baseline --bitrate …).- The Annex-B stream is piped into the stock FFmpeg package and pushed to the control server over SRT as MPEG‑TS:
ffmpeg -f h264 -i - -c copy -f mpegts "srt://<server>:9000?streamid=#!::r=rover-alpha,m=publish&latency=20&mode=caller&transtype=live&pkt_size=1316". - Configuration lives in
/var/lib/roverd/video.env(PUBLISH_URL, resolution, FPS, bitrate).roverdrewrites this file whenever the rover config changes, so onboarding a new rover is just flashing the SD card, setting itsname, and plugging it into the trusted LAN—no auth or per-rover server config is required on the Pi ⇄ server hop.
-
mediaMTX on the server
- Single wildcard path handles every rover:
paths: "~^rover-(?P<id>[a-z0-9_-]+)$": source: publisher sourceOnDemand: no sourceProtocol: srt readBufferCount: 512 webrtcEnable: yes webrtcMaxPlayoutDelay: 0 alwaysRemuxWhep: no - Pis publish to
srt://<server>:9000with the streamid above; mediaMTX auto-creates the path and fans it out over WHEP/WebRTC. If you expose playback under/video/<id>externally, let the reverse proxy rewrite that prefix back to<id>before forwarding to mediaMTX so the wildcard continues to match every rover. - Only playback is gated: mediaMTX calls the Node server to validate JWTs on
/whep/rover-<id>, so “locking” a stream is as simple as refusing to mint viewer tokens for that rover. Ingest stays unauthenticated because it lives on a secure LAN.
- Single wildcard path handles every rover:
-
Web clients
- Tiny helper (React hook or vanilla class) that:
- Requests a viewer token for rover
<id>. - Issues a
POSTto<mediamtx-host>/<rover-id>/whepwithAuthorization: Basic base64(token:token)(token issued by the server when the client callsvideo:request). - Maintains auto-reconnect timers on ICE failure so dashboard widgets can come/go without reloading the page.
- Requests a viewer token for rover
- Operator dashboard mounts one player tied to the assigned rover. The spectator view instantiates one player per tile, muting + pausing hidden elements to keep CPU usage sane even when every rover is shown simultaneously.
- Tiny helper (React hook or vanilla class) that:
Deployment checklist
pi/install_roverd.shinstalls thevideo-publisherhelper, drops/var/lib/roverd/video.env, and pulls inlibcamera-apps+ffmpegfrom apt. No custom FFmpeg, no WHIP builds, no extra config—Pis become plug-and-play.roverdderivesmedia.publishUrlautomatically fromserverUrl:srt://<server>:9000?streamid=#!::r=<name>,m=publish&latency=20&mode=caller&transtype=live&pkt_size=1316. The media supervisor rewritesvideo.envand managesvideo-publisher.servicewhenever you hit “Restart Camera” or change/etc/roverd.yaml.- The server’s mediaMTX config switches to the wildcard block above, leaves SRT ingest open, and enforces JWTs only on WHEP viewers. Fan-out stays inside mediaMTX so every browser sees the same low-latency stream (≈250–350 ms glass-to-glass).
- Adding a rover = flash SD → set
/etc/roverd.yaml(name,serverUrl, camera knobs if needed) → boot it. The server auto-discovers the newrover-<id>stream with zero manual edits.