A change between streams with different packet ids loses the new stream for a media server #174

Open
opened 2026-11-15 14:57:41 -05:00 by cmoriarty · 0 comments
Owner

What happens

One site's stream uses other MPEG-TS packet ids than the rest. On recordings of 2026-11-14:

Stream Video Sound
zkotaa.cfd (the streamgate player) 0xd3 0xdd
thetvapp, the embedsports player, edgestream 0x100 0x101

Read offline across a change between the two, ffmpeg -f hls -i <playlist> -c copy -copyts logged "New video stream" and "New audio stream" at the change and dropped the new stream's packets. A reader that copies would have no picture or sound after such a change until it is tuned again.

This is on main today, at any change of stream between two such links. Pull request #172 (#168) neither causes nor fixes it. A fault of the same family is on record: on 2026-10-29 a change of picture format at a splice hung Emby's transcode until the viewer re-tuned.

What is known, and what is not

  • Seen: once, offline, on recorded segments, with ffmpeg's copy.
  • Not checked: whether it reproduces with generated streams; what hls.js does; what Emby and Jellyfin themselves do (they may re-encode rather than copy); whether the audio step, which rewrites the sound's packets in production, already changes the sound's packet id; which other sites use other ids.

The idea

The channel gives every segment it serves its own packet ids and tables (PAT, PMT), where it already rewrites the packets for the clock (tsclock.restamp) and the sound (audionorm.py, tsmux.py). A change of stream then looks like one stream to a reader.

First step, before any code: reproduce it without a site. Two short generated streams, one on other ids (-streamid 0:211 -streamid 1:221), in one playlist with a discontinuity between them, read by ffmpeg's copy, by ffmpeg re-encoding, and by hls.js.

Done when

In the unit lane, with generated streams:

  • A change between streams with different packet ids: ffmpeg -f hls … -c copy -copyts across it carries the second stream's picture and sound, and no timestamp goes backwards.
  • hls.js plays through it.
  • A stream already on the channel's ids is served byte for byte as today, apart from what the clock and the audio step change.

Live: a swap onto a zkotaa.cfd link while watching through Emby keeps picture and sound.

backend/app/channel.py is also edited by #169 and #170.

## What happens One site's stream uses other MPEG-TS packet ids than the rest. On recordings of 2026-11-14: | Stream | Video | Sound | | --- | --- | --- | | zkotaa.cfd (the streamgate player) | 0xd3 | 0xdd | | thetvapp, the embedsports player, edgestream | 0x100 | 0x101 | Read offline across a change between the two, `ffmpeg -f hls -i <playlist> -c copy -copyts` logged "New video stream" and "New audio stream" at the change and dropped the new stream's packets. A reader that copies would have no picture or sound after such a change until it is tuned again. This is on `main` today, at any change of stream between two such links. Pull request #172 (#168) neither causes nor fixes it. A fault of the same family is on record: on 2026-10-29 a change of picture format at a splice hung Emby's transcode until the viewer re-tuned. ## What is known, and what is not - **Seen:** once, offline, on recorded segments, with ffmpeg's copy. - **Not checked:** whether it reproduces with generated streams; what hls.js does; what Emby and Jellyfin themselves do (they may re-encode rather than copy); whether the audio step, which rewrites the sound's packets in production, already changes the sound's packet id; which other sites use other ids. ## The idea The channel gives every segment it serves its own packet ids and tables (PAT, PMT), where it already rewrites the packets for the clock (`tsclock.restamp`) and the sound (`audionorm.py`, `tsmux.py`). A change of stream then looks like one stream to a reader. First step, before any code: reproduce it without a site. Two short generated streams, one on other ids (`-streamid 0:211 -streamid 1:221`), in one playlist with a discontinuity between them, read by ffmpeg's copy, by ffmpeg re-encoding, and by hls.js. ## Done when In the unit lane, with generated streams: - **A change between streams with different packet ids:** `ffmpeg -f hls … -c copy -copyts` across it carries the second stream's picture and sound, and no timestamp goes backwards. - **hls.js** plays through it. - **A stream already on the channel's ids** is served byte for byte as today, apart from what the clock and the audio step change. Live: a swap onto a zkotaa.cfd link while watching through Emby keeps picture and sound. `backend/app/channel.py` is also edited by #169 and #170.
Sign in to join this conversation.
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
cmoriarty/sports-breaker#174
No description provided.