Skip to content

fix: fixed audio filter chaining and add Vitest for unit testing#440

Merged
magic-peach merged 4 commits into
magic-peach:mainfrom
Shivansh181003:fix/audio-atempo-chain-logic
May 17, 2026
Merged

fix: fixed audio filter chaining and add Vitest for unit testing#440
magic-peach merged 4 commits into
magic-peach:mainfrom
Shivansh181003:fix/audio-atempo-chain-logic

Conversation

@Shivansh181003
Copy link
Copy Markdown
Contributor

Fix: Handle extreme audio speeds via atempo filter chaining

Description

This pull request fixes the audio distortion and silent export failures that occur when the user sets an audio speed outside the [0.5, 2.0] range natively supported by the FFmpeg atempo filter.

To achieve arbitrary speeds like 0.25x or 4.0x, the buildAudioFilter function was refactored to dynamically chain multiple atempo filters together mathematically. Additionally, since the project lacked a unit test runner, vitest was added as a development dependency, and a dedicated test suite for ffmpeg.ts was implemented to protect this logic from future regressions.

Closes #6

Acceptance Criteria Details

  • Valid atempo chain logic: Ensures mathematically that 0.25x speed is properly constructed as atempo=0.5,atempo=0.5.
  • Unit tests added: A test suite (src/lib/tests/ffmpeg.test.ts) has been written using vitest to validate chaining logic across boundary values, standard use cases, and extreme speeds.
  • Distortion-free exports: Export operations with speeds like 0.25x and 4.0x will now generate valid FFmpeg commands, preventing premature crashes and outputting correctly stretched audio.

PR Checklist

(Checked according to CONTRIBUTING.md guidelines)

  • Code works in Chrome, Firefox, and Safari
  • No new TypeScript errors (bunx tsc --noEmit)
  • ESLint passes (bun run lint)
  • UI changes tested on mobile (use browser DevTools) (N/A)
  • Accessibility: new interactive elements have ARIA labels (N/A)
  • Issue number referenced in PR description

@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

@Shivansh181003 is attempting to deploy a commit to the magic-peach1's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Thanks for your PR, @Shivansh181003!

Welcome to Reframe — a browser-based video editor built for everyone 🎬

What happens next

  1. 🤖 Automated checks — build & TypeScript typecheck will run automatically
  2. Vercel preview — a preview deployment will be created (requires maintainer authorization for fork PRs)
  3. 👀 Code review — a maintainer will review your changes
  4. 🚀 Merge — once approved, your PR will be merged!

Quick checklist

  • PR title follows Conventional Commits (e.g. feat: add dark mode)
  • Linked the issue this PR closes (e.g. Closes #123)
  • Tested the changes locally (bun run dev)
  • Build passes (bun run build)

Useful links

Happy coding! 🎉

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 16, 2026

✅ PR Format Check Passed — @Shivansh181003

Basic 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.

@github-actions github-actions Bot added dependencies Updates to dependency files enhancement Improvement to existing functionality ffmpeg FFmpeg/WASM processing related testing Tests needed or test infrastructure labels May 16, 2026
@magic-peach magic-peach added gssoc'26 GirlScript Summer of Code 2026 level:intermediate Intermediate level - 35 pts type:bug Bug fix type:testing Testing and removed enhancement Improvement to existing functionality testing Tests needed or test infrastructure dependencies Updates to dependency files ffmpeg FFmpeg/WASM processing related labels May 16, 2026
@magic-peach
Copy link
Copy Markdown
Owner

Hey @Shivansh181003! This PR has a merge conflict that needs to be resolved before it can be reviewed. Please rebase onto the latest main:

git fetch origin
git rebase origin/main
# resolve any conflicts
git push --force-with-lease

Also note: this PR adds Vitest as a testing dependency. Please check that it's added to bun.lock (not package-lock.json) and that the tests run correctly with bun test.

@magic-peach magic-peach added the gssoc:approved Approved for GSSoC'26 label May 16, 2026
@Shivansh181003 Shivansh181003 force-pushed the fix/audio-atempo-chain-logic branch from bfece26 to 2ee4ea9 Compare May 16, 2026 08:58
@github-actions github-actions Bot added dependencies Updates to dependency files enhancement Improvement to existing functionality ffmpeg FFmpeg/WASM processing related testing Tests needed or test infrastructure labels May 16, 2026
@magic-peach
Copy link
Copy Markdown
Owner

Hi @Shivansh181003 👋 This PR has a merge conflict with main. Please update your branch:

git fetch upstream && git merge upstream/main
# resolve any conflicts, then:
git push

Once conflicts are resolved and CI passes, this will be ready to merge. 🙂

@magic-peach magic-peach added the needs-fixes PR has issues that need to be fixed label May 16, 2026
@Shivansh181003
Copy link
Copy Markdown
Contributor Author

I have resolved the conflicts.
While on the issue is closed by you, does it needs any further actions or i also should consider it as finished ?
@magic-peach

@magic-peach magic-peach added quality:clean Well-implemented, clean code type:design UI/UX design labels May 16, 2026
@magic-peach magic-peach added the type:performance Performance label May 16, 2026
@magic-peach
Copy link
Copy Markdown
Owner

Hey @Shivansh181003, the audio filter chaining fix and Vitest tests look good! Quick note: the PR adds vitest to bun.lock and package.json, which is fine. The only concern is that the tests are in src/lib/tests/ rather than the conventional src/lib/__tests__/ directory — but that's minor. Could you also check if there's a vitest config needed or if bun test runs these? Overall looks solid!

@magic-peach magic-peach added the needs-review Needs maintainer review label May 16, 2026
@magic-peach magic-peach enabled auto-merge (squash) May 16, 2026 17:48
@github-actions github-actions Bot added the level:advanced Advanced level - 55 pts label May 17, 2026
@magic-peach magic-peach merged commit 58bc39f into magic-peach:main May 17, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Updates to dependency files enhancement Improvement to existing functionality ffmpeg FFmpeg/WASM processing related gssoc:approved Approved for GSSoC'26 gssoc'26 GirlScript Summer of Code 2026 level:advanced Advanced level - 55 pts level:intermediate Intermediate level - 35 pts needs-fixes PR has issues that need to be fixed needs-review Needs maintainer review quality:clean Well-implemented, clean code testing Tests needed or test infrastructure type:bug Bug fix type:design UI/UX design type:performance Performance type:testing Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Audio filter chain fails for speed below 0.5x due to atempo range restriction

2 participants