Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
reactive zoom
Siddhartha806e34ff09a
diff --git a/src/components/video-editor/SettingsPanel.tsx b/src/components/video-editor/SettingsPanel.tsxindex 8cb143a54..09ceb49f6 100644--- a/src/components/video-editor/SettingsPanel.tsx+++ b/src/components/video-editor/SettingsPanel.tsx@@ -88,6 +88,7 @@ import type {} from "./types";import {DEFAULT_WEBCAM_MIRRORED,+ DEFAULT_WEBCAM_REACTIVE_ZOOM,MAX_ZOOM_SCALE,MIN_ZOOM_SCALE,ROTATION_3D_PRESET_ORDER,@@ -327,6 +328,8 @@ interface SettingsPanelProps {onWebcamMaskShapeChange?: (shape: import("./types").WebcamMaskShape) => void;webcamMirrored?: boolean;onWebcamMirroredChange?: (mirrored: boolean) => void;+ webcamReactiveZoom?: boolean;+ onWebcamReactiveZoomChange?: (reactive: boolean) => void;webcamSizePreset?: WebcamSizePreset;onWebcamSizePresetChange?: (size: WebcamSizePreset) => void;onWebcamSizePresetCommit?: () => void;@@ -461,6 +464,8 @@ export function SettingsPanel({onWebcamMaskShapeChange,webcamMirrored = DEFAULT_WEBCAM_MIRRORED,onWebcamMirroredChange,+ webcamReactiveZoom = DEFAULT_WEBCAM_REACTIVE_ZOOM,+ onWebcamReactiveZoomChange,webcamSizePreset = DEFAULT_WEBCAM_SETTINGS.sizePreset,onWebcamSizePresetChange,onWebcamSizePresetCommit,@@ -1295,6 +1300,31 @@ export function SettingsPanel({/></div>)}+ {webcamLayoutPreset === "picture-in-picture" && (+ <div className="mt-2 flex items-center justify-between p-2 rounded-lg editor-control-surface">+ <div className="flex items-center gap-1 text-[10px] font-medium text-slate-300">+ <span>{t("layout.reactiveWebcam")}</span>+ <Tooltip+ content={t("layout.reactiveWebcamDescription")}+ className="max-w-[220px] leading-snug whitespace-normal"+ >+ <button+ type="button"+ className="text-slate-400 transition-colors hover:text-slate-200"+ aria-label={t("layout.reactiveWebcamDescription")}+ >+ <Info size={11} />+ </button>+ </Tooltip>+ </div>+ <Switch+ checked={webcamReactiveZoom}+ onCheckedChange={onWebcamReactiveZoomChange}+ className="data-[state=checked]:bg-[#34B27B] scale-90"+ aria-label={t("layout.reactiveWebcam")}+ />+ </div>+ )}{webcamLayoutPreset === "picture-in-picture" && (<div className="mt-2 p-2 rounded-lg editor-control-surface"><div className="text-[10px] font-medium text-slate-300 mb-1.5">diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsxindex 2b8664bd6..91a9fa5bb 100644--- a/src/components/video-editor/VideoEditor.tsx+++ b/src/components/video-editor/VideoEditor.tsx@@ -206,6 +206,7 @@ export default function VideoEditor() {webcamLayoutPreset,webcamMaskShape,webcamMirrored,+ webcamReactiveZoom,webcamSizePreset,webcamPosition,} = editorState;@@ -416,6 +417,7 @@ export default function VideoEditor() {webcamLayoutPreset: normalizedEditor.webcamLayoutPreset,webcamMaskShape: normalizedEditor.webcamMaskShape,webcamMirrored: normalizedEditor.webcamMirrored,+ webcamReactiveZoom: normalizedEditor.webcamReactiveZoom,webcamSizePreset: normalizedEditor.webcamSizePreset,webcamPosition: normalizedEditor.webcamPosition,});@@ -492,6 +494,7 @@ export default function VideoEditor() {webcamLayoutPreset,webcamMaskShape,webcamMirrored,+ webcamReactiveZoom,webcamSizePreset,webcamPosition,exportQuality,@@ -522,6 +525,7 @@ export default function VideoEditor() {webcamLayoutPreset,webcamMaskShape,webcamMirrored,+ webcamReactiveZoom,webcamSizePreset,webcamPosition,exportQuality,@@ -650,6 +654,7 @@ export default function VideoEditor() {webcamLayoutPreset,webcamMaskShape,webcamMirrored,+ webcamReactiveZoom,webcamSizePreset,webcamPosition,exportQuality,@@ -714,6 +719,7 @@ export default function VideoEditor() {webcamLayoutPreset,webcamMaskShape,webcamMirrored,+ webcamReactiveZoom,webcamSizePreset,webcamPosition,exportQuality,@@ -1911,6 +1917,7 @@ export default function VideoEditor() {webcamLayoutPreset,webcamMaskShape,webcamMirrored,+ webcamReactiveZoom,webcamSizePreset,webcamPosition,previewWidth,@@ -2004,6 +2011,7 @@ export default function VideoEditor() {webcamLayoutPreset,webcamMaskShape,webcamMirrored,+ webcamReactiveZoom,webcamSizePreset,webcamPosition,previewWidth,@@ -2106,6 +2114,7 @@ export default function VideoEditor() {webcamLayoutPreset,webcamMaskShape,webcamMirrored,+ webcamReactiveZoom,webcamSizePreset,webcamPosition,exportQuality,@@ -2592,6 +2601,7 @@ export default function VideoEditor() {webcamLayoutPreset={webcamLayoutPreset}webcamMaskShape={webcamMaskShape}webcamMirrored={webcamMirrored}+ webcamReactiveZoom={webcamReactiveZoom}webcamSizePreset={webcamSizePreset}webcamPosition={webcamPosition}onWebcamPositionChange={(pos) => updateState({ webcamPosition: pos })}@@ -2738,7 +2748,11 @@ export default function VideoEditor() {webcamMaskShape={webcamMaskShape}onWebcamMaskShapeChange={(shape) => pushState({ webcamMaskShape: shape })}webcamMirrored={webcamMirrored}+ webcamReactiveZoom={webcamReactiveZoom}onWebcamMirroredChange={(mirrored) => pushState({ webcamMirrored: mirrored })}+ onWebcamReactiveZoomChange={(reactive) =>+ pushState({ webcamReactiveZoom: reactive })+ }webcamSizePreset={webcamSizePreset}onWebcamSizePresetChange={(v) => updateState({ webcamSizePreset: v })}onWebcamSizePresetCommit={commitState}diff --git a/src/components/video-editor/VideoPlayback.tsx b/src/components/video-editor/VideoPlayback.tsxindex 0a3aa651f..22a11ec23 100644--- a/src/components/video-editor/VideoPlayback.tsx+++ b/src/components/video-editor/VideoPlayback.tsx@@ -20,6 +20,7 @@ import {} from "react";import {getWebcamLayoutCssBoxShadow,+ reactiveWebcamScale,type Size,type StyledRenderRect,type WebcamLayoutPreset,@@ -104,6 +105,7 @@ interface VideoPlaybackProps {webcamLayoutPreset: WebcamLayoutPreset;webcamMaskShape?: import("./types").WebcamMaskShape;webcamMirrored?: boolean;+ webcamReactiveZoom?: boolean;webcamSizePreset?: WebcamSizePreset;webcamPosition?: { cx: number; cy: number } | null;onWebcamPositionChange?: (position: { cx: number; cy: number }) => void;@@ -230,6 +232,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(webcamLayoutPreset,webcamMaskShape,webcamMirrored = false,+ webcamReactiveZoom = false,webcamSizePreset,webcamPosition,onWebcamPositionChange,@@ -285,6 +288,10 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(const videoRef = useRef<HTMLVideoElement | null>(null);const supplementalAudioRef = useRef<HTMLAudioElement | null>(null);const webcamVideoRef = useRef<HTMLVideoElement | null>(null);+ const webcamWrapperRef = useRef<HTMLDivElement | null>(null);+ const webcamReactiveZoomRef = useRef(webcamReactiveZoom);+ const webcamLayoutPresetRef = useRef(webcamLayoutPreset);+ const webcamPositionRef = useRef(webcamPosition);const containerRef = useRef<HTMLDivElement | null>(null);const appRef = useRef<Application | null>(null);const videoSpriteRef = useRef<Sprite | null>(null);@@ -858,6 +865,20 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(cursorThemeRef.current = cursorTheme;}, [cursorTheme]);+ useEffect(() => {+ webcamReactiveZoomRef.current = webcamReactiveZoom;+ webcamLayoutPresetRef.current = webcamLayoutPreset;+ webcamPositionRef.current = webcamPosition;+ // Clear any reactive transform the moment the effect is turned off or layout changes,+ // so a stale shrink doesn't linger when the ticker isn't actively updating it.+ if (+ webcamWrapperRef.current &&+ (!webcamReactiveZoom || webcamLayoutPreset !== "picture-in-picture")+ ) {+ webcamWrapperRef.current.style.transform = "";+ }+ }, [webcamReactiveZoom, webcamLayoutPreset, webcamPosition]);+useEffect(() => {isPreviewingZoomRef.current = isPreviewingZoom;}, [isPreviewingZoom]);@@ -1316,6 +1337,25 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(state.x = appliedTransform.x;state.y = appliedTransform.y;state.appliedScale = appliedTransform.scale;++ // Reactive camera sizing: scale the PiP webcam inversely with the (already eased) zoom.+ // Anchor the shrink to the corner the camera is docked in (bottom-right by default)+ // so it stays flush against the edges instead of drifting toward center.+ const webcamWrapper = webcamWrapperRef.current;+ if (webcamWrapper) {+ const reactive =+ webcamReactiveZoomRef.current && webcamLayoutPresetRef.current === "picture-in-picture";+ const factor = reactive ? reactiveWebcamScale(state.appliedScale) : 1;+ if (factor < 1) {+ const pos = webcamPositionRef.current;+ const originX = (pos ? pos.cx >= 0.5 : true) ? "100%" : "0%";+ const originY = (pos ? pos.cy >= 0.5 : true) ? "100%" : "0%";+ webcamWrapper.style.transformOrigin = `${originX} ${originY}`;+ webcamWrapper.style.transform = `scale(${factor})`;+ } else {+ webcamWrapper.style.transform = "";+ }+ }};let lastMotionBlurActive: boolean | null = null;@@ -1900,6 +1940,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(const useClipPath = !!clipPath;return (<div+ ref={webcamWrapperRef}className="absolute"style={{left: webcamLayout?.x ?? 0,diff --git a/src/components/video-editor/projectPersistence.ts b/src/components/video-editor/projectPersistence.tsindex 27bc05b64..22899be51 100644--- a/src/components/video-editor/projectPersistence.ts+++ b/src/components/video-editor/projectPersistence.ts@@ -27,6 +27,7 @@ import {DEFAULT_FIGURE_DATA,DEFAULT_PLAYBACK_SPEED,DEFAULT_WEBCAM_MIRRORED,+ DEFAULT_WEBCAM_REACTIVE_ZOOM,DEFAULT_ZOOM_DEPTH,DEFAULT_ZOOM_MOTION_BLUR,MAX_BLUR_BLOCK_SIZE,@@ -83,6 +84,7 @@ export interface ProjectEditorState {webcamLayoutPreset: WebcamLayoutPreset;webcamMaskShape: WebcamMaskShape;webcamMirrored: boolean;+ webcamReactiveZoom: boolean;webcamSizePreset: WebcamSizePreset;webcamPosition: WebcamPosition | null;exportQuality: ExportQuality;@@ -501,6 +503,10 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): Pro: DEFAULT_WEBCAM_SETTINGS.maskShape,webcamMirrored:typeof editor.webcamMirrored === "boolean" ? editor.webcamMirrored : DEFAULT_WEBCAM_MIRRORED,+ webcamReactiveZoom:+ typeof editor.webcamReactiveZoom === "boolean"+ ? editor.webcamReactiveZoom+ : DEFAULT_WEBCAM_REACTIVE_ZOOM,webcamSizePreset:typeof editor.webcamSizePreset === "number" && isFiniteNumber(editor.webcamSizePreset)? Math.max(10, Math.min(50, editor.webcamSizePreset))diff --git a/src/components/video-editor/types.ts b/src/components/video-editor/types.tsindex 364ff1937..e2d3d46ae 100644--- a/src/components/video-editor/types.ts+++ b/src/components/video-editor/types.ts@@ -16,6 +16,9 @@ export const DEFAULT_WEBCAM_MASK_SHAPE: WebcamMaskShape = "rectangle";export const DEFAULT_WEBCAM_MIRRORED = false;+/** When true, the picture-in-picture webcam scales inversely with zoom (shrinks as you zoom in). */+export const DEFAULT_WEBCAM_REACTIVE_ZOOM = true;+export interface WebcamPosition {cx: number; // normalized horizontal center (0-1)cy: number; // normalized vertical center (0-1)diff --git a/src/hooks/useEditorHistory.ts b/src/hooks/useEditorHistory.tsindex 1435cc2ae..0b27ee067 100644--- a/src/hooks/useEditorHistory.ts+++ b/src/hooks/useEditorHistory.ts@@ -15,7 +15,11 @@ import type {WebcamSizePreset,ZoomRegion,} from "@/components/video-editor/types";-import { DEFAULT_CROP_REGION, DEFAULT_WEBCAM_MIRRORED } from "@/components/video-editor/types";+import {+ DEFAULT_CROP_REGION,+ DEFAULT_WEBCAM_MIRRORED,+ DEFAULT_WEBCAM_REACTIVE_ZOOM,+} from "@/components/video-editor/types";import type { AspectRatio } from "@/utils/aspectRatioUtils";// Undoable state — selection IDs are intentionally excluded (undoing a@@ -42,6 +46,7 @@ export interface EditorState {webcamLayoutPreset: WebcamLayoutPreset;webcamMaskShape: WebcamMaskShape;webcamMirrored: boolean;+ webcamReactiveZoom: boolean;webcamSizePreset: WebcamSizePreset;webcamPosition: WebcamPosition | null;}@@ -65,6 +70,7 @@ export const INITIAL_EDITOR_STATE: EditorState = {webcamLayoutPreset: DEFAULT_WEBCAM_SETTINGS.layoutPreset,webcamMaskShape: DEFAULT_WEBCAM_SETTINGS.maskShape,webcamMirrored: DEFAULT_WEBCAM_MIRRORED,+ webcamReactiveZoom: DEFAULT_WEBCAM_REACTIVE_ZOOM,webcamSizePreset: DEFAULT_WEBCAM_SETTINGS.sizePreset,webcamPosition: DEFAULT_WEBCAM_SETTINGS.position,};diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.jsonindex a5c3183cc..c91928890 100644--- a/src/i18n/locales/ar/settings.json+++ b/src/i18n/locales/ar/settings.json@@ -46,7 +46,9 @@"webcamShape": "شكل الكاميرا","webcamSize": "حجم كاميرا الويب","noWebcam": "بدون كاميرا",- "mirrorWebcam": "عكس كاميرا الويب"+ "mirrorWebcam": "عكس كاميرا الويب",+ "reactiveWebcam": "تصغير عند التكبير",+ "reactiveWebcamDescription": "تتقلص الكاميرا بسلاسة أثناء تكبير الفيديو حتى لا تعيق الرؤية."},"effects": {"title": "تأثيرات الفيديو",diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.jsonindex d6c7f4a04..3594ac51e 100644--- a/src/i18n/locales/en/settings.json+++ b/src/i18n/locales/en/settings.json@@ -47,7 +47,9 @@"noWebcam": "No Webcam","webcamShape": "Camera Shape","webcamSize": "Webcam Size",- "mirrorWebcam": "Mirror Webcam"+ "mirrorWebcam": "Mirror Webcam",+ "reactiveWebcam": "Shrink on Zoom",+ "reactiveWebcamDescription": "Camera smoothly shrinks while the video is zoomed in, so it stays out of the way."},"effects": {"title": "Video Effects",diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.jsonindex 5876908fc..fa046e794 100644--- a/src/i18n/locales/es/settings.json+++ b/src/i18n/locales/es/settings.json@@ -46,7 +46,9 @@"webcamShape": "Forma de cámara","webcamSize": "Tamaño de cámara","noWebcam": "Sin cámara",- "mirrorWebcam": "Reflejar cámara"+ "mirrorWebcam": "Reflejar cámara",+ "reactiveWebcam": "Reducir al ampliar",+ "reactiveWebcamDescription": "La cámara se reduce suavemente mientras el vídeo está ampliado, para no estorbar."},"effects": {"title": "Efectos de video",diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.jsonindex 429eb1c21..06d51e2da 100644--- a/src/i18n/locales/fr/settings.json+++ b/src/i18n/locales/fr/settings.json@@ -46,7 +46,9 @@"webcamShape": "Forme de la caméra","webcamSize": "Taille de la caméra","noWebcam": "Sans webcam",- "mirrorWebcam": "Inverser la webcam"+ "mirrorWebcam": "Inverser la webcam",+ "reactiveWebcam": "Réduire au zoom",+ "reactiveWebcamDescription": "La caméra rétrécit doucement pendant le zoom, pour ne pas gêner."},"effects": {"title": "Effets vidéo",diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.jsonindex 5f986e0eb..9345f95ee 100644--- a/src/i18n/locales/it/settings.json+++ b/src/i18n/locales/it/settings.json@@ -46,7 +46,9 @@"noWebcam": "Nessuna webcam","webcamShape": "Forma fotocamera","webcamSize": "Dimensione webcam",- "mirrorWebcam": "Specchia webcam"+ "mirrorWebcam": "Specchia webcam",+ "reactiveWebcam": "Riduci con lo zoom",+ "reactiveWebcamDescription": "La webcam si riduce dolcemente durante lo zoom, così non intralcia."},"effects": {"title": "Effetti video",diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.jsonindex 3b7bb972a..2950deb03 100644--- a/src/i18n/locales/ja-JP/settings.json+++ b/src/i18n/locales/ja-JP/settings.json@@ -46,7 +46,9 @@"webcamShape": "カメラの形状","webcamSize": "カメラのサイズ","noWebcam": "Webカメラなし",- "mirrorWebcam": "Webカメラを反転"+ "mirrorWebcam": "Webカメラを反転",+ "reactiveWebcam": "ズーム時に縮小",+ "reactiveWebcamDescription": "ズーム中はカメラがスムーズに縮小し、邪魔になりません。"},"effects": {"title": "動画効果",diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.jsonindex 7d4c62b7e..d593014ed 100644--- a/src/i18n/locales/ko-KR/settings.json+++ b/src/i18n/locales/ko-KR/settings.json@@ -46,7 +46,9 @@"webcamSize": "웹캠 크기","dualFrame": "듀얼 프레임","noWebcam": "웹캠 없음",- "mirrorWebcam": "웹캠 미러링"+ "mirrorWebcam": "웹캠 미러링",+ "reactiveWebcam": "확대 시 축소",+ "reactiveWebcamDescription": "확대하는 동안 카메라가 부드럽게 작아져 방해되지 않습니다."},"effects": {"title": "비디오 효과",diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.jsonindex 5b25420fb..357db548a 100644--- a/src/i18n/locales/pt-BR/settings.json+++ b/src/i18n/locales/pt-BR/settings.json@@ -44,7 +44,9 @@"dualFrame": "Quadro Duplo","noWebcam": "Sem Webcam","webcamShape": "Formato da Câmera",- "webcamSize": "Tamanho da Webcam"+ "webcamSize": "Tamanho da Webcam",+ "reactiveWebcam": "Encolher ao ampliar",+ "reactiveWebcamDescription": "A câmera diminui suavemente enquanto o vídeo está ampliado, para não atrapalhar."},"effects": {"title": "Efeitos de Vídeo",diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.jsonindex 585b28e0a..17205a099 100644--- a/src/i18n/locales/ru/settings.json+++ b/src/i18n/locales/ru/settings.json@@ -46,7 +46,9 @@"webcamShape": "Форма камеры","webcamSize": "Размер веб-камеры","noWebcam": "Без веб-камеры",- "mirrorWebcam": "Зеркалить веб-камеру"+ "mirrorWebcam": "Зеркалить веб-камеру",+ "reactiveWebcam": "Уменьшать при зуме",+ "reactiveWebcamDescription": "Камера плавно уменьшается во время приближения, чтобы не мешать."},"effects": {"title": "Видеоэффекты",diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.jsonindex 555829967..209cddd09 100644--- a/src/i18n/locales/tr/settings.json+++ b/src/i18n/locales/tr/settings.json@@ -46,7 +46,9 @@"dualFrame": "Çift Kare","webcamSize": "Webcam Boyutu","noWebcam": "Web kamerası yok",- "mirrorWebcam": "Web kamerasını aynala"+ "mirrorWebcam": "Web kamerasını aynala",+ "reactiveWebcam": "Yakınlaştırınca küçült",+ "reactiveWebcamDescription": "Video yakınlaştırıldığında kamera yumuşakça küçülür, böylece yoldan çekilir."},"effects": {"title": "Video Efektleri",diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.jsonindex 281d38cfd..f86e4851c 100644--- a/src/i18n/locales/vi/settings.json+++ b/src/i18n/locales/vi/settings.json@@ -46,7 +46,9 @@"webcamShape": "Hình dạng máy ảnh","webcamSize": "Kích thước Webcam","noWebcam": "Không có webcam",- "mirrorWebcam": "Lật webcam"+ "mirrorWebcam": "Lật webcam",+ "reactiveWebcam": "Thu nhỏ khi phóng to",+ "reactiveWebcamDescription": "Camera thu nhỏ mượt mà khi video được phóng to, để không che khuất."},"effects": {"title": "Hiệu ứng video",diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.jsonindex 0f1601903..dab854077 100644--- a/src/i18n/locales/zh-CN/settings.json+++ b/src/i18n/locales/zh-CN/settings.json@@ -46,7 +46,9 @@"webcamShape": "摄像头形状","webcamSize": "摄像头大小","noWebcam": "无摄像头",- "mirrorWebcam": "镜像摄像头"+ "mirrorWebcam": "镜像摄像头",+ "reactiveWebcam": "缩放时缩小",+ "reactiveWebcamDescription": "放大视频时摄像头会平滑缩小,以免遮挡内容。"},"effects": {"title": "视频效果",diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.jsonindex 618f11742..b5fbcda8c 100644--- a/src/i18n/locales/zh-TW/settings.json+++ b/src/i18n/locales/zh-TW/settings.json@@ -47,7 +47,9 @@"webcamShape": "攝影機形狀","webcamSize": "攝影機大小","noWebcam": "無網路攝影機",- "mirrorWebcam": "鏡像攝影機"+ "mirrorWebcam": "鏡像攝影機",+ "reactiveWebcam": "縮放時縮小",+ "reactiveWebcamDescription": "放大影片時鏡頭會平滑縮小,以免遮擋內容。"},"effects": {"title": "影片效果",diff --git a/src/lib/compositeLayout.ts b/src/lib/compositeLayout.tsindex abb6b0f7b..a0ee58d89 100644--- a/src/lib/compositeLayout.ts+++ b/src/lib/compositeLayout.ts@@ -5,6 +5,21 @@ export interface RenderRect {height: number;}+/** Floor for the reactive webcam multiplier so the camera never shrinks below ~35% at deep zoom. */+export const WEBCAM_REACTIVE_ZOOM_MIN_SCALE = 0.35;++/**+ * Maps the live (spring-animated) zoom scale to a webcam size multiplier. The camera scales+ * inversely to the zoom — at 2× zoom it's half size, at 3× a third — so it stays out of the way+ * as you zoom into content, then returns to full size as the zoom eases back. Clamped to a floor+ * so it never disappears. Because `appliedScale` is already eased every frame, the camera animates+ * in sync with the zoom for free.+ */+export function reactiveWebcamScale(zoomScale: number): number {+ const safe = Number.isFinite(zoomScale) && zoomScale > 0 ? zoomScale : 1;+ return Math.max(WEBCAM_REACTIVE_ZOOM_MIN_SCALE, Math.min(1, 1 / safe));+}+export interface StyledRenderRect extends RenderRect {borderRadius: number;maskShape?: import("@/components/video-editor/types").WebcamMaskShape;diff --git a/src/lib/exporter/frameRenderer.ts b/src/lib/exporter/frameRenderer.tsindex 95943fde4..5379890bc 100644--- a/src/lib/exporter/frameRenderer.ts+++ b/src/lib/exporter/frameRenderer.ts@@ -47,6 +47,7 @@ import {import {computeCompositeLayout,getWebcamLayoutPresetDefinition,+ reactiveWebcamScale,type Size,type StyledRenderRect,} from "@/lib/compositeLayout";@@ -101,6 +102,7 @@ interface FrameRenderConfig {webcamLayoutPreset?: WebcamLayoutPreset;webcamMaskShape?: import("@/components/video-editor/types").WebcamMaskShape;webcamMirrored?: boolean;+ webcamReactiveZoom?: boolean;webcamSizePreset?: WebcamSizePreset;webcamPosition?: { cx: number; cy: number } | null;annotationRegions?: AnnotationRegion[];@@ -1042,6 +1044,26 @@ export class FrameRenderer {if (webcamFrame && webcamRect) {const preset = getWebcamLayoutPresetDefinition(this.config.webcamLayoutPreset);const shape = webcamRect.maskShape ?? this.config.webcamMaskShape ?? "rectangle";+ // Reactive camera sizing: scale the PiP webcam inversely with the eased zoom. Anchor the+ // shrink to the corner the camera is docked in (bottom-right by default), matching the+ // preview, so it stays flush against the edges instead of drifting toward center.+ const reactiveFactor =+ this.config.webcamReactiveZoom && this.config.webcamLayoutPreset === "picture-in-picture"+ ? reactiveWebcamScale(this.animationState.appliedScale)+ : 1;+ const camPos = this.config.webcamPosition;+ const biasX = (camPos ? camPos.cx >= 0.5 : true) ? 1 : 0;+ const biasY = (camPos ? camPos.cy >= 0.5 : true) ? 1 : 0;+ const drawRect =+ reactiveFactor < 1+ ? {+ width: webcamRect.width * reactiveFactor,+ height: webcamRect.height * reactiveFactor,+ x: webcamRect.x + webcamRect.width * (1 - reactiveFactor) * biasX,+ y: webcamRect.y + webcamRect.height * (1 - reactiveFactor) * biasY,+ borderRadius: webcamRect.borderRadius * reactiveFactor,+ }+ : webcamRect;const sourceWidth =("displayWidth" in webcamFrame && webcamFrame.displayWidth > 0? webcamFrame.displayWidth@@ -1061,12 +1083,12 @@ export class FrameRenderer {fgCtx.save();drawCanvasClipPath(fgCtx,- webcamRect.x,- webcamRect.y,- webcamRect.width,- webcamRect.height,+ drawRect.x,+ drawRect.y,+ drawRect.width,+ drawRect.height,shape,- webcamRect.borderRadius,+ drawRect.borderRadius,);if (preset.shadow) {fgCtx.shadowColor = preset.shadow.color;@@ -1087,10 +1109,10 @@ export class FrameRenderer {height: sourceCropHeight,},{- x: webcamRect.x,- y: webcamRect.y,- width: webcamRect.width,- height: webcamRect.height,+ x: drawRect.x,+ y: drawRect.y,+ width: drawRect.width,+ height: drawRect.height,},this.config.webcamMirrored,);diff --git a/src/lib/exporter/gifExporter.ts b/src/lib/exporter/gifExporter.tsindex 649511b66..43a7e4688 100644--- a/src/lib/exporter/gifExporter.ts+++ b/src/lib/exporter/gifExporter.ts@@ -47,6 +47,7 @@ interface GifExporterConfig {webcamLayoutPreset?: WebcamLayoutPreset;webcamMaskShape?: import("@/components/video-editor/types").WebcamMaskShape;webcamMirrored?: boolean;+ webcamReactiveZoom?: boolean;webcamSizePreset?: WebcamSizePreset;webcamPosition?: { cx: number; cy: number } | null;cursorRecordingData?: CursorRecordingData | null;@@ -172,6 +173,7 @@ export class GifExporter {webcamLayoutPreset: this.config.webcamLayoutPreset,webcamMaskShape: this.config.webcamMaskShape,webcamMirrored: this.config.webcamMirrored,+ webcamReactiveZoom: this.config.webcamReactiveZoom,webcamSizePreset: this.config.webcamSizePreset,webcamPosition: this.config.webcamPosition,annotationRegions: this.config.annotationRegions,diff --git a/src/lib/exporter/videoExporter.ts b/src/lib/exporter/videoExporter.tsindex ac12273ee..a0b063789 100644--- a/src/lib/exporter/videoExporter.ts+++ b/src/lib/exporter/videoExporter.ts@@ -38,6 +38,7 @@ export interface VideoExporterConfig extends ExportConfig {webcamLayoutPreset?: WebcamLayoutPreset;webcamMaskShape?: import("@/components/video-editor/types").WebcamMaskShape;webcamMirrored?: boolean;+ webcamReactiveZoom?: boolean;webcamSizePreset?: WebcamSizePreset;webcamPosition?: { cx: number; cy: number } | null;cursorRecordingData?: CursorRecordingData | null;@@ -252,6 +253,7 @@ export class VideoExporter {webcamLayoutPreset: this.config.webcamLayoutPreset,webcamMaskShape: this.config.webcamMaskShape,webcamMirrored: this.config.webcamMirrored,+ webcamReactiveZoom: this.config.webcamReactiveZoom,webcamSizePreset: this.config.webcamSizePreset,webcamPosition: this.config.webcamPosition,annotationRegions: this.config.annotationRegions,