Skip to content

Fix desktop 1080p/original export via growable ffmpeg core - #101

Merged
wassgha merged 2 commits into
mainfrom
cursor/fix-export-ffmpeg-memory-bacd
Sep 14, 2026
Merged

wassgha merged 2 commits into
mainfrom
cursor/fix-export-ffmpeg-memory-bacd

Conversation

@wassgha

@wassgha wassgha commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Discord reports (yerhss / Jandev): 1080p and original video export fail in the desktop app with something about “ffmpeg not starting”, while the same export works in the browser. Jandev linked #92 — that PR correctly stopped the hang, but left the underlying 1 GiB ceiling for a follow-up.

Root cause

@ffmpeg/core-mt instantiates a fixed 1 GiB WebAssembly.Memory (initial === maximum, shared). Under Electron memory pressure after ASR (ORT heaps still resident), that buffer often fails to allocate on export re-init — or the encode OOMs mid-filtergraph for 1080p/original. System RAM (e.g. M4 Pro 48 GB) does not help; this is the wasm heap limit.

Fix

  • Ship @ffmpeg/core (single-threaded, growable 32 MiB → 2 GiB) to /vendor/ffmpeg-st/
  • Video/audio export always loads the growable core
  • Audio extraction still prefers multi-threaded, with automatic fallback to the growable core if the 1 GiB SAB cannot be reserved
  • Terminate the transcription worker on complete so ORT heaps are released before the user exports (every transcribe() already starts a fresh worker)

Evidence

ffmpeg-core-tests.log

ffmpeg-memory-limits.log

Tests

  • npm run test:ffmpeg — watchdog + new core-selection / asset presence checks
  • npm run test:timeline, npm run test:i18n
  • npm run typecheck:electron
Open in Web Open in Cursor 

The multi-threaded @ffmpeg/core-mt hard-commits a fixed 1 GiB shared
heap, which is what made high-res export fail in the desktop app
(Discord: "ffmpeg not starting") after PR #92 stopped the hang.
Ship @ffmpeg/core for export (growable to 2 GiB), keep MT for audio
extraction with ST fallback, and drop the transcription worker once
ASR finishes so its ORT heaps are not still competing for memory.

Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
@vercel

vercel Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
app.rescript Ready Ready Preview Sep 14, 2026 10:50pm UTC

If the multi-threaded core fails mid-load, drop its class worker before
retrying the growable single-threaded core so the failed attempt does not
keep its allocation.

Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
@wassgha
wassgha marked this pull request as ready for review September 14, 2026 22:51
@wassgha
wassgha merged commit 4d6f295 into main Sep 14, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — aecf17d2 Deployed Sep 14, 2026 by vercel[bot]
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.

2 participants