Skip to content

Fix: FFmpeg Worker Crashes#1194

Open
mrdeyroy wants to merge 3 commits into
magic-peach:mainfrom
mrdeyroy:fix/ffmpeg-worker-oom-1190
Open

Fix: FFmpeg Worker Crashes#1194
mrdeyroy wants to merge 3 commits into
magic-peach:mainfrom
mrdeyroy:fix/ffmpeg-worker-oom-1190

Conversation

@mrdeyroy
Copy link
Copy Markdown

Fixes #1190

Description

Resolved an issue where ffmpeg.wasm would routinely exhaust browser WebAssembly memory limits (OOM) and crash the web worker when exporting longer duration videos.

Implemented massive memory optimizations:

  • Shifted from duplicating buffers in MEMFS to zero-copy streaming via WORKERFS. By passing raw HTML5 File objects directly to the Web Worker and mounting them with WORKERFS, FFmpeg now streams inputs natively from disk, saving hundreds of megabytes of RAM.
  • Capped encoder threads (-threads 2) to restrict runway libx264 buffer allocations.
  • Explicitly expanded max_muxing_queue_size to prevent buffer overflows during complex filter pipelines.
  • Excluded the out directory from tsconfig.json to prevent static export compile errors.

Testing & Verification

  • npm run build completed perfectly.
  • The project runs successfully without TS or ESLint errors.

Type of Contribution

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • GSSoC contribution

Checklist

  • I have read the contribution guidelines
  • My changes follow the project structure
  • I have tested my changes in Chrome, Firefox, and Safari
  • bun run lint passes (no ESLint errors)
  • bunx tsc --noEmit passes (no TypeScript errors)
  • No console.log statements left in

mrdeyroy added 3 commits May 26, 2026 00:50
…each#1184)

Fixes the bug where VideoPreview and ComparisonPreview incorrectly cropped videos due to misaligned overlay calculations. Replaced the manual math overlay with a dynamic CSS output frame using object-fit to accurately mirror the FFmpeg export behavior.
)

- Constrain WASM thread limit via '-threads 2' to prevent runaway libx264 memory allocations.
- Mitigate '99% Trap' by aggressively cleaning up input buffers from MEMFS prior to the memory-intensive final output read.
- Increase max muxing queue size to prevent buffer overflow.
- Exclude 'out' directory from tsconfig to fix stray Next.js build errors.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

@mrdeyroy 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

github-actions Bot commented May 25, 2026

✅ PR Format Check Passed — @mrdeyroy

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
Copy link
Copy Markdown
Contributor

👋 Thanks for your PR, @mrdeyroy!

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

🟠 GSSoC'26 PR detected — thanks for contributing under GirlScript Summer of Code 2026!

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 github-actions Bot added level:advanced Advanced level - 55 pts type:bug Bug fix type:docs Documentation type:feature New feature type:refactor Code refactor type:testing Testing gssoc'26 GirlScript Summer of Code 2026 labels May 25, 2026
@mrdeyroy mrdeyroy changed the title Fix for FFmpeg Worker Crashes Fix: FFmpeg Worker Crashes May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc'26 GirlScript Summer of Code 2026 level:advanced Advanced level - 55 pts type:bug Bug fix type:docs Documentation type:feature New feature type:refactor Code refactor type:testing Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] FFmpeg worker crashes

1 participant