Video match: the resize drops a frame about every 20 s, and the panel can't see it #122

Closed
opened 2026-11-08 16:09:42 -05:00 by cmoriarty · 1 comment
Owner

The owner, 2026-11-08 around 21:00Z, on Panthers vs. Broncos in Emby for Android on the Shield (direct play): stable, but short skips every so often, with nothing on the Admin page to tie them to.

What happens

  • Why the stream is re-encoded at all:
    • The channel keeps the shape of the first stream it played, 1152×648 at 59.94 fps (#39, videonorm.py).
    • Since a recovery at 20:59:55 it has played edgestream3.pro (via tvsportslive.fr), which is 1280×720 at 59.94 fps.
    • So every segment is re-encoded to 1152×648, about 1.4 s of work per 4 s segment.
  • The served segments: 12 of them (2131–2142, about 48 s), checked with ffprobe:
    • audio is perfectly continuous across every boundary;
    • video loses exactly one frame (16.7 ms) at the end of 2 of the 12. Segments 2135 and 2140 carry 251 frames where their 4.204 s needs 252, and the next segment starts 17 ms later.
  • The source's own segments are complete: 252 and 231 frames, matching their EXTINF. Their timestamps are uneven, though, with steps as short as 15 ms against the 16.7 ms average.
  • The likely cause:
    • ffmpeg_args puts every segment through fps={shape.fps} with -copyts, which re-grids it to the shape's frame rate.
    • With uneven input timestamps, the grid at a segment's end sometimes comes out one frame short.
    • Each segment is encoded on its own, so that frame is never recovered.
    • Here the rates already match (59.94 = 59.94), so the re-grid isn't needed at all.
    • The filter is also given 59.94, not the exact 60000/1001.
  • Why the panel shows nothing:
    • Nothing counts frames lost in a re-encode. The card says the video is matched (video.matching), but not that it loses frames.
    • The health's cadence for this channel read "62.5 of 62.5 fps" for a 59.94 fps stream, so the cadence count on re-encoded segments needs a look too.
  • Not this issue: the switch at 20:59:55 was a real jump. Another site runs the stream at another delay, and the card shows it only as "recovered on …" in its recent list.

The idea

  1. Scale only when the rates already match. When the stream's frame rate matches the shape's within FPS_TOLERANCE, drop the fps filter, so frames and timestamps pass 1:1 (-fps_mode passthrough is already there).
  2. When the rates differ (30 → 59.94, say), keep the filter, but give it the exact rational rate (60000/1001, 30000/1001). Carry its grid across segments, so a boundary never loses a frame: start each segment's grid where the last one ended.
  3. Count frames in and out of every re-encode. A segment that comes out short is counted on the channel, as frames dropped in the last 10 minutes. The card shows that count beside the matched mark, so a skip has something to tie it to.
  4. Check the cadence measure on re-encoded segments (the 62.5 of 62.5 fps reading).

Done when

  • In the unit lane:
    • a 1280×720 segment at 59.94 fps with uneven timestamps, re-encoded to 1152×648 at 59.94, keeps its frame count (252 in, 252 out);
    • the next segment continues with no timestamp gap;
    • a 30 fps segment re-encoded to 59.94 still comes out at the shape's rate, with no gap at the boundary;
    • a re-encode that comes out short is counted on the channel and shown on the card.
  • Live: while a channel is matching, its served segments show no frame gap across boundaries (the ffprobe check above).

Also worth knowing

A 59.94 fps stream on a TV running at 60 Hz repeats a frame about every 17 s, regardless of the app. On the Shield, "Match content frame rate" (Settings → Device Preferences → Display & Sound → Advanced) avoids that. It is worth ruling out before judging the fix live.

The owner, 2026-11-08 around 21:00Z, on Panthers vs. Broncos in Emby for Android on the Shield (direct play): stable, but short skips every so often, with nothing on the Admin page to tie them to. ## What happens - **Why the stream is re-encoded at all:** - The channel keeps the shape of the first stream it played, 1152×648 at 59.94 fps (#39, `videonorm.py`). - Since a recovery at 20:59:55 it has played edgestream3.pro (via tvsportslive.fr), which is 1280×720 at 59.94 fps. - So every segment is re-encoded to 1152×648, about 1.4 s of work per 4 s segment. - **The served segments:** 12 of them (2131–2142, about 48 s), checked with ffprobe: - audio is perfectly continuous across every boundary; - video loses exactly one frame (16.7 ms) at the end of 2 of the 12. Segments 2135 and 2140 carry 251 frames where their 4.204 s needs 252, and the next segment starts 17 ms later. - **The source's own segments are complete:** 252 and 231 frames, matching their EXTINF. Their timestamps are uneven, though, with steps as short as 15 ms against the 16.7 ms average. - **The likely cause:** - `ffmpeg_args` puts every segment through `fps={shape.fps}` with `-copyts`, which re-grids it to the shape's frame rate. - With uneven input timestamps, the grid at a segment's end sometimes comes out one frame short. - Each segment is encoded on its own, so that frame is never recovered. - Here the rates already match (59.94 = 59.94), so the re-grid isn't needed at all. - The filter is also given `59.94`, not the exact `60000/1001`. - **Why the panel shows nothing:** - Nothing counts frames lost in a re-encode. The card says the video is matched (`video.matching`), but not that it loses frames. - The health's cadence for this channel read "62.5 of 62.5 fps" for a 59.94 fps stream, so the cadence count on re-encoded segments needs a look too. - **Not this issue:** the switch at 20:59:55 was a real jump. Another site runs the stream at another delay, and the card shows it only as "recovered on …" in its recent list. ## The idea 1. **Scale only when the rates already match.** When the stream's frame rate matches the shape's within `FPS_TOLERANCE`, drop the `fps` filter, so frames and timestamps pass 1:1 (`-fps_mode passthrough` is already there). 2. **When the rates differ** (30 → 59.94, say), keep the filter, but give it the exact rational rate (`60000/1001`, `30000/1001`). Carry its grid across segments, so a boundary never loses a frame: start each segment's grid where the last one ended. 3. **Count frames in and out of every re-encode.** A segment that comes out short is counted on the channel, as frames dropped in the last 10 minutes. The card shows that count beside the matched mark, so a skip has something to tie it to. 4. **Check the cadence measure on re-encoded segments** (the 62.5 of 62.5 fps reading). ## Done when - **In the unit lane:** - a 1280×720 segment at 59.94 fps with uneven timestamps, re-encoded to 1152×648 at 59.94, keeps its frame count (252 in, 252 out); - the next segment continues with no timestamp gap; - a 30 fps segment re-encoded to 59.94 still comes out at the shape's rate, with no gap at the boundary; - a re-encode that comes out short is counted on the channel and shown on the card. - **Live:** while a channel is matching, its served segments show no frame gap across boundaries (the ffprobe check above). ## Also worth knowing A 59.94 fps stream on a TV running at 60 Hz repeats a frame about every 17 s, regardless of the app. On the Shield, "Match content frame rate" (Settings → Device Preferences → Display & Sound → Advanced) avoids that. It is worth ruling out before judging the fix live.
Author
Owner

Closing: merged to develop in PR #123 (merge f520e51), milestone 40. It deploys once nobody is watching.

What changed:

  • At the channel's rate, a stream is now only scaled, with the encoder on the segment's own 90 kHz clock, so every frame passes 1:1.
  • At another rate, it converts to the exact rational rate, with the grid carried from segment to segment.
  • Lost frames are counted over 10 minutes and shown as an amber "−N" on the Playing card.
  • The cadence reads 59.94 for uneven timestamps, where it read 62.5.
  • Checked in the production image (ffmpeg 7.1.5): 252 frames in, 252 out, at 60000/1001.

Not seen live yet: a matched channel's served segments with no frame gap at their boundaries.

Closing: merged to develop in PR #123 (merge f520e51), milestone 40. It deploys once nobody is watching. **What changed:** - **At the channel's rate,** a stream is now only scaled, with the encoder on the segment's own 90 kHz clock, so every frame passes 1:1. - **At another rate,** it converts to the exact rational rate, with the grid carried from segment to segment. - **Lost frames** are counted over 10 minutes and shown as an amber "−N" on the Playing card. - **The cadence** reads 59.94 for uneven timestamps, where it read 62.5. - **Checked in the production image** (ffmpeg 7.1.5): 252 frames in, 252 out, at 60000/1001. **Not seen live yet:** a matched channel's served segments with no frame gap at their boundaries.
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#122
No description provided.