Appearance
Add fallback sources
Give a channel more than one source. If the main source dies or freezes, the node switches to the next one in a few seconds. When the main source is healthy again, the node goes back to it.
This works the same in ffmpeg and llod mode.
Add sources to a channel
Sources are an ordered list. Position 0 is the main source. Replace the whole list with PUT /streams/{id}/sources:
bash
curl -s -X PUT $PANEL/streams/101/sources \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '[
{"url": "http://provider-a.example.net/live/u/p/1234.ts"},
{"url": "http://provider-b.example.net/live/u/p/9876.ts", "headers": {"Referer": "https://provider-b.example.net/"}},
{"url": "https://backup.example.org/sports/index.m3u8"}
]' | jqIn the panel, open the channel and use Sources. Each source has a Test button that probes it on an online server.
Running nodes get the new list right away and use it on their next switch. To change only the order, use POST /streams/{id}/sources/reorder. A reorder re-ranks the running source on the node without a restart.
To start over on the main source now, restart the channel:
bash
curl -s -X POST $PANEL/streams/101/restart -H "Authorization: Bearer $TOKEN"TS viewers see a short gap and HLS viewers get a discontinuity. If the channel is on no server yet, you get 409 no_nodes.
When the node switches
The node follows the same rules as XC_VM. A source fails when:
- it refuses the connection, closes it, answers with an error, or ffmpeg stops. This is noticed at once;
- no new video arrives for 60 seconds. Nothing arrives at all, or data keeps coming but the picture is frozen (a provider sending empty packets to keep the connection open);
- the first byte does not arrive within 20 seconds.
A short network drop does not count: ffmpeg reconnects by itself, like in XC_VM.
A late or slow source is never cut. Some providers send video in bursts, a whole segment every few seconds, with quiet gaps in between. A normal player rides over those gaps with its buffer, and so does the node. A source slower than real time keeps playing and the channel page shows "Slow source" with its speed.
On failure the next source starts right away. Viewers stay connected. HLS viewers see one discontinuity marker and keep playing. A source that failed to start is tried again after 10 seconds.
Detection time and fast detection
A dead source takes up to about 60 seconds before the backup plays, like XC_VM. For channels with good sources, turn on Fast detection in the channel's health checks: the switch then happens after 15 seconds. A source that sends in bursts may be cut with it.
Extra health checks (off by default)
| Option | What it does | XC_VM name |
|---|---|---|
| Restart when the frame rate drops | After 10 minutes, restart the source when its frame rate falls below 90 % (you can change it) of the rate at the start | fps_restart, fps_threshold |
| Restart when the audio is lost | Every 5 minutes, restart the source if no audio arrived for 10 seconds | audio_restart_loss |
| Go back to the main source (on by default) | See below | priority_backup |
Going back to the main source
While it runs on a fallback, the node checks the better sources in the background: first after 10 seconds, then less and less often, up to every 5 minutes. It only switches back after the main source stayed healthy for 30 seconds. That stops it from flapping between two sources.
Change that hold time in the streaming settings (primary_return_healthy_seconds):
bash
curl -s -X PATCH $PANEL/settings/streaming \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"primary_return_healthy_seconds": 60}'Respect your provider's connection limit
Providers often allow only a few connections per account. If two of your sources use the same account, group them under a source account, so the node never opens more connections than the account allows. That limit also counts background checks.
bash
curl -s -X POST $PANEL/source-accounts \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"name": "Provider A", "max_connections": 2}' | jq '{id}'Then set account_id on each source that uses that account. max_connections: 0 means no limit.
Restart storms
When a provider goes down, hundreds of channels may fail at once. Each source has its own backoff (1, 2, 4 seconds and so on up to 60 seconds, with some randomness), and each node starts at most a few sources at the same time (max_concurrent_starts_per_node, by default twice the CPU cores). Your provider does not get flooded and ban you.
See what is happening
The channel page in the panel shows the live state and the logs. In the channel list, a channel on a backup source shows an amber badge with the reason, for example "Primary source failed (no data). Using source 3."
With the API, read the live stats per node:
bash
curl -s $PANEL/streams/101/stats -H "Authorization: Bearer $TOKEN" | jqhealthsums it up:state(running,starting,idle,stopped,error,fallback,frozen), acolor(green,yellow,red,grey) and areason.nodeshas one entry per node withactive_source_position,active_source_id,clients,input_bitrate_kbps,fps,speed, and the ffmpegpid,cpu_pctandmem_bytes(pidisnullfor LLOD, relays and stopped channels).- On a backup source,
last_errorsays why the main source failed, for exampleprimary source failed (no data), using source 3.last_error_codeis the same as a stable code:no_data,frozen,slow,ended,refused,timeout,not_found,forbidden,http_error,dns,not_tsorunavailable.
Read the recent logs. Nodes keep about the last 500 lines per channel in memory:
bash
curl -s "$PANEL/streams/101/logs?level=warn&limit=100" -H "Authorization: Bearer $TOKEN" | jq '.data[] | {at, node_id, level, message}'Add node_id=2 to see one node only. limit is 200 by default, 1000 at most. Logs say which source is playing ("playing source N") and never show source passwords.