Appearance
Use on-demand channels
An on-demand channel starts when the first viewer arrives and stops after a while with no viewers. With a large list where most channels are rarely watched, you save CPU, bandwidth and provider connections.
Turn it on
In the panel, new channels already have Start only when someone watches turned on, with Stop after (seconds) at 60. You find both in the channel form under On demand. In the channel list, a stopped on-demand channel shows a grey Idle badge, not a red offline one.
With the API, set it when you create a channel, or later:
bash
curl -s -X PATCH $PANEL/streams/101 -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' -d '{"on_demand": true, "idle_timeout_s": 60}'idle_timeout_s is how long the channel keeps running after the last viewer leaves, from 5 to 86400 seconds.
When you create a channel with the API and leave these fields out, the streaming settings decide: default_on_demand (off by default) and default_idle_timeout_s (60 by default). Change them like this:
bash
curl -s -X PATCH $PANEL/settings/streaming -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' -d '{"default_on_demand": true, "default_idle_timeout_s": 60}'A standalone node (streams_file, no control) uses 30 seconds when a stream has no idle_timeout_sec.
How fast does it open?
Bitstream does three things to make the first picture come quickly:
- Pre-warm. The control tells the node to start the channel at the same moment it redirects the viewer, so the start and the redirect happen in parallel.
- Small probe. ffmpeg reads only a little of the source before it starts (1 MB and 0.5 seconds by default). If that misses the audio track, the node restarts once with a bigger probe and remembers it for that channel.
- The viewer starts at a keyframe. New viewers get the latest keyframe from memory, so they never see a grey or green picture.
HLS players get a playlist that waits up to 10 seconds for the first segment, instead of an error. Most apps give up on an error and show "channel offline".
Measured on a test server with a 2 second GOP source: about 2 seconds to the first byte with ffmpeg 5.x and later, about 0.5 seconds with ffmpeg 4.4. On a real server, cold starts measured 0.8 seconds for ffmpeg and 0.4 to 1.4 seconds for LLOD. A cold HLS playlist took about 4 seconds, because the node waits for a whole first segment. ffmpeg 5 and later wait for one full GOP before they write anything. LLOD is faster.
LLOD for the fastest start
For plain HTTP MPEG-TS sources, set mode to llod. The node reads the source in Go without ffmpeg and passes the bytes through. It opens faster and uses almost no CPU.
bash
curl -s -X PATCH $PANEL/streams/101 \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"mode": "llod", "on_demand": true}'LLOD only takes HTTP or HTTPS MPEG-TS sources. HLS, RTSP, RTMP and UDP sources need ffmpeg mode.
Change the probe for one channel
If a channel opens without audio or subtitles, give it a bigger probe:
bash
curl -s -X PATCH $PANEL/streams/101 \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"probe_size": 5000000, "analyze_duration_ms": 2000}'null goes back to the node default.
On-demand and the server tree
A relay from a child node counts as a viewer on its parent. So when a viewer opens the channel on a child node, the parent starts too, and the parent keeps running as long as any child needs it.