Relay live TS through the server, racing streams at start and failing over mid-show #41

Merged
namillis merged 1 commit from feat/stream-relay into main 2026-11-20 03:39:08 +00:00
Owner

Streams kept failing on every TV: the pool redirected the TV to one provider and only learned a stream failed when the app asked again, so finding one that played meant trying sources one by one, about 5 seconds each.

With RELAY_PORT set, live .ts goes through a relay process on the server instead:

  • Start: it opens a channel's best two streams (different providers) at once and keeps the first that sends video. Refusals, error pages and non-TS answers are passed over in well under a second.
  • Mid-show failover: when the stream drops or falls 1.5 s behind real time, it moves to the next stream on the same connection to the TV. The output keeps fixed packet ids, its own PAT/PMT, continuous PCR/PTS/DTS and continuity counters, and each new source starts on a picture with an SPS, so the player plays on from its buffer. An audio format change (e.g. HE-AAC to AAC-LC) resets the TV connection instead, so the app reopens the channel.
  • Order: recent failures last, full accounts next, then each stream's (or provider's) record of starting and playing. pool_sources lists the best 3.
  • Server refused: a provider that refuses the server 3 times in a row (ultra and nash8k do, from the VM) is redirected to directly for 30 minutes, as before.
  • Sharing: two TVs on one channel share one provider connection.
  • It's a separate process because the main one blocks its event loop for seconds at a time.

HLS and catch-up still redirect. Without RELAY_PORT nothing changes.

Checked on the VM against real providers: starts in 0.5 to 2.8 s, forced switches in 0.5 to 2.2 s, and real ksenqw/raptor captures through switches decode with ffmpeg with only the provider's own errors (down from about 690 before the parameter-set gate). 138 tests pass.

Streams kept failing on every TV: the pool redirected the TV to one provider and only learned a stream failed when the app asked again, so finding one that played meant trying sources one by one, about 5 seconds each. With `RELAY_PORT` set, live `.ts` goes through a relay process on the server instead: - **Start:** it opens a channel's best two streams (different providers) at once and keeps the first that sends video. Refusals, error pages and non-TS answers are passed over in well under a second. - **Mid-show failover:** when the stream drops or falls 1.5 s behind real time, it moves to the next stream on the same connection to the TV. The output keeps fixed packet ids, its own PAT/PMT, continuous PCR/PTS/DTS and continuity counters, and each new source starts on a picture with an SPS, so the player plays on from its buffer. An audio format change (e.g. HE-AAC to AAC-LC) resets the TV connection instead, so the app reopens the channel. - **Order:** recent failures last, full accounts next, then each stream's (or provider's) record of starting and playing. `pool_sources` lists the best 3. - **Server refused:** a provider that refuses the server 3 times in a row (ultra and nash8k do, from the VM) is redirected to directly for 30 minutes, as before. - **Sharing:** two TVs on one channel share one provider connection. - It's a separate process because the main one blocks its event loop for seconds at a time. HLS and catch-up still redirect. Without `RELAY_PORT` nothing changes. Checked on the VM against real providers: starts in 0.5 to 2.8 s, forced switches in 0.5 to 2.2 s, and real ksenqw/raptor captures through switches decode with ffmpeg with only the provider's own errors (down from about 690 before the parameter-set gate). 138 tests pass.
The pool only redirected TVs to a provider and guessed failures from their retries, so finding a stream that
played meant trying them one by one. With RELAY_PORT set, a separate relay process opens a channel's best two
streams at once, keeps the first that sends video, and moves to the next on the same connection when one drops
or falls behind. Its output keeps fixed packet ids, its own program table and continuous timestamps, so players
play on through a switch. Outcomes rank each channel's streams, pool_sources lists the best 3, a provider that
refuses the server is redirected to as before, and two TVs on one channel share a provider connection.
namillis deleted branch feat/stream-relay 2026-11-20 03:39:08 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
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
namillis/iptv-pool!41
No description provided.