Smoother playback: a frame-exact resize, and pooled upstream connections #123

Merged
cmoriarty merged 1 commit from feature/smoother-playback into develop 2026-11-08 16:46:14 -05:00
Owner

Milestone 40, "Smoother playback": #121 and #122, the small hitches left once #118's DNS fix let streams play from the fast CDNs through the VPN.

#122: a frame-exact resize

  • The bug: the video match ran every segment through the fps filter, even at the stream's own rate. With uneven source timestamps, 2 of 12 served segments came out one frame short, a skip about every 20 s on Panthers vs. Broncos.
  • At the channel's rate, a stream is now only scaled, with the encoder on the segment's own 90 kHz clock: 252 frames in, 252 out, and the SPS still declares the channel's rate.
  • At another rate, it converts to the exact rational rate (60000/1001), and each segment's grid starts where the previous one ended.
  • The count: frames lost in a re-encode are counted over 10 minutes (video.dropped_frames, video.dropped_segments). The Playing card shows an amber "−N" beside the picture chip when there are any.
  • The cadence's counted rate comes from a fit over all the timestamps, so it reads 59.94, not 62.5, for a stream with uneven timestamps.
  • Checked in the production image (ffmpeg 7.1.5): the new command turned a 252-frame 720p segment into 252 frames at 1152×648, 60000/1001.

#121: pooled upstream connections

  • One client: one pooled keep-alive client per event loop and certificate mode, in place of a fresh TCP+TLS connection for every playlist poll and segment. The tunnel lost about 2% of new connections under bursts (#118).
  • Per request: each request keeps its own timeout, and a failed connect is tried once more.
  • Closing: callers close the response and get a lease whose close does nothing, so the relay is unchanged. The app closes the pool at shutdown.
  • Tests: they run against a loopback server that counts connections: ten polls open one connection, a burst is reused, a server that hangs up costs a new connection rather than a failure, and the per-request timeout holds.

OpenSpec: the change smoother-playback, validated with --strict.

Lanes (run locally)

  • make test (frontend built first): 1166 passed, 1 skipped
  • npm --prefix frontend test: 247 passed
  • make e2e: passed

Closes #121, #122

🤖 Generated with Claude Code

Milestone 40, "Smoother playback": #121 and #122, the small hitches left once #118's DNS fix let streams play from the fast CDNs through the VPN. ## #122: a frame-exact resize - **The bug:** the video match ran every segment through the `fps` filter, even at the stream's own rate. With uneven source timestamps, 2 of 12 served segments came out one frame short, a skip about every 20 s on Panthers vs. Broncos. - **At the channel's rate,** a stream is now only scaled, with the encoder on the segment's own 90 kHz clock: 252 frames in, 252 out, and the SPS still declares the channel's rate. - **At another rate,** it converts to the exact rational rate (`60000/1001`), and each segment's grid starts where the previous one ended. - **The count:** frames lost in a re-encode are counted over 10 minutes (`video.dropped_frames`, `video.dropped_segments`). The Playing card shows an amber "−N" beside the picture chip when there are any. - **The cadence's counted rate** comes from a fit over all the timestamps, so it reads 59.94, not 62.5, for a stream with uneven timestamps. - **Checked in the production image** (ffmpeg 7.1.5): the new command turned a 252-frame 720p segment into 252 frames at 1152×648, 60000/1001. ## #121: pooled upstream connections - **One client:** one pooled keep-alive client per event loop and certificate mode, in place of a fresh TCP+TLS connection for every playlist poll and segment. The tunnel lost about 2% of new connections under bursts (#118). - **Per request:** each request keeps its own timeout, and a failed connect is tried once more. - **Closing:** callers close the response and get a lease whose close does nothing, so the relay is unchanged. The app closes the pool at shutdown. - **Tests:** they run against a loopback server that counts connections: ten polls open one connection, a burst is reused, a server that hangs up costs a new connection rather than a failure, and the per-request timeout holds. **OpenSpec:** the change `smoother-playback`, validated with `--strict`. ## Lanes (run locally) - `make test` (frontend built first): 1166 passed, 1 skipped - `npm --prefix frontend test`: 247 passed - `make e2e`: passed Closes #121, #122 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Milestone 40, from the evening of 2026-11-08 after #118's DNS fix.

#122: the video match re-gridded every segment through the fps filter,
even at the stream's own rate, and with uneven source timestamps 2 of 12
segments came out a frame short (a skip about every 20 s on Panthers vs.
Broncos). A stream at the channel's rate is now only scaled, the encoder
on the segment's own 90 kHz clock (252 frames in, 252 out); another rate
converts to the exact rational rate (60000/1001) with the grid carried
from segment to segment. Frames lost in a re-encode are counted for 10
minutes and shown on the Playing card. The cadence's counted rate comes
from a fit over all the timestamps (59.94, not 62.5, for uneven steps).

#121: upstream fetches share one pooled keep-alive client per loop and
certificate mode instead of a fresh TCP+TLS connection per playlist poll
and segment (the tunnel lost about 2% of new connections under bursts,
#118); each request keeps its own timeout, a failed connect is tried
once more, callers close the response, the app closes the pool.

OpenSpec change smoother-playback. Lanes: make test 1166 passed (1
skipped), frontend 247 passed, make e2e passed. The new ffmpeg command
was run in the production image (ffmpeg 7.1.5): 252 frames in and out.

Closes #121, #122

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmoriarty merged commit f520e518d4 into develop 2026-11-08 16:46:14 -05: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
cmoriarty/sports-breaker!123
No description provided.