OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.
TypeScript
fix: add ProRes to memory-intensive codecs, prevent browser crash on vertical video export
Augustus Otu53d813da26aa
diff --git a/packages/core/src/export/export-engine.ts b/packages/core/src/export/export-engine.tsindex 6abb30a4..a6569830 100644--- a/packages/core/src/export/export-engine.ts+++ b/packages/core/src/export/export-engine.ts@@ -232,26 +232,42 @@ export class ExportEngine {};const pixelCount = fullSettings.width * fullSettings.height;+ const isProRes = fullSettings.codec === "prores";const isMemoryIntensiveCodec =fullSettings.codec === "vp9" ||fullSettings.codec === "av1" ||- fullSettings.codec === "h265";- const maxSafePixels = isMemoryIntensiveCodec ? 1920 * 1080 : 3840 * 2160;+ fullSettings.codec === "h265" ||+ isProRes;+ const maxSafePixels = isProRes+ ? 1280 * 720+ : isMemoryIntensiveCodec+ ? 1920 * 1080+ : 3840 * 2160;if (pixelCount > maxSafePixels && isMemoryIntensiveCodec) {+ const maxDimension = isProRes ? 1280 : 1920;console.warn(- `[ExportEngine] ${fullSettings.codec.toUpperCase()} at ${fullSettings.width}x${fullSettings.height} may cause browser instability. Reducing to 1080p for stability.`,+ `[ExportEngine] ${fullSettings.codec.toUpperCase()} at ${fullSettings.width}x${fullSettings.height} may cause browser instability. Reducing for stability.`,);const aspectRatio = fullSettings.width / fullSettings.height;if (aspectRatio > 1) {- fullSettings.width = 1920;- fullSettings.height = Math.round(1920 / aspectRatio);+ fullSettings.width = maxDimension;+ fullSettings.height = Math.round(maxDimension / aspectRatio);} else {- fullSettings.height = 1920;- fullSettings.width = Math.round(1920 * aspectRatio);+ fullSettings.height = maxDimension;+ fullSettings.width = Math.round(maxDimension * aspectRatio);}fullSettings.width = Math.round(fullSettings.width / 2) * 2;fullSettings.height = Math.round(fullSettings.height / 2) * 2;++ if (isProRes) {+ fullSettings.codec = "h264";+ fullSettings.format = "mp4";+ fullSettings.bitrate = 20000;+ console.warn(+ `[ExportEngine] ProRes not supported in browser at this resolution. Switching to H.264 at ${fullSettings.width}x${fullSettings.height}.`,+ );+ }}this.abortController = new AbortController();@@ -355,11 +371,12 @@ export class ExportEngine {await output.start();- const isMemoryIntensiveCodec =+ const isIntensiveCodec =fullSettings.codec === "vp9" ||fullSettings.codec === "av1" ||- fullSettings.codec === "h265";- const flushInterval = isMemoryIntensiveCodec ? 15 : 30;+ fullSettings.codec === "h265" ||+ fullSettings.codec === "prores";+ const flushInterval = isIntensiveCodec ? 10 : 30;for (let frame = 0; frame < totalFrames; frame++) {if (this.abortController.signal.aborted) {