Create polished demo videos without editing skills. Mac/Windows/Linux
Fix Windows export finalization progress
webadderall344506f88d1a
diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsxindex f79ead6d..d77ec1e9 100644--- a/src/components/video-editor/VideoEditor.tsx+++ b/src/components/video-editor/VideoEditor.tsx@@ -3723,6 +3723,14 @@ export default function VideoEditor() {const isExportSaving = exportProgress?.phase === "saving";const isExportFinalizing = exportProgress?.phase === "finalizing";+ const exportFinalizingProgress = isExportFinalizing+ ? Math.min(+ typeof exportProgress?.renderProgress === "number"+ ? exportProgress.renderProgress+ : (exportProgress?.percentage ?? 99),+ 99,+ )+ : null;const isLightningExportInProgress =exportFormat === "mp4" && exportPipelineModel === "modern" && (isExporting || exportProgress !== null);const isLegacyExportInProgress =@@ -3738,9 +3746,9 @@ export default function VideoEditor() {const exportPercentLabel = exportProgress? isExportSaving? t("editor.exportStatus.saving", "Opening save dialog...")- : isExportFinalizing && typeof exportProgress.renderProgress === "number"+ : isExportFinalizing? t("editor.exportStatus.finalizingPercent", "Finalizing {{percent}}%", {- percent: Math.round(exportProgress.renderProgress),+ percent: Math.round(exportFinalizingProgress ?? 99),}): t("editor.exportStatus.completePercent", "{{percent}}% complete", {percent: Math.round(exportProgress.percentage),@@ -3942,7 +3950,7 @@ export default function VideoEditor() {<divclassName="h-full bg-[#2563EB] transition-all duration-300 ease-out"style={{- width: `${Math.min(isExportFinalizing && typeof exportProgress?.renderProgress === "number" ? exportProgress.renderProgress : (exportProgress?.percentage ?? 8), 100)}%`,+ width: `${Math.min(exportFinalizingProgress ?? (exportProgress?.percentage ?? 8), 100)}%`,}}/>)}diff --git a/src/lib/exporter/modernVideoExporter.ts b/src/lib/exporter/modernVideoExporter.tsindex 4031c3cd..3dacb6cc 100644--- a/src/lib/exporter/modernVideoExporter.ts+++ b/src/lib/exporter/modernVideoExporter.ts@@ -122,7 +122,7 @@ export class ModernVideoExporter {private nativeWriteError: Error | null = null;private maxNativeWriteInFlight = 1;private lastNativeExportError: string | null = null;- private readonly WINDOWS_FINALIZATION_TIMEOUT_MS = 180_000;+ private readonly WINDOWS_FINALIZATION_TIMEOUT_MS = 600_000;private totalExportStartTimeMs = 0;private metadataLoadTimeMs = 0;private rendererInitTimeMs = 0;@@ -354,10 +354,11 @@ export class ModernVideoExporter {return { success: false, error: "Export cancelled", metrics: this.buildExportMetrics() };}- this.reportProgress(totalFrames, totalFrames, "finalizing");+ this.reportFinalizingProgress(totalFrames, 96);if (useNativeEncoder) {stageStartedAt = this.getNowMs();+ this.reportFinalizingProgress(totalFrames, 99);const finishResult = await this.finishNativeVideoExport(nativeAudioPlan);this.finalizationTimeMs = this.getNowMs() - stageStartedAt;if (!finishResult.success || !finishResult.blob) {@@ -377,9 +378,11 @@ export class ModernVideoExporter {stageStartedAt = this.getNowMs();if (this.encoder && this.encoder.state === "configured") {+ this.reportFinalizingProgress(totalFrames, 97);await this.awaitWithWindowsTimeout(this.encoder.flush(), "encoder flush");}+ this.reportFinalizingProgress(totalFrames, 98);await this.awaitWithWindowsTimeout(this.pendingMuxing, "muxing queued video chunks");if (nativeAudioPlan.audioMode !== "none" && !this.cancelled) {@@ -390,6 +393,7 @@ export class ModernVideoExporter {(this.config.sourceAudioFallbackPaths ?? []).length > 0) {this.audioProcessor = new AudioProcessor();+ this.reportFinalizingProgress(totalFrames, 99);await this.awaitWithWindowsTimeout(this.audioProcessor.process(demuxer,@@ -406,6 +410,7 @@ export class ModernVideoExporter {}}+ this.reportFinalizingProgress(totalFrames, 99);const blob = await this.awaitWithWindowsTimeout(this.muxer!.finalize(), "muxer finalization");this.finalizationTimeMs = this.getNowMs() - stageStartedAt;@@ -549,7 +554,11 @@ export class ModernVideoExporter {promise,new Promise<T>((_, reject) => {timeoutId = setTimeout(() => {- reject(new Error(`Export timed out during ${stage} on Windows`));+ reject(+ new Error(+ `Export timed out during ${stage} on Windows after ${Math.round(this.WINDOWS_FINALIZATION_TIMEOUT_MS / 60_000)} minutes`,+ ),+ );}, this.WINDOWS_FINALIZATION_TIMEOUT_MS);}),]);@@ -890,10 +899,15 @@ export class ModernVideoExporter {}}+ private reportFinalizingProgress(totalFrames: number, renderProgress: number) {+ this.reportProgress(totalFrames, totalFrames, "finalizing", renderProgress);+ }+private reportProgress(currentFrame: number,totalFrames: number,phase: ExportProgress["phase"] = "extracting",+ renderProgress?: number,) {const nowMs = this.getNowMs();const elapsedSeconds = Math.max((nowMs - this.exportStartTimeMs) / 1000, 0.001);@@ -903,6 +917,16 @@ export class ModernVideoExporter {const sampleRenderFps = (sampleFrameDelta * 1000) / sampleElapsedMs;const remainingFrames = Math.max(totalFrames - currentFrame, 0);const estimatedTimeRemaining = averageRenderFps > 0 ? remainingFrames / averageRenderFps : 0;+ const safeRenderProgress =+ phase === "finalizing"+ ? Math.max(0, Math.min(renderProgress ?? 99, 99))+ : undefined;+ const percentage =+ phase === "finalizing"+ ? safeRenderProgress ?? 99+ : totalFrames > 0+ ? (currentFrame / totalFrames) * 100+ : 100;if (nowMs - this.lastThroughputLogTimeMs >= 1000 || currentFrame === totalFrames) {const safeFrameCount = Math.max(this.processedFrameCount, 1);@@ -946,13 +970,14 @@ export class ModernVideoExporter {this.config.onProgress({currentFrame,totalFrames,- percentage: totalFrames > 0 ? (currentFrame / totalFrames) * 100 : 100,+ percentage,estimatedTimeRemaining,renderFps: sampleRenderFps,renderBackend: this.renderBackend ?? undefined,encodeBackend: this.encodeBackend ?? undefined,encoderName: this.encoderName ?? undefined,phase,+ renderProgress: safeRenderProgress,});}}diff --git a/src/lib/exporter/videoExporter.ts b/src/lib/exporter/videoExporter.tsindex 6db90240..1275d01a 100644--- a/src/lib/exporter/videoExporter.ts+++ b/src/lib/exporter/videoExporter.ts@@ -95,7 +95,7 @@ export class VideoExporter {private videoColorSpace: VideoColorSpaceInit | undefined;private pendingMuxing: Promise<void> = Promise.resolve();private chunkCount = 0;- private readonly WINDOWS_FINALIZATION_TIMEOUT_MS = 180_000;+ private readonly WINDOWS_FINALIZATION_TIMEOUT_MS = 600_000;private exportStartTimeMs = 0;private progressSampleStartTimeMs = 0;private progressSampleStartFrame = 0;@@ -240,22 +240,28 @@ export class VideoExporter {return { success: false, error: "Export cancelled" };}+ this.reportFinalizingProgress(totalFrames, 96);+if (useNativeEncoder && nativeAudioPlan) {+ this.reportFinalizingProgress(totalFrames, 99);return await this.finishNativeVideoExport(nativeAudioPlan);}// Finalize encodingif (this.encoder && this.encoder.state === "configured") {+ this.reportFinalizingProgress(totalFrames, 97);await this.awaitWithWindowsTimeout(this.encoder.flush(), "encoder flush");}// Wait for queued muxing operations to complete+ this.reportFinalizingProgress(totalFrames, 98);await this.awaitWithWindowsTimeout(this.pendingMuxing, "muxing queued video chunks");if (hasAudio && !this.cancelled) {const demuxer = this.streamingDecoder.getDemuxer();if (demuxer || hasAudioRegions || hasSourceAudioFallback) {this.audioProcessor = new AudioProcessor();+ this.reportFinalizingProgress(totalFrames, 99);await this.awaitWithWindowsTimeout(this.audioProcessor.process(demuxer,@@ -273,6 +279,7 @@ export class VideoExporter {}// Finalize muxer and get output blob+ this.reportFinalizingProgress(totalFrames, 99);const blob = await this.awaitWithWindowsTimeout(this.muxer!.finalize(), "muxer finalization");return { success: true, blob };@@ -326,7 +333,11 @@ export class VideoExporter {promise,new Promise<T>((_, reject) => {timeoutId = setTimeout(() => {- reject(new Error(`Export timed out during ${stage} on Windows`));+ reject(+ new Error(+ `Export timed out during ${stage} on Windows after ${Math.round(this.WINDOWS_FINALIZATION_TIMEOUT_MS / 60_000)} minutes`,+ ),+ );}, this.WINDOWS_FINALIZATION_TIMEOUT_MS);}),]);@@ -590,7 +601,16 @@ export class VideoExporter {exportFrame.close();}- private reportProgress(currentFrame: number, totalFrames: number) {+ private reportFinalizingProgress(totalFrames: number, renderProgress: number) {+ this.reportProgress(totalFrames, totalFrames, "finalizing", renderProgress);+ }++ private reportProgress(+ currentFrame: number,+ totalFrames: number,+ phase: ExportProgress["phase"] = "extracting",+ renderProgress?: number,+ ) {const nowMs = this.getNowMs();const elapsedSeconds = Math.max((nowMs - this.exportStartTimeMs) / 1000, 0.001);const averageRenderFps = currentFrame / elapsedSeconds;@@ -600,6 +620,16 @@ export class VideoExporter {const remainingFrames = Math.max(totalFrames - currentFrame, 0);const estimatedTimeRemaining =averageRenderFps > 0 ? remainingFrames / averageRenderFps : 0;+ const safeRenderProgress =+ phase === "finalizing"+ ? Math.max(0, Math.min(renderProgress ?? 99, 99))+ : undefined;+ const percentage =+ phase === "finalizing"+ ? safeRenderProgress ?? 99+ : totalFrames > 0+ ? (currentFrame / totalFrames) * 100+ : 100;if (sampleElapsedMs >= PROGRESS_SAMPLE_WINDOW_MS) {this.progressSampleStartTimeMs = nowMs;@@ -610,9 +640,11 @@ export class VideoExporter {this.config.onProgress({currentFrame,totalFrames,- percentage: totalFrames > 0 ? (currentFrame / totalFrames) * 100 : 100,+ percentage,estimatedTimeRemaining,renderFps,+ phase,+ renderProgress: safeRenderProgress,});}}