Create polished demo videos without editing skills. Mac/Windows/Linux
Match webcam styling between preview and export
young8e6c6da56eaf
diff --git a/src/components/video-editor/VideoPlayback.tsx b/src/components/video-editor/VideoPlayback.tsxindex df1ee6e9..86b40054 100644--- a/src/components/video-editor/VideoPlayback.tsx+++ b/src/components/video-editor/VideoPlayback.tsx@@ -12,6 +12,7 @@ import {useState,} from "react";import { getAssetPath, getRenderableAssetUrl, getRenderableVideoUrl } from "@/lib/assetPath";+import { WEBCAM_SHADOW_LAYER_PROFILES } from "@/lib/exporter/shadowProfile";import {clampMediaTimeToDuration,enablePitchPreservingPlayback,@@ -126,6 +127,7 @@ import {getWebcamCropSourceRect,getWebcamOverlayDimensionsPx,getWebcamOverlayPosition,+ scaleWebcamOverlayPixels,} from "./webcamOverlay";type PlaybackAnimationState = {@@ -793,6 +795,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(const webcamCorner = webcam?.corner ?? "bottom-right";const webcamCornerRadius = webcam?.cornerRadius ?? DEFAULT_WEBCAM_CORNER_RADIUS;const webcamShadow = webcam?.shadow ?? DEFAULT_WEBCAM_SHADOW;+ const webcamShadowProfile = WEBCAM_SHADOW_LAYER_PROFILES[0];const webcamTimeOffsetMs = webcam?.timeOffsetMs;const webcamCropRegion = webcam?.cropRegion;const webcamMirror = webcam?.mirror ?? false;@@ -841,13 +844,18 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(}return;}+ const scaledMargin = scaleWebcamOverlayPixels(webcamMargin, overlay.clientWidth);+ const scaledRadius = scaleWebcamOverlayPixels(+ webcamCornerRadius,+ overlay.clientWidth,+ );const scaledDimensions = getWebcamOverlayDimensionsPx({containerWidth: overlay.clientWidth,containerHeight: overlay.clientHeight,widthPercent: webcamWidth,heightPercent: webcamHeight,- margin: webcamMargin,+ margin: scaledMargin,zoomScale,reactToZoom: webcamReactToZoom,});@@ -856,7 +864,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(containerHeight: overlay.clientHeight,width: scaledDimensions.width,height: scaledDimensions.height,- margin: webcamMargin,+ margin: scaledMargin,positionPreset: webcamPositionPreset,positionX: webcamPositionX,positionY: webcamPositionY,@@ -874,12 +882,16 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(y: 0,width: scaledDimensions.width,height: scaledDimensions.height,- radius: webcamCornerRadius,+ radius: scaledRadius,});const shadowSize = Math.min(scaledDimensions.width, scaledDimensions.height);- bubble.style.filter = `drop-shadow(0 ${Math.round(shadowSize * 0.06)}px ${Math.round(- shadowSize * 0.22,- )}px rgba(0, 0, 0, ${webcamShadow}))`;+ const shadowOffset = shadowSize * webcamShadowProfile.offsetScale * webcamShadow;+ const shadowBlur = shadowSize * webcamShadowProfile.blurScale * webcamShadow;+ const shadowAlpha = webcamShadowProfile.alphaScale * webcamShadow;+ bubble.style.filter =+ webcamShadow > 0+ ? `drop-shadow(0 ${shadowOffset}px ${shadowBlur}px rgba(0, 0, 0, ${shadowAlpha}))`+ : "none";bubble.style.borderRadius = "0px";bubble.style.boxShadow = "none";diff --git a/src/components/video-editor/webcamOverlay.test.ts b/src/components/video-editor/webcamOverlay.test.tsindex 001f3cd6..701d6a71 100644--- a/src/components/video-editor/webcamOverlay.test.ts+++ b/src/components/video-editor/webcamOverlay.test.ts@@ -6,8 +6,17 @@ import {getWebcamOverlayPosition,isWebcamCropRegionDefault,normalizeWebcamCropRegion,+ scaleWebcamOverlayPixels,} from "./webcamOverlay";+describe("scaleWebcamOverlayPixels", () => {+ it("keeps webcam pixel controls proportional between preview and export", () => {+ expect(scaleWebcamOverlayPixels(24, 960)).toBe(12);+ expect(scaleWebcamOverlayPixels(24, 1920)).toBe(24);+ expect(scaleWebcamOverlayPixels(24, 3840)).toBe(48);+ });+});+describe("normalizeWebcamCropRegion", () => {it("defaults to the full webcam frame", () => {expect(normalizeWebcamCropRegion()).toEqual({ x: 0, y: 0, width: 1, height: 1 });diff --git a/src/components/video-editor/webcamOverlay.ts b/src/components/video-editor/webcamOverlay.tsindex 9ce38212..342415d9 100644--- a/src/components/video-editor/webcamOverlay.ts+++ b/src/components/video-editor/webcamOverlay.ts@@ -1,11 +1,18 @@import type { CropRegion, WebcamCorner, WebcamPositionPreset } from "./types";const MIN_WEBCAM_OVERLAY_SIZE_PX = 56;+export const WEBCAM_REFERENCE_VIEWPORT_WIDTH = 1920;function clamp(value: number, min: number, max: number) {return Math.min(max, Math.max(min, value));}+export function scaleWebcamOverlayPixels(value: number, containerWidth: number): number {+ const safeValue = Number.isFinite(value) ? Math.max(0, value) : 0;+ const safeWidth = Number.isFinite(containerWidth) ? Math.max(0, containerWidth) : 0;+ return safeValue * (safeWidth / WEBCAM_REFERENCE_VIEWPORT_WIDTH);+}+export function getWebcamPositionForPreset(preset: WebcamPositionPreset): { x: number; y: number } {switch (preset) {case "top-left":diff --git a/src/lib/exporter/frameRenderer.ts b/src/lib/exporter/frameRenderer.tsindex a4b73f83..2ae00875 100644--- a/src/lib/exporter/frameRenderer.ts+++ b/src/lib/exporter/frameRenderer.ts@@ -54,6 +54,7 @@ import {getWebcamCropSourceRect,getWebcamOverlayDimensionsPx,getWebcamOverlayPosition,+ scaleWebcamOverlayPixels,} from "@/components/video-editor/webcamOverlay";import { getAssetPath, getExportableVideoUrl, getRenderableAssetUrl } from "@/lib/assetPath";import { drawSquircleOnCanvas, drawSquircleOnGraphics } from "@/lib/geometry/squircle";@@ -2067,7 +2068,7 @@ export class FrameRenderer {: "videoHeight" in webcamFrameSource? webcamFrameSource.videoHeight: webcamFrameSource.height) || sourceWidth;- const margin = webcam.margin ?? 24;+ const margin = scaleWebcamOverlayPixels(webcam.margin ?? 24, width);const widthPercent = webcam.width ?? webcam.size ?? 50;const heightPercent = getCropMatchedWebcamHeightPercent(widthPercent,@@ -2096,7 +2097,7 @@ export class FrameRenderer {positionY: webcam.positionY ?? 1,legacyCorner: webcam.corner,});- const radius = Math.max(0, webcam.cornerRadius ?? 18);+ const radius = scaleWebcamOverlayPixels(webcam.cornerRadius ?? 18, width);const bubbleWidth = Math.max(1, Math.ceil(dimensions.width));const bubbleHeight = Math.max(1, Math.ceil(dimensions.height));if (bubbleCanvas.width !== bubbleWidth || bubbleCanvas.height !== bubbleHeight) {diff --git a/src/lib/exporter/modernFrameRenderer.ts b/src/lib/exporter/modernFrameRenderer.tsindex b9eefea1..5be35b8a 100644--- a/src/lib/exporter/modernFrameRenderer.ts+++ b/src/lib/exporter/modernFrameRenderer.ts@@ -64,6 +64,7 @@ import {getWebcamOverlayDimensionsPx,getWebcamOverlayPosition,isWebcamCropRegionDefault,+ scaleWebcamOverlayPixels,} from "@/components/video-editor/webcamOverlay";import { getAssetPath, getExportableVideoUrl, getRenderableAssetUrl } from "@/lib/assetPath";import { drawSquircleOnCanvas, drawSquircleOnGraphics } from "@/lib/geometry/squircle";@@ -2825,7 +2826,7 @@ export class FrameRenderer {return;}- const margin = webcam.margin ?? 24;+ const margin = scaleWebcamOverlayPixels(webcam.margin ?? 24, this.config.width);const widthPercent = webcam.width ?? webcam.size ?? 50;const aspectSourceWidth =liveSourceDimensions.width > 0@@ -2862,7 +2863,7 @@ export class FrameRenderer {positionY: webcam.positionY ?? 1,legacyCorner: webcam.corner,});- const radius = Math.max(0, webcam.cornerRadius ?? 18);+ const radius = scaleWebcamOverlayPixels(webcam.cornerRadius ?? 18, this.config.width);const shadowStrength = clampUnitInterval(webcam.shadow ?? 0);this.webcamRootContainer.visible = true;diff --git a/src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.ts b/src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.tsindex a1783d8b..50f0e3ba 100644--- a/src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.ts+++ b/src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.ts@@ -387,6 +387,7 @@ describe("ModernVideoExporter native static-layout eligibility", () => {"unsupported-background-video","unsupported-annotation-overlay","unsupported-caption-overlay",+ "native-webcam-style-mismatch","unsupported-webcam-source",]);});@@ -676,7 +677,7 @@ describe("ModernVideoExporter native static-layout eligibility", () => {).toBeNull();});- it("allows slow-speed webcam timelines through native source-time mapping", () => {+ it("uses the shared renderer for slow-speed webcam timelines", () => {const speedRegions: SpeedRegion[] = [{ id: "speed-1", startMs: 1_000, endMs: 4_000, speed: 0.5 },];@@ -697,10 +698,10 @@ describe("ModernVideoExporter native static-layout eligibility", () => {videoInfo,63,),- ).toBeNull();+ ).toBe("native-webcam-style-mismatch");});- it("skips native static layout for rectangular webcam overlays", () => {+ it("uses the shared renderer for rectangular webcam overlays", () => {const exporter = createExporter({webcam: {enabled: true,@@ -719,10 +720,10 @@ describe("ModernVideoExporter native static-layout eligibility", () => {videoInfo,60,),- ).toBe("unsupported-rectangular-webcam-overlay");+ ).toBe("native-webcam-style-mismatch");});- it("allows native speed timelines with a resolvable webcam source", () => {+ it("uses the shared renderer for native speed timelines with a webcam", () => {const speedRegions: SpeedRegion[] = [{ id: "speed-1", startMs: 1_000, endMs: 4_000, speed: 1.5 },];@@ -750,6 +751,6 @@ describe("ModernVideoExporter native static-layout eligibility", () => {videoInfo,59,),- ).toBeNull();+ ).toBe("native-webcam-style-mismatch");});});diff --git a/src/lib/exporter/modernVideoExporter.ts b/src/lib/exporter/modernVideoExporter.tsindex 73df81ee..258b205f 100644--- a/src/lib/exporter/modernVideoExporter.ts+++ b/src/lib/exporter/modernVideoExporter.ts@@ -1561,6 +1561,11 @@ export class ModernVideoExporter {if ((this.config.autoCaptions ?? []).length > 0) {reasons.push("unsupported-caption-overlay");}+ if (this.config.webcam?.enabled) {+ // Native GPU compositors use a different corner and shadow model.+ // Keep webcam exports on the shared renderer used by preview.+ reasons.push("native-webcam-style-mismatch");+ }if (this.config.webcam?.enabled && !this.getNativeWebcamSourcePath()) {reasons.push("unsupported-webcam-source");