OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.
TypeScript
perf: use multi-threaded ffmpeg.wasm with -threads 4 limit
Augustus Otu9534a37e1e88
diff --git a/packages/core/src/media/ffmpeg-fallback.ts b/packages/core/src/media/ffmpeg-fallback.tsindex 954ab8ab..6be3acf1 100644--- a/packages/core/src/media/ffmpeg-fallback.ts+++ b/packages/core/src/media/ffmpeg-fallback.ts@@ -105,16 +105,18 @@ export class FFmpegFallback {this.ffmpeg = new FFmpeg() as unknown as FFmpegInstance;- const baseURL = "https://unpkg.com/@ffmpeg/[email protected]/dist/esm";+ const baseURL = "https://unpkg.com/@ffmpeg/[email protected]/dist/esm";- const [coreURL, wasmURL] = await Promise.all([+ const [coreURL, wasmURL, workerURL] = await Promise.all([toBlobURL(`${baseURL}/ffmpeg-core.js`, "text/javascript"),toBlobURL(`${baseURL}/ffmpeg-core.wasm`, "application/wasm"),+ toBlobURL(`${baseURL}/ffmpeg-core.worker.js`, "text/javascript"),]);await this.ffmpeg.load({coreURL,wasmURL,+ workerURL,});this.loaded = true;} catch (error) {@@ -680,7 +682,7 @@ export class FFmpegFallback {ffmpegArgs.push("-i", "audio.wav");}- ffmpegArgs.push("-threads", "2");+ ffmpegArgs.push("-threads", "4");if (format === "mp4") {ffmpegArgs.push(@@ -909,6 +911,8 @@ export class FFmpegFallback {ffmpegArgs.push("-t", (endTime - startTime).toString());}+ ffmpegArgs.push("-threads", "4");+const needsReencode = speed !== 1 || !useStreamCopy;if (needsReencode) {