Create polished demo videos without editing skills. Mac/Windows/Linux
fix(export): route trim timelines to native gpu
wiiiii1235ee12d168560
diff --git a/src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.ts b/src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.tsindex 3392b9ee..539159d2 100644--- a/src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.ts+++ b/src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.ts@@ -40,6 +40,13 @@ function createExporter(overrides: Record<string, unknown> = {}) {...overrides,} as never) as unknown as {buildNativeAudioPlan: (videoInfo: DecodedVideoInfo) => unknown;+ buildNativeStaticLayoutVideoTimelineSegments: (videoInfo: DecodedVideoInfo) => Array<{+ sourceStartMs: number;+ sourceEndMs: number;+ outputStartMs: number;+ outputEndMs: number;+ speed: number;+ }>;getNativeStaticLayoutEffectiveDuration: (videoInfo: DecodedVideoInfo) => number;getNativeStaticLayoutSkipReason: (audioPlan: unknown,@@ -183,6 +190,67 @@ describe("ModernVideoExporter native static-layout eligibility", () => {).toBe("unsupported-background-blur");});+ it("allows non-tail trim timelines with native static-layout", () => {+ const exporter = createExporter({+ trimRegions: [{ id: "trim-1", startMs: 10_000, endMs: 12_000 }],+ });+ const effectiveDuration = exporter.getNativeStaticLayoutEffectiveDuration(videoInfo);++ expect(effectiveDuration).toBeCloseTo(58, 3);+ expect(exporter.buildNativeStaticLayoutVideoTimelineSegments(videoInfo)).toEqual([+ {+ sourceStartMs: 0,+ sourceEndMs: 10_000,+ outputStartMs: 0,+ outputEndMs: 10_000,+ speed: 1,+ },+ {+ sourceStartMs: 12_000,+ sourceEndMs: 60_000,+ outputStartMs: 10_000,+ outputEndMs: 58_000,+ speed: 1,+ },+ ]);+ expect(+ exporter.getNativeStaticLayoutSkipReason(+ {+ audioMode: "trim-source",+ audioSourcePath: "recording.mp4",+ trimSegments: [+ { startMs: 0, endMs: 10_000 },+ { startMs: 12_000, endMs: 60_000 },+ ],+ },+ videoInfo,+ effectiveDuration,+ ),+ ).toBeNull();+ });++ it("requires the Windows GPU compositor for non-tail trim timelines", () => {+ const exporter = createExporter({+ experimentalNativeExport: false,+ trimRegions: [{ id: "trim-1", startMs: 10_000, endMs: 12_000 }],+ });++ expect(+ exporter.getNativeStaticLayoutSkipReason(+ {+ audioMode: "trim-source",+ audioSourcePath: "recording.mp4",+ trimSegments: [+ { startMs: 0, endMs: 10_000 },+ { startMs: 12_000, endMs: 60_000 },+ ],+ },+ videoInfo,+ 58,+ ),+ ).toBe("native-timeline-requires-windows-gpu");+ });+it("uses speed timeline duration during native static-layout preflight", () => {const speedRegions: SpeedRegion[] = [{ id: "speed-1", startMs: 1_000, endMs: 4_000, speed: 1.5 },diff --git a/src/lib/exporter/modernVideoExporter.ts b/src/lib/exporter/modernVideoExporter.tsindex 00da8753..6d4eaa39 100644--- a/src/lib/exporter/modernVideoExporter.ts+++ b/src/lib/exporter/modernVideoExporter.ts@@ -1014,6 +1014,22 @@ export class ModernVideoExporter {return buildNativeStaticLayoutTimelineSegments(sourceSegments);}+ private shouldUseNativeStaticLayoutTimelineMap(+ videoInfo: DecodedVideoInfo,+ effectiveDurationSec: number,+ ): boolean {+ const speedRegions = this.config.speedRegions ?? [];+ if (speedRegions.length > 0) {+ return true;+ }++ const trimRegions = this.config.trimRegions ?? [];+ return (+ trimRegions.length > 0 &&+ !this.canUseNativeStaticTailTrim(videoInfo, effectiveDurationSec)+ );+ }+private buildNativeAudioPlan(videoInfo: DecodedVideoInfo): NativeAudioPlan {const speedRegions = this.config.speedRegions ?? [];const audioRegions = this.config.audioRegions ?? [];@@ -1170,17 +1186,13 @@ export class ModernVideoExporter {);}- private canUseNativeStaticLayoutAudioPlan(- audioPlan: NativeAudioPlan,- videoInfo: DecodedVideoInfo,- effectiveDurationSec: number,- ): boolean {+ private canUseNativeStaticLayoutAudioPlan(audioPlan: NativeAudioPlan): boolean {switch (audioPlan.audioMode) {case "none":case "copy-source":return true;case "trim-source":- return this.canUseNativeStaticTailTrim(videoInfo, effectiveDurationSec);+ return true;case "edited-track":return (audioPlan.strategy === "offline-render-fallback" ||@@ -1206,27 +1218,35 @@ export class ModernVideoExporter {return "odd-output-dimensions";}- if (!this.canUseNativeStaticLayoutAudioPlan(audioPlan, videoInfo, effectiveDurationSec)) {+ if (!this.canUseNativeStaticLayoutAudioPlan(audioPlan)) {return `unsupported-audio-mode:${audioPlan.audioMode}`;}- const trimRegions = this.config.trimRegions ?? [];const speedRegions = this.config.speedRegions ?? [];const hasZoomRegions = (this.config.zoomRegions ?? []).length > 0;+ const needsTimelineMap = this.shouldUseNativeStaticLayoutTimelineMap(+ videoInfo,+ effectiveDurationSec,+ );+ if (needsTimelineMap && this.config.experimentalNativeExport !== true) {+ return "native-timeline-requires-windows-gpu";+ }if (- speedRegions.length > 0 &&+ needsTimelineMap &&this.buildNativeStaticLayoutVideoTimelineSegments(videoInfo).length === 0) {- return "unsupported-native-speed-timeline";+ return speedRegions.length > 0+ ? "unsupported-native-speed-timeline"+ : "unsupported-native-trim-timeline";}- if (- (trimRegions.length > 0 &&- !this.canUseNativeStaticTailTrim(videoInfo, effectiveDurationSec)) ||- (hasZoomRegions && this.config.experimentalNativeExport !== true) ||- (this.config.annotationRegions ?? []).length > 0 ||- (this.config.autoCaptions ?? []).length > 0- ) {- return "timeline-edits-present";+ if (hasZoomRegions && this.config.experimentalNativeExport !== true) {+ return "native-zoom-requires-windows-gpu";+ }+ if ((this.config.annotationRegions ?? []).length > 0) {+ return "unsupported-annotation-overlay";+ }+ if ((this.config.autoCaptions ?? []).length > 0) {+ return "unsupported-caption-overlay";}if (this.config.webcam?.enabled && !this.getNativeWebcamSourcePath()) {@@ -1723,12 +1743,18 @@ export class ModernVideoExporter {totalFrames,cursorTelemetry,);- const timelineSegments =- (this.config.speedRegions ?? []).length > 0- ? this.buildNativeStaticLayoutVideoTimelineSegments(videoInfo)- : undefined;- if ((this.config.speedRegions ?? []).length > 0 && !timelineSegments?.length) {- this.nativeStaticLayoutSkipReason = "invalid-native-speed-timeline";+ const needsTimelineMap = this.shouldUseNativeStaticLayoutTimelineMap(+ videoInfo,+ effectiveDuration,+ );+ const timelineSegments = needsTimelineMap+ ? this.buildNativeStaticLayoutVideoTimelineSegments(videoInfo)+ : undefined;+ if (needsTimelineMap && !timelineSegments?.length) {+ this.nativeStaticLayoutSkipReason =+ (this.config.speedRegions ?? []).length > 0+ ? "invalid-native-speed-timeline"+ : "invalid-native-trim-timeline";return null;}const cursorAtlas =