Problem: An RTMP-based camera platform had 8–14 second live-view latency. Each RTMP hop (camera → media server → CDN → client) added 1.5–3 seconds. Operators were watching events that had already happened.
Solution: Pion-based SFU forwarded WebRTC packets without decoding, keeping latency to network RTT plus 2-frame jitter buffer. TURN over TLS 443 for cameras behind double-NAT. HLS fallback: RTSP ingest → LL-HLS segmentation → S3 (30-day retention). WebRTC P2P for 66% of sessions; TURN relay for 34%.
Technology: WebRTC · Pion SFU · TURN/STUN · LL-HLS · RTSP
Optimisation pattern: rtmp-to-webrtc-sfu
Outcomes:
Live latency: 8–14 s → 600 ms–1.8 s (P50/P99). HLS review availability: 99.98%. Infrastructure cost vs CDN RTMP: 43% lower.