Keep up to 5 followed live games' channels running in the background #96

Closed
opened 2026-11-07 20:04:41 -05:00 by cmoriarty · 3 comments
Owner

What happens

A channel starts at the first tune and closes 60 s after the last poll (CHANNEL_IDLE_SECONDS). Until someone tunes in, the app has only the readiness checks to go on. A tune always starts cold:

  • the cold-tune read;
  • an empty buffer;
  • a health history that starts at zero, so the first minutes are where the swaps begin.

The idea

Run the channel itself for followed live games, with nobody watching, so it has played for minutes before anyone tunes in.

  1. Which games: live, Ready and followed. Ranked by how they are followed (the game, then a team, then the league), then by earliest kickoff.
  2. At most 5 at once.
    • The setting is CHANNEL_BACKGROUND_LIMIT, 5 by default, 0 to turn it off.
    • It guards against a slate where dozens of followed games are live at once.
    • Channels with viewers don't count against it and aren't limited, as today.
    • When a game ends or a higher-ranked game goes live, the lowest-ranked background channel without a viewer closes.
  3. A tune finds it warm: the timeline, the buffer and the health history are already there, with no cold read. When the last viewer leaves, a game still in the top 5 keeps running instead of closing after 60 s.
  4. It is judged like a played channel: stalls, dry spells, served rate, frame cadence, late releases. Its swaps and recoveries happen before anyone sees them. The light watch (#94) still covers the standbys and any followed games past the 5.
  5. No viewer, no re-encode: with no player attached there is no transcoder to protect (#39). A background channel takes the shape of the stream it swaps to instead of re-encoding (the second idea in #62). The shape is fixed when a viewer tunes in.
  6. Not a viewer: background pulls don't count as viewers or readers on the card, in the Playing count, in the tuner count Emby and Jellyfin see, or in the media-session lookup. The card shows a background channel as warm. Background channels don't record.
  7. Cost:
    • Bandwidth: each game's full bitrate, about 2–3 Mbit/s (tonight's 720p at 59.94 fps averaged 2.8 Mbit/s). That is about 15 Mbit/s at the limit, all evening on a busy slate.
    • CPU: nothing beyond copying while nobody watches (point 5).

Done when

  • In the unit lane:
    • with 7 followed live games, exactly 5 background channels run, and they are the top 5 by the ranking;
    • a viewer's tune of one of them is served from the existing timeline;
    • CHANNEL_BACKGROUND_LIMIT=0 runs none.
  • On a live game: a followed game's channel is warm before the tune, and Emby's first picture comes faster than a cold tune.
## What happens A channel starts at the first tune and closes 60 s after the last poll (`CHANNEL_IDLE_SECONDS`). Until someone tunes in, the app has only the readiness checks to go on. A tune always starts cold: - the cold-tune read; - an empty buffer; - a health history that starts at zero, so the first minutes are where the swaps begin. ## The idea Run the channel itself for followed live games, with nobody watching, so it has played for minutes before anyone tunes in. 1. **Which games:** live, Ready and followed. Ranked by how they are followed (the game, then a team, then the league), then by earliest kickoff. 2. **At most 5 at once.** - The setting is `CHANNEL_BACKGROUND_LIMIT`, 5 by default, 0 to turn it off. - It guards against a slate where dozens of followed games are live at once. - Channels with viewers don't count against it and aren't limited, as today. - When a game ends or a higher-ranked game goes live, the lowest-ranked background channel without a viewer closes. 3. **A tune finds it warm:** the timeline, the buffer and the health history are already there, with no cold read. When the last viewer leaves, a game still in the top 5 keeps running instead of closing after 60 s. 4. **It is judged like a played channel:** stalls, dry spells, served rate, frame cadence, late releases. Its swaps and recoveries happen before anyone sees them. The light watch (#94) still covers the standbys and any followed games past the 5. 5. **No viewer, no re-encode:** with no player attached there is no transcoder to protect (#39). A background channel takes the shape of the stream it swaps to instead of re-encoding (the second idea in #62). The shape is fixed when a viewer tunes in. 6. **Not a viewer:** background pulls don't count as viewers or readers on the card, in the Playing count, in the tuner count Emby and Jellyfin see, or in the media-session lookup. The card shows a background channel as warm. Background channels don't record. 7. **Cost:** - **Bandwidth:** each game's full bitrate, about 2–3 Mbit/s (tonight's 720p at 59.94 fps averaged 2.8 Mbit/s). That is about 15 Mbit/s at the limit, all evening on a busy slate. - **CPU:** nothing beyond copying while nobody watches (point 5). ## Done when - **In the unit lane:** - with 7 followed live games, exactly 5 background channels run, and they are the top 5 by the ranking; - a viewer's tune of one of them is served from the existing timeline; - `CHANNEL_BACKGROUND_LIMIT=0` runs none. - **On a live game:** a followed game's channel is warm before the tune, and Emby's first picture comes faster than a cold tune.
Author
Owner

Built in PR #99 (merged as 732ab0a), deployed 2026-11-08 04:19Z (container 52cd495f611a); the OpenSpec change is archived in 038f7a9. This stays open until it is seen working on a live followed game: a grade before the tune, a Warm background channel, and a Choppy stream that stays put.

Built in PR #99 (merged as 732ab0a), deployed 2026-11-08 04:19Z (container 52cd495f611a); the OpenSpec change is archived in 038f7a9. This stays open until it is seen working on a live followed game: a grade before the tune, a Warm background channel, and a Choppy stream that stays put.
Author
Owner

Live test, UTEP vs. Hawai'i, 2026-11-07 23:22–23:55 ET (first followed game after the deploy). Seen working: the game was kept warm 10 s after it turned Ready ("kept warm for the watch list"), showed as Warm, and the tune came up quickly from the channel's buffer (Chris confirmed). After the tune it counted as playing. Follow-up for settings: #100.

Live test, UTEP vs. Hawai'i, 2026-11-07 23:22–23:55 ET (first followed game after the deploy). Seen working: the game was kept warm 10 s after it turned Ready ("kept warm for the watch list"), showed as Warm, and the tune came up quickly from the channel's buffer (Chris confirmed). After the tune it counted as playing. Follow-up for settings: #100.
Author
Owner

Closed at the owner's word (2026-11-08): the fix is merged to develop in PR #99 (merge 732ab0a) and deployed. A new issue will be opened if a problem shows up.

Closed at the owner's word (2026-11-08): the fix is merged to develop in PR #99 (merge 732ab0a) and deployed. A new issue will be opened if a problem shows up.
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/sports-breaker#96
No description provided.