WebRTC vs HLS: pick your latency
Sub-second WebRTC or buffered HLS? The trade-off between latency, scale and reach — and how StreamHub gives you both from the same live stream.
Two players, one stream
StreamHub can play the same live room two ways, and choosing between them is really choosing where you want to sit on the latency-vs-scale curve.
- WebRTC (
LivePlayer) — glass-to-glass latency under a second. It subscribes to the LiveKit room directly and renders the tracks. This is what you want for anything interactive: two-way calls, auctions, "watch live now" moments where a delay feels broken. - HLS (
HlsPlayer, video.js) — a segmented feed at/hls/<app>/<room>/index.m3u8with roughly 6–15 seconds of latency. In exchange you get effortless scale, CDN-friendliness, and playback on devices and networks where WebRTC struggles.
The trade-off in one line
WebRTC minimizes latency; HLS maximizes reach and scale. There is no free lunch — the buffering that lets HLS ride out a flaky network is exactly the buffering that adds latency.
When to reach for each
| Use case | Reach for |
|---|---|
| Video calls, interactive auctions | WebRTC |
| "Watch live now" on the dashboard | WebRTC |
| Large audience live event | HLS |
| Mobile / restrictive networks | HLS |
| Public embed at unknown scale | HLS |
How to get a WebRTC player
Mint a subscribe token and connect:
curl -s -X POST $BASE/apps/demo/tokens -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d '{"room":"demo-room1","canPublish":false,"canSubscribe":true}'
# → data.playUrl / data.embedUrl / data.iframe
The response hands you public /play and /embed URLs and a ready-to-paste iframe — no auth needed on those pages.
How to get an HLS URL
HLS needs no token. If the room is publishing with transcoding on (the default for RTMP and URL ingest), the playlist is simply:
/hls/<app>/<room>/index.m3u8
Point any HLS-capable player at it.
You don't have to choose up front
Because both come off the same live room, you can offer WebRTC to your interactive users and HLS to your broadcast audience simultaneously. The dashboard's live tab even exposes both Ver (WebRTC) and Ver (HLS) actions per stream, so operators can pick per situation.