Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

Fix loop suggestions and webcam positioning

webadderall1b43459eabfc
diff --git a/src/components/video-editor/SettingsPanel.tsx b/src/components/video-editor/SettingsPanel.tsx
index 8b404ad9..a5dc4ff1 100644
--- a/src/components/video-editor/SettingsPanel.tsx
+++ b/src/components/video-editor/SettingsPanel.tsx
@@ -24,11 +24,16 @@ import type {
CropRegion,
FigureData,
PlaybackSpeed,
+ WebcamPositionPreset,
WebcamOverlaySettings,
ZoomDepth,
} from "./types";
import {
DEFAULT_WEBCAM_CORNER_RADIUS,
+ DEFAULT_WEBCAM_MARGIN,
+ DEFAULT_WEBCAM_POSITION_PRESET,
+ DEFAULT_WEBCAM_POSITION_X,
+ DEFAULT_WEBCAM_POSITION_Y,
DEFAULT_WEBCAM_REACT_TO_ZOOM,
DEFAULT_WEBCAM_SHADOW,
DEFAULT_WEBCAM_SIZE,
@@ -42,6 +47,7 @@ import {
DEFAULT_ZOOM_MOTION_BLUR,
SPEED_OPTIONS,
} from "./types";
+import { getWebcamPositionForPreset, resolveWebcamCorner } from "./webcamOverlay";
import { fromCursorSwaySliderValue, toCursorSwaySliderValue } from "./videoPlayback/cursorSway";
const GRADIENTS = [
@@ -169,6 +175,21 @@ const ZOOM_DEPTH_OPTIONS: Array<{ depth: ZoomDepth; label: string }> = [
{ depth: 6, label: "5×" },
];
+const WEBCAM_POSITION_PRESETS: Array<{
+ preset: Exclude<WebcamPositionPreset, "custom">;
+ label: string;
+}> = [
+ { preset: "top-left", label: "↖" },
+ { preset: "top-center", label: "↑" },
+ { preset: "top-right", label: "↗" },
+ { preset: "center-left", label: "←" },
+ { preset: "center", label: "•" },
+ { preset: "center-right", label: "→" },
+ { preset: "bottom-left", label: "↙" },
+ { preset: "bottom-center", label: "↓" },
+ { preset: "bottom-right", label: "↘" },
+];
+
export function SettingsPanel({
panelMode = "editor",
activeEffectSection: activeEffectSectionProp,
@@ -334,6 +355,9 @@ export function SettingsPanel({
const webcamFileName = webcam?.sourcePath?.split(/[\\/]/).pop() ?? null;
const visibleColorPalette = colorPalette.slice(0, 15);
+ const webcamPositionPreset = webcam?.positionPreset ?? DEFAULT_WEBCAM_POSITION_PRESET;
+ const webcamPositionX = webcam?.positionX ?? DEFAULT_WEBCAM_POSITION_X;
+ const webcamPositionY = webcam?.positionY ?? DEFAULT_WEBCAM_POSITION_Y;
const getWallpaperTileState = (candidateValue: string, previewPath?: string) => {
if (!selected) return false;
@@ -491,6 +515,23 @@ export function SettingsPanel({
onWebcamChange({ ...webcam, ...patch });
};
+ const applyWebcamPositionPreset = (preset: WebcamPositionPreset) => {
+ if (!webcam) return;
+
+ if (preset === "custom") {
+ updateWebcam({ positionPreset: "custom" });
+ return;
+ }
+
+ const position = getWebcamPositionForPreset(preset);
+ updateWebcam({
+ positionPreset: preset,
+ positionX: position.x,
+ positionY: position.y,
+ corner: resolveWebcamCorner(preset, webcam.corner),
+ });
+ };
+
const handleImageUpload = (event: React.ChangeEvent<HTMLInputElement>) => {
const files = event.target.files;
if (!files || files.length === 0) return;
@@ -919,6 +960,40 @@ export function SettingsPanel({
<div className="flex items-center justify-between rounded-lg bg-white/[0.03] px-2.5 py-1.5"><span className="text-[10px] text-slate-400">{tSettings("effects.show", "Show")}</span><Switch checked={webcam?.enabled ?? false} onCheckedChange={(enabled) => updateWebcam({ enabled })} className="data-[state=checked]:bg-[#2563EB] scale-75" /></div>
<div className="flex items-center justify-between rounded-lg bg-white/[0.03] px-2.5 py-1.5"><span className="text-[10px] text-slate-400">{tSettings("effects.webcamReactToZoom")}</span><Switch checked={webcam?.reactToZoom ?? DEFAULT_WEBCAM_REACT_TO_ZOOM} onCheckedChange={(reactToZoom) => updateWebcam({ reactToZoom })} className="data-[state=checked]:bg-[#2563EB] scale-75" /></div>
<SliderControl label={tSettings("effects.webcamSize")} value={webcam?.size ?? DEFAULT_WEBCAM_SIZE} defaultValue={DEFAULT_WEBCAM_SIZE} min={10} max={100} step={1} onChange={(v) => updateWebcam({ size: v })} formatValue={(v) => `${Math.round(v)}%`} parseInput={(text) => parseFloat(text.replace(/%$/, ""))} />
+ <div className="rounded-lg bg-white/[0.03] px-2.5 py-2">
+ <div className="mb-2 text-[10px] text-slate-400">{tSettings("effects.webcamPosition", "Position")}</div>
+ <div className="grid grid-cols-3 gap-1.5">
+ {WEBCAM_POSITION_PRESETS.map((option) => {
+ const isActive = webcamPositionPreset === option.preset;
+ return (
+ <Button
+ key={option.preset}
+ type="button"
+ onClick={() => applyWebcamPositionPreset(option.preset)}
+ className={cn(
+ "h-8 rounded-lg border px-0 text-sm font-semibold transition-all",
+ isActive
+ ? "border-[#2563EB] bg-[#2563EB] text-white"
+ : "border-white/10 bg-white/5 text-slate-300 hover:border-white/20 hover:bg-white/10",
+ )}
+ >
+ {option.label}
+ </Button>
+ );
+ })}
+ </div>
+ <div className="mt-2 flex items-center justify-between rounded-lg bg-black/10 px-2.5 py-1.5">
+ <span className="text-[10px] text-slate-400">{tSettings("effects.webcamCustomPosition", "Custom position")}</span>
+ <Switch checked={webcamPositionPreset === "custom"} onCheckedChange={(checked) => applyWebcamPositionPreset(checked ? "custom" : DEFAULT_WEBCAM_POSITION_PRESET)} className="data-[state=checked]:bg-[#2563EB] scale-75" />
+ </div>
+ </div>
+ {webcamPositionPreset === "custom" ? (
+ <>
+ <SliderControl label={tSettings("effects.webcamHorizontal", "Horizontal")} value={webcamPositionX * 100} defaultValue={DEFAULT_WEBCAM_POSITION_X * 100} min={0} max={100} step={1} onChange={(v) => updateWebcam({ positionPreset: "custom", positionX: v / 100 })} formatValue={(v) => `${Math.round(v)}%`} parseInput={(text) => parseFloat(text.replace(/%$/, ""))} />
+ <SliderControl label={tSettings("effects.webcamVertical", "Vertical")} value={webcamPositionY * 100} defaultValue={DEFAULT_WEBCAM_POSITION_Y * 100} min={0} max={100} step={1} onChange={(v) => updateWebcam({ positionPreset: "custom", positionY: v / 100 })} formatValue={(v) => `${Math.round(v)}%`} parseInput={(text) => parseFloat(text.replace(/%$/, ""))} />
+ </>
+ ) : null}
+ <SliderControl label={tSettings("effects.webcamMargin", "Margin")} value={webcam?.margin ?? DEFAULT_WEBCAM_MARGIN} defaultValue={DEFAULT_WEBCAM_MARGIN} min={0} max={96} step={1} onChange={(v) => updateWebcam({ margin: v })} formatValue={(v) => `${Math.round(v)}px`} parseInput={(text) => parseFloat(text.replace(/px$/, ""))} />
<SliderControl label={tSettings("effects.webcamRoundness")} value={webcam?.cornerRadius ?? DEFAULT_WEBCAM_CORNER_RADIUS} defaultValue={DEFAULT_WEBCAM_CORNER_RADIUS} min={0} max={80} step={1} onChange={(v) => updateWebcam({ cornerRadius: v })} formatValue={(v) => `${Math.round(v)}px`} parseInput={(text) => parseFloat(text.replace(/px$/, ""))} />
<SliderControl label={tSettings("effects.webcamShadow")} value={webcam?.shadow ?? DEFAULT_WEBCAM_SHADOW} defaultValue={DEFAULT_WEBCAM_SHADOW} min={0} max={1} step={0.01} onChange={(v) => updateWebcam({ shadow: v })} formatValue={(v) => `${Math.round(v * 100)}%`} parseInput={(text) => parseFloat(text.replace(/%$/, "")) / 100} />
<div className="rounded-lg bg-white/[0.03] px-2.5 py-2">
diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsx
index 0fd5b0cf..e043870a 100644
--- a/src/components/video-editor/VideoEditor.tsx
+++ b/src/components/video-editor/VideoEditor.tsx
@@ -804,10 +804,20 @@ export default function VideoEditor() {
.pop()
?.replace(/\.[^.]+$/, "") || `project-${Date.now()}`;
const projectSnapshot = JSON.stringify(projectData);
+ let targetProjectPath = forceSaveAs ? undefined : (currentProjectPath ?? undefined);
+
+ if (!forceSaveAs && !targetProjectPath) {
+ const activeProjectResult = await window.electronAPI.loadCurrentProjectFile();
+ if (activeProjectResult.success && activeProjectResult.path) {
+ targetProjectPath = activeProjectResult.path;
+ setCurrentProjectPath(activeProjectResult.path);
+ }
+ }
+
const result = await window.electronAPI.saveProjectFile(
projectData,
fileNameBase,
- forceSaveAs ? undefined : (currentProjectPath ?? undefined),
+ targetProjectPath,
);
if (result.canceled) {
@@ -1019,11 +1029,13 @@ export default function VideoEditor() {
}, [loopCursor, zoomRegions, displayedTimelineWindow, connectZooms]);
useEffect(() => {
+ const suggestionTelemetry = effectiveCursorTelemetry;
if (
!videoPath ||
duration <= 0 ||
+ loopCursor ||
zoomRegions.length > 0 ||
- normalizedCursorTelemetry.length < 2
+ suggestionTelemetry.length < 2
) {
return;
}
@@ -1037,7 +1049,7 @@ export default function VideoEditor() {
return;
}
- const candidates = detectInteractionCandidates(normalizedCursorTelemetry);
+ const candidates = detectInteractionCandidates(suggestionTelemetry);
if (candidates.length === 0) {
autoSuggestedVideoPathRef.current = videoPath;
return;
@@ -1094,7 +1106,7 @@ export default function VideoEditor() {
});
autoSuggestedVideoPathRef.current = videoPath;
- }, [videoPath, duration, normalizedCursorTelemetry, zoomRegions.length]);
+ }, [videoPath, duration, effectiveCursorTelemetry, loopCursor, zoomRegions.length]);
// Initialize default wallpaper with resolved asset path
useEffect(() => {
@@ -2491,6 +2503,7 @@ export default function VideoEditor() {
currentTime={currentTime}
onSeek={handleSeek}
cursorTelemetry={effectiveCursorTelemetry}
+ disableSuggestedZooms={loopCursor}
zoomRegions={effectiveZoomRegions}
onZoomAdded={handleZoomAdded}
onZoomSuggested={handleZoomSuggested}
diff --git a/src/components/video-editor/VideoPlayback.tsx b/src/components/video-editor/VideoPlayback.tsx
index af67c482..27849cba 100644
--- a/src/components/video-editor/VideoPlayback.tsx
+++ b/src/components/video-editor/VideoPlayback.tsx
@@ -71,7 +71,7 @@ import {
DEFAULT_CURSOR_SMOOTHING,
DEFAULT_CURSOR_SWAY,
} from "./types";
-import { getWebcamOverlaySizePx } from "./webcamOverlay";
+import { getWebcamOverlayPosition, getWebcamOverlaySizePx } from "./webcamOverlay";
type PlaybackAnimationState = {
scale: number;
@@ -284,12 +284,16 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
zoomScale,
reactToZoom: webcam.reactToZoom ?? true,
});
- const x = webcam.corner.endsWith("right")
- ? overlay.clientWidth - scaledSize - margin
- : margin;
- const y = webcam.corner.startsWith("bottom")
- ? overlay.clientHeight - scaledSize - margin
- : margin;
+ const { x, y } = getWebcamOverlayPosition({
+ containerWidth: overlay.clientWidth,
+ containerHeight: overlay.clientHeight,
+ size: scaledSize,
+ margin,
+ positionPreset: webcam.positionPreset ?? webcam.corner,
+ positionX: webcam.positionX ?? 1,
+ positionY: webcam.positionY ?? 1,
+ legacyCorner: webcam.corner,
+ });
bubble.style.display = "block";
bubble.style.left = `${x}px`;
diff --git a/src/components/video-editor/projectPersistence.ts b/src/components/video-editor/projectPersistence.ts
index 67723411..e28a5915 100644
--- a/src/components/video-editor/projectPersistence.ts
+++ b/src/components/video-editor/projectPersistence.ts
@@ -18,6 +18,9 @@ import {
DEFAULT_WEBCAM_CORNER_RADIUS,
DEFAULT_WEBCAM_MARGIN,
DEFAULT_WEBCAM_OVERLAY,
+ DEFAULT_WEBCAM_POSITION_PRESET,
+ DEFAULT_WEBCAM_POSITION_X,
+ DEFAULT_WEBCAM_POSITION_Y,
DEFAULT_WEBCAM_REACT_TO_ZOOM,
DEFAULT_WEBCAM_SHADOW,
DEFAULT_WEBCAM_SIZE,
@@ -409,6 +412,30 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): Pro
typeof webcam.enabled === "boolean" ? webcam.enabled : DEFAULT_WEBCAM_OVERLAY.enabled,
sourcePath: webcamSourcePath,
mirror: typeof webcam.mirror === "boolean" ? webcam.mirror : DEFAULT_WEBCAM_OVERLAY.mirror,
+ positionPreset:
+ webcam.positionPreset === "top-left" ||
+ webcam.positionPreset === "top-center" ||
+ webcam.positionPreset === "top-right" ||
+ webcam.positionPreset === "center-left" ||
+ webcam.positionPreset === "center" ||
+ webcam.positionPreset === "center-right" ||
+ webcam.positionPreset === "bottom-left" ||
+ webcam.positionPreset === "bottom-center" ||
+ webcam.positionPreset === "bottom-right" ||
+ webcam.positionPreset === "custom"
+ ? webcam.positionPreset
+ : webcam.corner === "top-left" ||
+ webcam.corner === "top-right" ||
+ webcam.corner === "bottom-left" ||
+ webcam.corner === "bottom-right"
+ ? webcam.corner
+ : DEFAULT_WEBCAM_POSITION_PRESET,
+ positionX: isFiniteNumber(webcam.positionX)
+ ? clamp(webcam.positionX, 0, 1)
+ : DEFAULT_WEBCAM_POSITION_X,
+ positionY: isFiniteNumber(webcam.positionY)
+ ? clamp(webcam.positionY, 0, 1)
+ : DEFAULT_WEBCAM_POSITION_Y,
corner:
webcam.corner === "top-left" ||
webcam.corner === "top-right" ||
diff --git a/src/components/video-editor/timeline/TimelineEditor.tsx b/src/components/video-editor/timeline/TimelineEditor.tsx
index 773ce257..8e9e00d0 100644
--- a/src/components/video-editor/timeline/TimelineEditor.tsx
+++ b/src/components/video-editor/timeline/TimelineEditor.tsx
@@ -41,6 +41,7 @@ interface TimelineEditorProps {
currentTime: number;
onSeek?: (time: number) => void;
cursorTelemetry?: CursorTelemetryPoint[];
+ disableSuggestedZooms?: boolean;
zoomRegions: ZoomRegion[];
onZoomAdded: (span: Span) => void;
onZoomSuggested?: (span: Span, focus: ZoomFocus) => void;
@@ -625,6 +626,7 @@ export default function TimelineEditor({
currentTime,
onSeek,
cursorTelemetry = [],
+ disableSuggestedZooms = false,
zoomRegions,
onZoomAdded,
onZoomSuggested,
@@ -937,6 +939,11 @@ export default function TimelineEditor({
return;
}
+ if (disableSuggestedZooms) {
+ toast.info("Suggested zooms are unavailable while cursor looping is enabled.");
+ return;
+ }
+
if (!onZoomSuggested) {
toast.error("Zoom suggestion handler unavailable");
return;
@@ -1015,7 +1022,15 @@ export default function TimelineEditor({
}
toast.success(`Added ${addedCount} interaction-based zoom suggestion${addedCount === 1 ? "" : "s"}`);
- }, [videoDuration, totalMs, defaultRegionDurationMs, zoomRegions, onZoomSuggested, cursorTelemetry]);
+ }, [
+ videoDuration,
+ totalMs,
+ defaultRegionDurationMs,
+ zoomRegions,
+ disableSuggestedZooms,
+ onZoomSuggested,
+ cursorTelemetry,
+ ]);
const handleAddTrim = useCallback(() => {
if (!videoDuration || videoDuration === 0 || totalMs === 0 || !onTrimAdded) {
diff --git a/src/components/video-editor/types.ts b/src/components/video-editor/types.ts
index 7aeada4a..626109fd 100644
--- a/src/components/video-editor/types.ts
+++ b/src/components/video-editor/types.ts
@@ -46,12 +46,23 @@ export interface CursorVisualSettings {
}
export type WebcamCorner = "top-left" | "top-right" | "bottom-left" | "bottom-right";
+export type WebcamPositionPreset =
+ | WebcamCorner
+ | "top-center"
+ | "center-left"
+ | "center"
+ | "center-right"
+ | "bottom-center"
+ | "custom";
export interface WebcamOverlaySettings {
enabled: boolean;
sourcePath: string | null;
mirror: boolean;
corner: WebcamCorner;
+ positionPreset: WebcamPositionPreset;
+ positionX: number;
+ positionY: number;
size: number;
reactToZoom: boolean;
cornerRadius: number;
@@ -71,12 +82,18 @@ export const DEFAULT_WEBCAM_REACT_TO_ZOOM = true;
export const DEFAULT_WEBCAM_CORNER_RADIUS = 18;
export const DEFAULT_WEBCAM_SHADOW = 0.35;
export const DEFAULT_WEBCAM_MARGIN = 24;
+export const DEFAULT_WEBCAM_POSITION_PRESET: WebcamPositionPreset = "bottom-right";
+export const DEFAULT_WEBCAM_POSITION_X = 1;
+export const DEFAULT_WEBCAM_POSITION_Y = 1;
export const DEFAULT_WEBCAM_OVERLAY: WebcamOverlaySettings = {
enabled: false,
sourcePath: null,
mirror: true,
corner: "bottom-right",
+ positionPreset: DEFAULT_WEBCAM_POSITION_PRESET,
+ positionX: DEFAULT_WEBCAM_POSITION_X,
+ positionY: DEFAULT_WEBCAM_POSITION_Y,
size: DEFAULT_WEBCAM_SIZE,
reactToZoom: DEFAULT_WEBCAM_REACT_TO_ZOOM,
cornerRadius: DEFAULT_WEBCAM_CORNER_RADIUS,
diff --git a/src/components/video-editor/webcamOverlay.ts b/src/components/video-editor/webcamOverlay.ts
index 4e859d6b..8d316837 100644
--- a/src/components/video-editor/webcamOverlay.ts
+++ b/src/components/video-editor/webcamOverlay.ts
@@ -1,9 +1,55 @@
+import type { WebcamCorner, WebcamPositionPreset } from "./types";
+
const MIN_WEBCAM_OVERLAY_SIZE_PX = 56;
function clamp(value: number, min: number, max: number) {
return Math.min(max, Math.max(min, value));
}
+export function getWebcamPositionForPreset(
+ preset: WebcamPositionPreset,
+): { x: number; y: number } {
+ switch (preset) {
+ case "top-left":
+ return { x: 0, y: 0 };
+ case "top-center":
+ return { x: 0.5, y: 0 };
+ case "top-right":
+ return { x: 1, y: 0 };
+ case "center-left":
+ return { x: 0, y: 0.5 };
+ case "center":
+ return { x: 0.5, y: 0.5 };
+ case "center-right":
+ return { x: 1, y: 0.5 };
+ case "bottom-left":
+ return { x: 0, y: 1 };
+ case "bottom-center":
+ return { x: 0.5, y: 1 };
+ case "custom":
+ return { x: 1, y: 1 };
+ case "bottom-right":
+ default:
+ return { x: 1, y: 1 };
+ }
+}
+
+function isCornerPreset(preset: WebcamPositionPreset): preset is WebcamCorner {
+ return (
+ preset === "top-left" ||
+ preset === "top-right" ||
+ preset === "bottom-left" ||
+ preset === "bottom-right"
+ );
+}
+
+export function resolveWebcamCorner(
+ preset: WebcamPositionPreset,
+ legacyCorner: WebcamCorner,
+): WebcamCorner {
+ return isCornerPreset(preset) ? preset : legacyCorner;
+}
+
export function getWebcamOverlayScale(
zoomScale: number,
reactToZoom: boolean,
@@ -37,4 +83,37 @@ export function getWebcamOverlaySizePx({
* getWebcamOverlayScale(zoomScale, reactToZoom);
return Math.min(maxSize, Math.max(MIN_WEBCAM_OVERLAY_SIZE_PX, scaledSize));
-}
\ No newline at end of file
+}
+
+export function getWebcamOverlayPosition({
+ containerWidth,
+ containerHeight,
+ size,
+ margin,
+ positionPreset,
+ positionX,
+ positionY,
+ legacyCorner,
+}: {
+ containerWidth: number;
+ containerHeight: number;
+ size: number;
+ margin: number;
+ positionPreset: WebcamPositionPreset;
+ positionX: number;
+ positionY: number;
+ legacyCorner: WebcamCorner;
+}): { x: number; y: number } {
+ const safeMargin = Math.max(0, margin);
+ const availableWidth = Math.max(0, containerWidth - size - safeMargin * 2);
+ const availableHeight = Math.max(0, containerHeight - size - safeMargin * 2);
+ const presetPosition =
+ positionPreset === "custom"
+ ? { x: clamp(positionX, 0, 1), y: clamp(positionY, 0, 1) }
+ : getWebcamPositionForPreset(positionPreset || legacyCorner);
+
+ return {
+ x: safeMargin + availableWidth * presetPosition.x,
+ y: safeMargin + availableHeight * presetPosition.y,
+ };
+}
diff --git a/src/lib/exporter/frameRenderer.ts b/src/lib/exporter/frameRenderer.ts
index 7305c457..ef730f34 100644
--- a/src/lib/exporter/frameRenderer.ts
+++ b/src/lib/exporter/frameRenderer.ts
@@ -37,7 +37,7 @@ import {
preloadCursorAssets,
} from "@/components/video-editor/videoPlayback/cursorRenderer";
import { clampMediaTimeToDuration } from "@/lib/mediaTiming";
-import { getWebcamOverlaySizePx } from "@/components/video-editor/webcamOverlay";
+import { getWebcamOverlayPosition, getWebcamOverlaySizePx } from "@/components/video-editor/webcamOverlay";
import { ForwardFrameSource } from "./forwardFrameSource";
import { resolveMediaElementSource } from "./localMediaSource";
@@ -1079,8 +1079,16 @@ export class FrameRenderer {
zoomScale: this.animationState.appliedScale || 1,
reactToZoom: webcam.reactToZoom ?? true,
});
- const x = webcam.corner.endsWith("right") ? width - size - margin : margin;
- const y = webcam.corner.startsWith("bottom") ? height - size - margin : margin;
+ const { x, y } = getWebcamOverlayPosition({
+ containerWidth: width,
+ containerHeight: height,
+ size,
+ margin,
+ positionPreset: webcam.positionPreset ?? webcam.corner,
+ positionX: webcam.positionX ?? 1,
+ positionY: webcam.positionY ?? 1,
+ legacyCorner: webcam.corner,
+ });
const radius = Math.max(0, webcam.cornerRadius ?? 18);
const bubbleCanvas = this.webcamBubbleCanvas ?? document.createElement("canvas");