Skip to content

Kept typed-rate and sampled encodes on the source frames they stand for - #104

Merged
CodyCBakerPhD merged 12 commits into
mainfrom
claude/trusting-gates-w61ru8-encsync
Dec 3, 2026
Merged

CodyCBakerPhD merged 12 commits into
mainfrom
claude/trusting-gates-w61ru8-encsync

Conversation

@CodyCBakerPhD

Copy link
Copy Markdown
Member

Two encode-side offsets the real-Chromium probe found after #103.

  • Typed frame rate: an output -r kept each source frame until it had fallen more than a frame behind, so 50 to 25 fps showed the frame 3 before the one on screen, and 30 to 24 fps 1 or 2 before. A typed rate is now an fps=N:round=up filter in the -vf chain, ahead of the scale or pad, with no -r. This changes the displayed command, the whole-file encode, Reencode samples and Compare squares.
  • Sampling lead: round=up alone judders on timestamps rounded to the millisecond (common after a remux out of Matroska) or jittered by a few ms: 30 to 15 fps stepped 1, 3 and 2 source frames. A settb=AVTB,setpts=PTS-<lead>/TB ahead of the filter takes each frame an eighth of a frame after its instant (an eighth of the faster of the source and typed rates). The A/B window reads the original at the same lead.
  • Copied cuts: a cut stretch's video can start up to a frame after its audio (20 ms on a 29.97 fps file cut at 17.017 s). The constant-rate encode filled the gap by repeating frame 0, putting every later frame one behind. Sampled encodes of cut stretches now start the video at zero (-STARTPTS). The whole-file and displayed commands do not, and Compare squares cached from the old command are measured again.

Probe, main → this branch, in source frames behind the original pane (most frames):

Scenario main branch
50 → 25 fps -3/-4 0
30 → 24 fps (Reencode) -1/-2 0
30 → 7.5 fps -5 0
29.97 → 14.985 / 25 fps -3 / -1 0 / 0
59.94 → 29.97 fps -3/-4 0
25 → 30 fps 0/+1 0
29.97 and 59.94 fps at source rate, later stretches -1 0
Whole file, 30 → 24 fps -1/-2 0
Reference demo (B-frames) -3/-4 -2

Native ffmpeg 6.1 and the in-browser core (5.1) give the same frames. Encoded frame rate and keyframe spacing are unchanged. Samples no longer encode the frames past the stretch end.

Left open: the reference demo's -2 is the B-frame edit-list item of #86. A variable-rate source with no typed rate still shows the next frame in about a third of slots. Files without a keyframe table, trimmed rather than cut, can still be off by up to half an output frame at a typed rate (main was off by 2 to 5).

No Chromatic snapshot change expected.

Prompts

just fix em


Generated by Claude Code

claude added 12 commits December 3, 2026 17:27
A typed rate now goes into the one -vf chain, ahead of the scale or pad, as
fps=N:round=up, which shows at each output frame the source frame on screen at
that instant. An output -r kept every frame until it fell more than a frame
behind, so 50 fps taken to 25 showed the source frame three before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
The copy cut rebases a stretch on its audio, which starts before the keyframe
the video is cut at, so the video started a little after zero and the
constant-rate encode repeated its first frame into the gap, putting every later
frame one behind the source frame the A/B window pairs it with. Sampled encodes
of cut stretches now lead their -vf with setpts=PTS-STARTPTS; the command shown,
the whole-file encode and the trim of a file with no keyframe table are
unchanged. The measurement cache keys a square on that same command, so squares
measured before are measured again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
…r each instant

fps=N:round=up took a source frame only if its timestamp was not even a hair
past the output instant, so a source with millisecond-rounded or jittered
timestamps decimated unevenly: 30 fps taken to 15 stepped 1, 3 and 2 source
frames. A typed rate now moves every frame earlier by samplingLeadSeconds, an
eighth of a source frame (settb=AVTB,setpts before the fps filter, folded into
the setpts that starts a cut stretch at zero), and the A/B window reads the
original at the same lead, which also pairs source-rate encodes of such
sources correctly.

Measured on native ffmpeg 6.1.1 and the wasm core (5.1), identical on both:
millisecond 30->15 steps {1:150, 2:149, 3:150} became {2:449}, +-2 ms jitter
30->15 {1:106, 2:239, 3:105} became {2:449}, and millisecond 59.94->29.97
became all 2. At the source's own rate the A/B paired 17 to 27 of every 60
frames of those sources with the source frame before; now none.
Exact-timestamp sources (50->25, 30->24/20/15/7.5/1, 29.97->14.985,
59.94->29.97, 25->30, 30->60, VFR, late-starting video, cut stretches) pick
the same frames at the same sizes and keyframes. Where an output instant
falls less than the lead before a source frame's start (100 of 751 slots of
29.97->25, 150 of 1800 of 25->60) it now takes that frame, and the A/B pairs
it with the same one. Without settb a 1/30 time-base source showed the next
frame everywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
…ests

compareTab's trim test sliced the arguments after -i inline, the same thing
segmentRun's tests did with a local afterInput. It now lives in
tests/unit/helpers/ffmpegArgs.ts (named apart from helpers/arguments.ts, which
is about call-argument limits) and both files import it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
The it.each named its rows with %o, which no other test does, and its second
assertion ignored the row it ran for. The rows now carry a $label, the first
passes no options at all so the default is what is checked, and the
row-blind assertion is gone (the chain check already pins it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
A separate test rebuilt the same trim inputs only to check the -vf chain.
The trim test now runs at a typed rate and checks the chain itself; it still
fails if a trimmed stretch is moved to zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
Nothing failed if inBrowserEncode passed startVideoAtZero to the builder, which
on a source whose video starts after its audio (0.1 s on the probe's
nob30late.mp4) would play every frame of the user's output that much early
against the copied audio. The whole-file test now checks the command has no
STARTPTS. It checks STARTPTS rather than setpts because a typed rate's
sampling lead puts a setpts in every command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
Passing startVideoAtZero to the builder for the Reencode tab's command
(cliControls) or Full Analysis's Command Builder block (analysisTab) left the
whole unit suite passing, though either is the command a user copies and runs
on their whole file. Each test now checks its command has no STARTPTS, and
each fails its own mutation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
…ctly

B-frame sources such as the reference demo still show the encoded pane two
frames behind (the edit-list offset this branch leaves alone), so the entry
now says the samples no longer fall an extra frame behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
…ce's

The lead was an eighth of a source frame whatever the typed rate, so at eight
times the source's rate or more it was a whole output frame or more, put the
first source frame before zero, and the encode started that many frames later
than the A/B window paired them. It is now an eighth of a frame of the faster
of the source's rate and the typed one, and the A/B window reads the original
at the lead of the rate the encode was made at.

Measured on native ffmpeg 6.1.1 and the wasm core (5.1.4), identical on both,
with lossless encodes content-matched against the source: 30 fps typed 240
paired 59 of 480 frames with the source frame after the one shown, 3 fps typed
30 paired 29 of 300 so, and 1 fps typed 30 lost a frame (299 of 300) and paired
18; all now pair every frame, with the frame counts, durations and keyframes of
the encodes before the lead. 25 fps typed 200 and a copy-cut 30 fps stretch
typed 240 likewise. Typed rates at or below the source's keep the lead they had.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw74tPQDnDqyNERnS42
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-12-03 20:34 UTC

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/lib/cliCommand.ts 100.00% <100.00%> (ø)
src/ui/abPanel.ts 100.00% <100.00%> (ø)
src/ui/compareTab.ts 100.00% <100.00%> (ø)
src/ui/segmentRun.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CodyCBakerPhD CodyCBakerPhD self-assigned this Dec 3, 2026
@CodyCBakerPhD
CodyCBakerPhD marked this pull request as ready for review December 3, 2026 19:33
@CodyCBakerPhD
CodyCBakerPhD merged commit 27872c7 into main Dec 3, 2026
18 checks passed
@CodyCBakerPhD
CodyCBakerPhD deleted the claude/trusting-gates-w61ru8-encsync branch December 3, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants