A swap carries on from the same moment of the game #168
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
cmoriarty/sports-breaker#168
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What happens
When the channel changes stream, the new one starts three segments from its end, wherever that falls in the game (
Timeline.append_upstream). The owner, 2026-11-14: "it's annoying when it goes back in time because you have to re-watch something, and confusing when it jumps forward because you missed something."On recordings of two games from that afternoon, the same swap was built two ways:
Clips, frames and scripts:
/Users/cmoriarty/Library/Application Support/Claude/side-session-notes/local_daf105a8-87c5-4403-af2c-b78517c66b67/stream-swap-research/. The owner's page: https://claude.ai/artifact/TCY5qaAe54rzrNnmjajbok.This is step 2 of 3 in the milestone. It needs #167, and comes after #136, which edits the same file (
backend/app/channel.py).The idea
When the channel changes stream and knows where the new one is (#167), it ends the old stream and starts the new one on the same moment T.
cut_tailandcut_headin the research scripts, pasted in a comment below). The join is a discontinuity as today, and the channel's clock runs on (tsclock).What the viewer gets:
When it may aim
The owner, 2026-11-14:
So:
Settings
playback.head_start, #117) is the room for meeting a slower stream: 15 s by default, up to 30 s. The owner, 2026-11-14: "The 15s/30s decision should be a setting, lets start with 15s by default." It is that setting already, so nothing new is built. Its help text gains one line: at 30 s, none of the pairs measured would repeat anything.Data it needs
aimed(yes,unconfirmedorno, with the reason when not),moved_secondsas measured, andin_hand_secondsafter the join.Done when
In the unit lane, with the generated streams of #167, reading the served playlist and segments the way a player does:
ffmpeg -f hls … -c copy -copytsacross an aimed join has no timestamp going backwards and loses no frame. The web player (hls.js) plays through it.Live: a Swap by hand between two matched streams records 0.0 s (within 0.1), and the owner sees no jump on the web player and on Emby.
Specs:
stream-supervision,admin-page,event-log.Reference from the research, not production code: the two cuts as the scripts did them (
splice_demo.pyandsplice_demo3.pyin the notes folder). They are here so the method does not depend on a scratch folder.What the research saw with them:
ffmpeg -fflags +igndts+genpts -f hls -i … -c copy -copyts -start_at_zero, came out whole: 25.36 s of 25.36 s, the largest video step 0.08 s, no timestamp going backwards.cut_ptshas to be the keyframe's own timestamp. In decode order every picture before a keyframe is earlier than it, so the first video packet at or past T is the keyframe.Merged in pull request #172 as
584162b. The live checks (a swap by hand recording 0.0 s, no jump on the web player or Emby) are next.