Repository navigation
fix: run the export graph the tests cover, not a drifting copy - #1809
Open
chiragjangiir wants to merge 1 commit into
Open
chiragjangiir wants to merge 1 commit into
chiragjangiir wants to merge 1 commit into
Conversation
src/lib/ffmpeg.ts carried a second, complete copy of the FFmpeg argv builder that nothing imported, so only the unit tests exercised it. The copy the worker actually ran had silently drifted: the Sharpness and Volume settings (both wired to UI sliders) produced no filter, trim bounds fell back to 999999 placeholders, and the unconditional -t output cap merged for reframe-oss#1289 landed in the unused copy, leaving exports uncapped and looped-music exports unbounded. Keep one implementation in src/lib/exportGraph.ts, used by both the worker and the tests, and cover the argv the worker passes. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
👷 Deploy request for reframe-os pending review.Visit the deploys page to approve it
|
Contributor
👋 Thanks for your PR, @chiragjangiir!Welcome to Reframe — a browser-based video editor built for everyone 🎬
What happens next
Quick checklist
Useful links
Happy coding! 🎉 |
Contributor
✅ PR Format Check Passed — @chiragjangiirBasic format checks passed. A maintainer will review your code changes. This does not mean the PR is approved — it just means the format is correct. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
src/lib/ffmpeg.tsheld a second, complete copy of the FFmpeg argv builder (buildVideoFilter,buildAudioFilter,buildArguments) that nothing imported —buildArgumentsis not exported and has zero references in the repository atmain. The unit tests imported that copy, so they stayed green whilesrc/lib/ffmpeg.worker.tsran its own copy that had silently drifted behind it.Drift between the tested copy and the executed copy:
ffmpeg.ts(tested, never called)ffmpeg.worker.ts(executed)unsharp=5:5:n:5:5:0.0volume=n.nntrimwith nulltrimEndtrim=start=X(FFmpeg infers the end)trim=start=X:end=999999placeholderatrimwith nulltrimEndatrim=start=Xatrim=start=X:end=999999placeholder-toutput caprecipe.speed !== 1The last row is the user-visible one: PR #1289 ("fix: enforce -t flag on export to prevent infinite loop with background music") is merged, but its diff touched only
src/lib/ffmpeg.ts— the uncalled copy. The executed path kept itsspeed !== 1gate, so the fix never ran at runtime, issue #1577 was closed without a behavioural change, and the duplicate report #1493 is still open.What changed
src/lib/exportGraph.ts: one pure implementation of the export graph —buildVideoFilter,buildAudioFilter,buildAudioTrimFilter,buildDurationArgs,buildArguments. No worker globals, no DOM, no FFmpeg instance.src/lib/ffmpeg.worker.tsimports it and deletes its private copy;src/lib/ffmpeg.tsdeletes its dead copy and re-exports the two filters the existing tests import.buildDurationArgscentralises the-tdecision and rejects durations that cannot be trusted (0from a failed metadata load,Infinityfrom MediaRecorder WebM containers,NaN), which would otherwise reach FFmpeg as-t 0(zero-length export) or-t Infinity(aborts the export).src/lib/tests/exportGraph.test.ts(22 tests) asserts the argv the worker actually passes: duration capping, the looped-music case, volume and muting, codec-per-container, overlay positioning, and the removal of the999999placeholders.Net effect: the export behaves the way the reviewed code intended — Sharpness, Volume and the
-tcap are live — and the tests can no longer pass against a copy nothing runs.Related Issue
Closes #1493
Related: #1577 (closed by #1289 without a behavioural fix), #1289 (merged, landed in the uncalled copy), #1590 (closed unmerged).
Type of Contribution
Participant Info
Screen Recording
A recording is being prepared and will be attached to this PR. Suggested demonstration:
bun run dev→ Audio & Speed → Volume = 0% → Export → the exported file's audio is silent (onmainthe same export keeps full-volume audio).Checklist
bun run lintpasses — run asnpx eslint .→ exit 0 (bun is not installed on this machine)bunx tsc --noEmitpasses — run asnpx tsc --noEmit→ exit 0bun run buildpasses — run asnpx next build --webpack→ exit 0aria-label/ accessible names (no new UI added)console.logstatements left inHow this was verified
Unit tests
Static checks:
npx tsc --noEmit→ 0 ·npx eslint .→ 0 ·npx next build --webpack→ 0 (static export generated).Runtime A/B through the real editor UI. Two dev servers:
localhost:3100= this branch,localhost:3101=main. Each run: import a ~3 s fixture → set Volume → EXPORT → decode the exported MP4 in the page and measure the audio.main-287106300%On
mainthe Volume slider has no effect on the exported audio; on this branch it is exact — 50% halves the amplitude and 0% produces digital silence.The
-tcap was confirmed in the live argv with a temporary diagnostic (since removed):"-t", "3.004000"for a 3.004 s fixture produced a 2.963 s file — no truncation, no overshoot.Pre-existing test failures (not introduced here).
npx vitest runreports 4 failing files / 6 failing tests out of 131; all four fail identically on an unmodifiedmainworktree:src/lib/exportEstimate.test.ts(duplicatedexpectimport — parse error),useVideoEditor.test.tsandThemeToggle.test.tsx(react 19.3.0 vs react-dom 19.2.8 mismatch from f013f3c), andeditorPersistence.test.ts(localStorageundefined). CI does not runvitest(main.ymlruns install + build only).Limitations
-tnow reaches the executed argv whenever the duration is trustworthy — exactly what fix: enforce -t flag on export to prevent infinite loop with backgrou… #1289 intended, and what the new tests assert.-tevidence is container-independent.