Skip to content

fix(engine): nested video clips on a frame boundary export every source frame - #6893

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/engine-float-time-args
Oct 31, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/engine-float-time-args

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

A nested video clip whose start sums to a frame boundary (for example parent 3.3 s + local 1.3666666666666667 s at 30 fps) now exports with every source frame instead of aborting.

Why

alignClipStartToFirstOutputFrame saw a start of 4.666666666666666 (frame 140, already on the grid) and still shifted mediaStart by 8.88e-16. That value reached ffmpeg/ffprobe in scientific notation, which their parsers reject, and the clip lost frames (7 of 8 captured, below the 95% coverage threshold).

How

  • A shift under a nanosecond is float dust: the start snaps to the frame, mediaStart is untouched. Real shifts (for example a start of 1.999999) still move mediaStart.
  • New formatFfmpegSeconds in utils/ffprobe.ts is the one formatter for -ss, -t and -read_intervals values (extractor, audio mixer, ffprobe helpers). Ordinary times print exactly as before; only exponent forms are rewritten to fixed notation.
  • The 95% coverage threshold is unchanged.

Test plan

  • ffprobe.test.ts and videoFrameExtractor.test.ts: 350 passed, 3 runs in a row on the devbox.
  • On origin/main logic the new align test fails with expected 1.350000000000001 to be 1.35; the formatter tests fail (formatFfmpegSeconds is not a function).
  • oxlint 0 errors, tsc clean for packages/engine.
  • Committed with lint/format/typecheck hooks skipped locally (no node_modules on the Mac); all three were run on the devbox.

Size

Standalone: one root cause and its single formatter; splitting would leave the exponent path or the dust source open.

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE · 0 blockers · 0 important · 1 nit

No blocker at 1b30bf79. The root cause holds up. A shift under 1e-9 now snaps start onto the frame and leaves mediaStart alone, so float dust no longer reaches it. formatFfmpegSeconds only rewrites values that String() would print with an exponent.

Nit, follow-up: some ffmpeg time arguments outside the engine still use String(). In the export path these are producer/.../captureHdrResources.ts:386 and :496 (the -ss from mediaStart/ffmpegSeek) and producer/.../audioTruePeak.ts:50. There are more in studio-server (proxyTranscoder, loudness) and in the CLI's measure/snapshot commands. Now that mediaStart no longer picks up dust, they are not on this bug's path, but a later tiny value would hit the same Invalid duration specification there. formatFfmpegSeconds is exported, so they could switch over in a follow-up.

What I checked
  • The local ffmpeg rejects -ss 8.88e-16 ("Invalid duration specification for ss"), which confirms the failure mode. The formatter maps ±8.88e-16, 5e-7 and 1e-7 to 0 (negative values give 0, not -0) and keeps 1.35 and 4.666666666666666 unchanged.
  • ffprobe.test.ts and videoFrameExtractor.test.ts: with main's source and the PR's tests, the 3 new tests fail (exponent, ordinary times, nested clip on a frame boundary). At head they pass. In both runs, 4 HDR-PNG cICP and stream-classification tests also fail in my sandbox, on main as well, so I put those down to my local ffprobe/fixtures, not this PR.
  • A grep of engine/src finds no remaining String()/template time values for -ss, -t or -read_intervals.
  • At review time CI, regression, CodeQL and Windows render verification were still running on this head; the other workflows were green.

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 119 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (1)

  • seqplainkeys-none-center-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

@miguel-heygen
miguel-heygen added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 47fe685 Oct 31, 2026
90 checks passed
@miguel-heygen
miguel-heygen deleted the fix/engine-float-time-args branch October 31, 2026 20:25
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.

1 participant