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
fix(zoom): grey out zoom levels that would blur the recording, and bound the render
EtienneLescotcd825ddd23e7
diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsxindex c04736717..65258360b 100644--- a/src/components/ai-edition/RightPanes.tsx+++ b/src/components/ai-edition/RightPanes.tsx@@ -3966,8 +3966,15 @@ export function ChoiceRow<T extends string | number>({display,}: {label: string;- /** `null` leaves a hole in the grid: the middle of the camera's position grid. */- options: ReadonlyArray<{ value: T; label: string; icon?: ReactNode } | null>;+ /** `null` leaves a hole in the grid: the middle of the camera's position grid. An option+ * can be `disabled` on its own, with the reason as its `title`. */+ options: ReadonlyArray<{+ value: T;+ label: string;+ icon?: ReactNode;+ disabled?: boolean;+ title?: string;+ } | null>;value: T;onChange: (next: T) => void;disabled?: boolean;@@ -4006,7 +4013,7 @@ export function ChoiceRow<T extends string | number>({// A hole is stepped over, not landed on.const to = options[from + step] === null ? from + 2 * step : from + step;const next = options[to];- if (!next) return;+ if (!next || next.disabled) return;buttonsRef.current[to]?.focus();if (next.value !== value) onChange(next.value);}}@@ -4025,8 +4032,8 @@ export function ChoiceRow<T extends string | number>({aria-pressed={pressed}aria-label={mode === "icon" ? option.label : undefined}// Always: a label cut short by a narrow pane still reads in full on hover.- title={option.label}- disabled={disabled}+ title={option.title ?? option.label}+ disabled={disabled || option.disabled}// Re-choisir la valeur en place n'est pas une modification : ni sauvegarde ni// entrée d'annulation.onClick={() => {diff --git a/src/components/ai-edition/v4/FloatingInspector.tsx b/src/components/ai-edition/v4/FloatingInspector.tsxindex 3e10abeb3..02a16dad9 100644--- a/src/components/ai-edition/v4/FloatingInspector.tsx+++ b/src/components/ai-edition/v4/FloatingInspector.tsx@@ -53,12 +53,14 @@ import {TEXT_ANIMATION_VALUES,} from "@/lib/ai-edition/annotations/textAnimation";import type { AxcutAnnotationRegion, AxcutClip } from "@/lib/ai-edition/schema";+import { useProjectStore } from "@/lib/ai-edition/store/projectStore";import { rafCoalesce } from "@/lib/ai-edition/store/rafCoalesce";import { useEditorSettings } from "@/lib/ai-edition/store/useEditorSettings";import type { useTimeline } from "@/lib/ai-edition/store/useTimeline";import { formatSeconds } from "@/lib/ai-edition/timeline/format";import { coalescedTrimGroups } from "@/lib/ai-edition/timeline/trim-mapping";import { clampToBound } from "@/lib/projectDefaults";+import { zoomScaleLimit } from "@/native/sceneDescription";import { ColorField } from "../ColorField";import shell from "../NewEditorShell.module.css";import {@@ -457,9 +459,13 @@ const ZOOM_PRESETS = ([2, 3, 4, 5] as const).map((depth) => ({export function ZoomLevelControl({region,tl,+ maxScale = MAX_ZOOM_SCALE,}: {region: { id: string; depth: ZoomDepth; customScale?: number };tl: Pick<TimelineApi, "updateZoomDepth" | "updateZoomCustomScale">;+ /** The deepest level this region's clip takes before its recording blurs+ * (`zoomScaleLimit`). Deeper presets are greyed out with the reason. */+ maxScale?: number;}) {const ts = useScopedT("settings");const current = effectiveZoomScale(region);@@ -530,13 +536,18 @@ export function ZoomLevelControl({// Empty or unparseable reverts to the live level rather than guessing at an intent.if (text === "" || !Number.isFinite(Number(text))) return;const scale = Math.round(Number(text) * 100) / 100;- if (scale < MIN_ZOOM_SCALE || scale > MAX_ZOOM_SCALE) {- toast.error(ts("zoom.customScaleRange", { min: MIN_ZOOM_SCALE, max: MAX_ZOOM_SCALE }));+ if (scale < MIN_ZOOM_SCALE || scale > maxScale) {+ toast.error(ts("zoom.customScaleRange", { min: MIN_ZOOM_SCALE, max: maxScale }));return;}setScale(scale);};+ const tooDeep = ts("zoom.levelBlurs", { max: maxScale });+ const presets = ZOOM_PRESETS.map((preset) =>+ preset.value > maxScale ? { ...preset, disabled: true, title: tooDeep } : preset,+ );+return (<>{/* A level outside the row presses no button; the field below shows it. */}@@ -544,11 +555,12 @@ export function ZoomLevelControl({ts("zoom.level"),<ChoiceRow<number>label={ts("zoom.level")}- options={ZOOM_PRESETS}+ options={presets}value={requested}onChange={setScale}/>,)}+ {maxScale < MAX_ZOOM_SCALE ? <p className={shell.hint}>{tooDeep}</p> : null}{paneRow(ts("zoom.customScale"),<input@@ -719,6 +731,12 @@ function SelectionPane({ tl, onClose }: { tl: TimelineApi; onClose: () => void }// toggle that writes it lives in the timeline toolbar, not on this component's path.const { settings } = useEditorSettings();const autoFocusAll = settings.autoFocusAll;+ const doc = useProjectStore((s) => s.document);+ const zoomId = tl.selection?.kind === "zoom" ? tl.selection.id : null;+ const zoomMaxScale = useMemo(+ () => (doc && zoomId ? zoomScaleLimit(doc, zoomId) : MAX_ZOOM_SCALE),+ [doc, zoomId],+ );// Mise à jour en direct regroupée à une par frame. `updateAnnotationLive` remplace le document// dans le store, donc chaque appel fait reconstruire et re-sérialiser toute la scène avant de// la pousser au natif : c'est le juste prix une fois par image, mais un `<input type="color">`@@ -773,7 +791,7 @@ function SelectionPane({ tl, onClose }: { tl: TimelineApi; onClose: () => void }<div style={{ display: "flex", flexDirection: "column", minHeight: 0 }}>{paneHeader(<ZoomIn size={16} />, tt("labels.zoom"), onClose, tc("actions.close"))}<div style={bodyStyle}>- <ZoomLevelControl key={region.id} region={region} tl={tl} />+ <ZoomLevelControl key={region.id} region={region} tl={tl} maxScale={zoomMaxScale} /><div style={{ display: "flex", flexDirection: "column", gap: 4 }}>{paneRow(ts("zoom.camera.title"),diff --git a/src/components/ai-edition/v4/ZoomLevelControl.test.tsx b/src/components/ai-edition/v4/ZoomLevelControl.test.tsxindex 7b76a663b..c7fef006f 100644--- a/src/components/ai-edition/v4/ZoomLevelControl.test.tsx+++ b/src/components/ai-edition/v4/ZoomLevelControl.test.tsx@@ -123,6 +123,33 @@ describe("ZoomLevelControl", () => {expect(updateZoomDepth).not.toHaveBeenCalled();});+ it("greys out the levels that would blur this clip, with the reason, and refuses them typed", () => {+ const updateZoomDepth = vi.fn(async (_id: string, _depth: ZoomDepth) => true);+ render(+ <ZoomLevelControl+ region={{ id: "z1", depth: 3 }}+ tl={{ updateZoomDepth, updateZoomCustomScale }}+ maxScale={2.5}+ />,+ );+ const buttons = screen.getAllByRole("button") as HTMLButtonElement[];+ expect(buttons.map((b) => b.disabled)).toEqual([false, false, false, true]);+ expect(buttons[3]).toHaveAttribute("title", "zoom.levelBlurs:2.5");+ expect(screen.getByText("zoom.levelBlurs:2.5")).toBeInTheDocument();++ const field = screen.getByRole("textbox", { name: "zoom.customScale" });+ fireEvent.change(field, { target: { value: "3" } });+ fireEvent.blur(field);+ expect(toastError).toHaveBeenCalledWith("zoom.customScaleRange:1,2.5");+ expect(updateZoomCustomScale).not.toHaveBeenCalled();+ expect(updateZoomDepth).not.toHaveBeenCalled();+ });++ it("says nothing when every level is within reach", () => {+ renderControl(3);+ expect(screen.queryByText(/zoom\.levelBlurs/)).not.toBeInTheDocument();+ });+it("ignores an unparseable draft without touching the region", () => {const { updateZoomDepth, field } = renderControl(3);fireEvent.change(field, { target: { value: "abc" } });diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.jsonindex 820ba9a36..52f5b30db 100644--- a/src/i18n/locales/ar/settings.json+++ b/src/i18n/locales/ar/settings.json@@ -387,6 +387,7 @@"previewHold": "اضغط مع الاستمرار لمعاينة تأثير التكبير","customScale": "تكبير مخصص","customScaleRange": "يتراوح التكبير بين {{min}}× و{{max}}×",+ "levelBlurs": "بعد {{max}}×، سيُكبَّر هذا التسجيل أكثر من مرتين ويصبح ضبابيًا.","selectRegion": "حدد منطقة التكبير للتعديل","cursor": {"title": "المؤشر",diff --git a/src/i18n/locales/cs/settings.json b/src/i18n/locales/cs/settings.jsonindex 998f87206..7fc99ec5b 100644--- a/src/i18n/locales/cs/settings.json+++ b/src/i18n/locales/cs/settings.json@@ -387,6 +387,7 @@"previewHold": "Podržte pro náhled efektu přiblížení","customScale": "Vlastní přiblížení","customScaleRange": "Přiblížení může být od {{min}}× do {{max}}×",+ "levelBlurs": "Nad {{max}}× by se tento záznam zvětšil víc než 2× a rozmazal se.","selectRegion": "Vyberte oblast přiblížení pro úpravu","cursor": {"title": "Kurzor",diff --git a/src/i18n/locales/de/settings.json b/src/i18n/locales/de/settings.jsonindex a30b71fe1..74784272e 100644--- a/src/i18n/locales/de/settings.json+++ b/src/i18n/locales/de/settings.json@@ -387,6 +387,7 @@"previewHold": "Gedrückt halten für die Zoom-Vorschau","customScale": "Eigener Zoom","customScaleRange": "Der Zoom reicht von {{min}}× bis {{max}}×",+ "levelBlurs": "Über {{max}}× würde diese Aufnahme mehr als 2× vergrößert und unscharf.","selectRegion": "Wähle einen Zoom-Bereich zum Anpassen","cursor": {"title": "Cursor",diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.jsonindex e529e7601..aad2ad560 100644--- a/src/i18n/locales/en/settings.json+++ b/src/i18n/locales/en/settings.json@@ -387,6 +387,7 @@"previewHold": "Hold to preview zoom effect","customScale": "Custom zoom","customScaleRange": "Zoom goes from {{min}}× to {{max}}×",+ "levelBlurs": "Past {{max}}×, this recording would be enlarged more than 2× and blur.","selectRegion": "Select a zoom region to adjust","cursor": {"title": "Cursor",diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.jsonindex 5581799e0..e159d8e72 100644--- a/src/i18n/locales/es/settings.json+++ b/src/i18n/locales/es/settings.json@@ -387,6 +387,7 @@"previewHold": "Mantener para previsualizar el efecto de zoom","customScale": "Zoom personalizado","customScaleRange": "El zoom va de {{min}}× a {{max}}×",+ "levelBlurs": "Por encima de {{max}}×, esta grabación se ampliaría más de 2× y se vería borrosa.","selectRegion": "Selecciona una región de zoom para ajustar","cursor": {"title": "Cursor",diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.jsonindex 4b698ef17..6b8e27c7a 100644--- a/src/i18n/locales/fr/settings.json+++ b/src/i18n/locales/fr/settings.json@@ -387,6 +387,7 @@"previewHold": "Maintenir pour prévisualiser l'effet de zoom","customScale": "Zoom personnalisé","customScaleRange": "Le zoom va de {{min}}× à {{max}}×",+ "levelBlurs": "Au-delà de {{max}}×, cet enregistrement serait agrandi plus de 2× et deviendrait flou.","selectRegion": "Sélectionnez une région de zoom à ajuster","cursor": {"title": "Curseur",diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.jsonindex b33efa5d3..085c6dd3f 100644--- a/src/i18n/locales/it/settings.json+++ b/src/i18n/locales/it/settings.json@@ -387,6 +387,7 @@"previewHold": "Tieni premuto per vedere l'anteprima dell'effetto zoom","customScale": "Zoom personalizzato","customScaleRange": "Lo zoom va da {{min}}× a {{max}}×",+ "levelBlurs": "Oltre {{max}}×, questa registrazione verrebbe ingrandita più di 2× e risulterebbe sfocata.","selectRegion": "Seleziona una regione zoom da regolare","cursor": {"title": "Cursore",diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.jsonindex c9dcab066..05a419369 100644--- a/src/i18n/locales/ja-JP/settings.json+++ b/src/i18n/locales/ja-JP/settings.json@@ -387,6 +387,7 @@"previewHold": "押している間ズーム効果をプレビュー","customScale": "カスタムズーム","customScaleRange": "ズーム倍率は{{min}}×から{{max}}×までです",+ "levelBlurs": "{{max}}×を超えると、この録画は2倍以上に拡大されてぼやけます。","selectRegion": "ズーム範囲を選択して調整","cursor": {"title": "カーソル",diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.jsonindex f0bc32cc5..c39788147 100644--- a/src/i18n/locales/ko-KR/settings.json+++ b/src/i18n/locales/ko-KR/settings.json@@ -387,6 +387,7 @@"previewHold": "누르고 있으면 줌 효과 미리보기","customScale": "커스텀 줌","customScaleRange": "줌은 {{min}}×에서 {{max}}×까지 가능합니다",+ "levelBlurs": "{{max}}×를 넘으면 이 녹화가 2배 넘게 확대되어 흐려집니다.","selectRegion": "조정할 줌 구간을 선택하세요","cursor": {"title": "커서",diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.jsonindex 03ffc9c82..823d0c8b7 100644--- a/src/i18n/locales/pt-BR/settings.json+++ b/src/i18n/locales/pt-BR/settings.json@@ -387,6 +387,7 @@"previewHold": "Mantenha pressionado para pré-visualizar o efeito de zoom","customScale": "Zoom Personalizado","customScaleRange": "O zoom vai de {{min}}× a {{max}}×",+ "levelBlurs": "Acima de {{max}}×, esta gravação seria ampliada mais de 2× e ficaria borrada.","selectRegion": "Selecione uma região de zoom para ajustar","cursor": {"title": "Cursor",diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.jsonindex a28403d66..123fef3dd 100644--- a/src/i18n/locales/ru/settings.json+++ b/src/i18n/locales/ru/settings.json@@ -387,6 +387,7 @@"previewHold": "Удерживайте для предпросмотра эффекта зума","customScale": "Пользовательский масштаб","customScaleRange": "Масштаб может быть от {{min}}× до {{max}}×",+ "levelBlurs": "Выше {{max}}× эта запись увеличится более чем в 2 раза и станет размытой.","selectRegion": "Выберите область масштабирования для настройки","cursor": {"title": "Курсор",diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.jsonindex 454f82a79..4d1609f86 100644--- a/src/i18n/locales/tr/settings.json+++ b/src/i18n/locales/tr/settings.json@@ -387,6 +387,7 @@"previewHold": "Yakınlaştırma efektini önizlemek için basılı tutun","customScale": "Özel Yakınlaştırma","customScaleRange": "Yakınlaştırma {{min}}× ile {{max}}× arasında olabilir",+ "levelBlurs": "{{max}}× üzerinde bu kayıt 2 kattan fazla büyür ve bulanıklaşır.","selectRegion": "Ayarlamak için bir yakınlaştırma bölgesi seçin","cursor": {"title": "İmleç",diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.jsonindex 0daeac1eb..8549a7c2e 100644--- a/src/i18n/locales/vi/settings.json+++ b/src/i18n/locales/vi/settings.json@@ -387,6 +387,7 @@"previewHold": "Giữ để xem trước hiệu ứng phóng to","customScale": "Thu phóng tùy chỉnh","customScaleRange": "Mức thu phóng từ {{min}}× đến {{max}}×",+ "levelBlurs": "Vượt quá {{max}}×, bản ghi này sẽ bị phóng to hơn 2× và bị mờ.","selectRegion": "Chọn vùng thu phóng để điều chỉnh","cursor": {"title": "Con trỏ",diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.jsonindex 514a2a135..2b28817de 100644--- a/src/i18n/locales/zh-CN/settings.json+++ b/src/i18n/locales/zh-CN/settings.json@@ -387,6 +387,7 @@"previewHold": "按住预览放大效果","customScale": "自定义缩放","customScaleRange": "缩放范围为 {{min}}× 到 {{max}}×",+ "levelBlurs": "超过 {{max}}× 后,此录制内容会被放大 2 倍以上而变得模糊。","selectRegion": "选择要调整的缩放区域","cursor": {"title": "光标",diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.jsonindex d501839af..d310920a8 100644--- a/src/i18n/locales/zh-TW/settings.json+++ b/src/i18n/locales/zh-TW/settings.json@@ -387,6 +387,7 @@"previewHold": "按住預覽放大效果","customScale": "自訂縮放","customScaleRange": "縮放範圍為 {{min}}× 到 {{max}}×",+ "levelBlurs": "超過 {{max}}× 後,此錄製內容會被放大 2 倍以上而變得模糊。","selectRegion": "選擇要調整的縮放區域","cursor": {"title": "游標",diff --git a/src/lib/ai-edition/timeline/zoom-scale.test.ts b/src/lib/ai-edition/timeline/zoom-scale.test.tsindex 809d44f85..0b655dac3 100644--- a/src/lib/ai-edition/timeline/zoom-scale.test.ts+++ b/src/lib/ai-edition/timeline/zoom-scale.test.ts@@ -9,6 +9,7 @@ import {effectiveZoomScale,MAX_ZOOM_SCALE,MIN_ZOOM_SCALE,+ maxZoomScaleFor,ZOOM_DEPTH_LEGEND,} from "./zoom-scale";@@ -63,3 +64,18 @@ describe("ZOOM_DEPTH_LEGEND", () => {}});});++describe("maxZoomScaleFor", () => {+ it("keeps rest magnification × zoom at or under 2", () => {+ expect(maxZoomScaleFor(0.8)).toBe(2.5); // 1080p take, 50 % padding+ expect(maxZoomScaleFor(0.4)).toBe(MAX_ZOOM_SCALE); // 2160p take+ expect(maxZoomScaleFor(1.6)).toBe(1.25); // half of a 1080p take+ expect(maxZoomScaleFor(0.9) * 0.9).toBeLessThanOrEqual(2);+ });++ it("never goes below 1 and ignores a missing magnification", () => {+ expect(maxZoomScaleFor(3)).toBe(MIN_ZOOM_SCALE);+ expect(maxZoomScaleFor(0)).toBe(MAX_ZOOM_SCALE);+ expect(maxZoomScaleFor(Number.NaN)).toBe(MAX_ZOOM_SCALE);+ });+});diff --git a/src/lib/ai-edition/timeline/zoom-scale.ts b/src/lib/ai-edition/timeline/zoom-scale.tsindex fe0bef88a..2cc8b23bf 100644--- a/src/lib/ai-edition/timeline/zoom-scale.ts+++ b/src/lib/ai-edition/timeline/zoom-scale.ts@@ -59,6 +59,27 @@ export function effectiveZoomScale(region: ZoomScaleInput): number {return ZOOM_DEPTH_SCALES[region.depth];}+/**+ * How far a recording may be blown up on the finished frame before it visibly blurs: output+ * pixels per source pixel. Crop and zoom multiply, so the zoom a clip can take depends on+ * how big it already is at rest (`maxZoomScaleFor`).+ */+export const MAX_SOURCE_MAGNIFICATION = 2;++/** The frame magnification is measured on: the short side of the default export (Good, 1080p). */+export const MAGNIFICATION_REFERENCE_PX = 1080;++/**+ * The deepest zoom that keeps a clip at or under `MAX_SOURCE_MAGNIFICATION`, given its+ * magnification at rest (screen box px ÷ source px, crop included). Never below 1: a clip+ * already past the limit at rest cannot zoom at all, rather than zoom out.+ */+export function maxZoomScaleFor(restMagnification: number): number {+ if (!(restMagnification > 0)) return MAX_ZOOM_SCALE;+ const scale = Math.floor((MAX_SOURCE_MAGNIFICATION / restMagnification) * 100) / 100;+ return Math.max(MIN_ZOOM_SCALE, Math.min(MAX_ZOOM_SCALE, scale));+}+/*** The depth→scale table as one line of prose, for the tool descriptions handed* to the model.diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.tsindex 2dcf9d7ba..004dabf69 100644--- a/src/native/sceneDescription.test.ts+++ b/src/native/sceneDescription.test.ts@@ -21,7 +21,7 @@ import { axcutSchemaVersion } from "@/lib/ai-edition/schema";import { DEFAULT_CURSOR_THEME_ID } from "@/lib/cursor/cursorThemes";import { DEVICE_FRAMES } from "@/lib/projectDefaults";import { getFocusBoundsForScale } from "@/lib/zoomMath/focusUtils";-import { buildSceneDescription, wallpaperAcceptsMotion } from "./sceneDescription";+import { buildSceneDescription, wallpaperAcceptsMotion, zoomScaleLimit } from "./sceneDescription";// --- Fixture helpers --------------------------------------------------------// Keep fixtures minimal & deterministic — every field the serializer consults is filled in;@@ -585,6 +585,48 @@ describe("buildSceneDescription.zoomRegions", () => {}});+ it("bounds each clip's zoom so its recording is never blown up past 2× at 1080p", () => {+ // Crop and zoom multiply: at 50 % padding a 1080p take already sits at 0.8, a 2160p+ // take at 0.4 and half a 1080p take at 1.6 of the default 1080p export.+ const at = (width: number, height: number, crop?: AxcutClip["cropRegion"]) => {+ const doc = makeDoc({+ assets: [+ makeAsset({+ id: "a",+ originalPath: "/a.mp4",+ durationSec: 5,+ video: { codec: "h264", width, height, fps: 30 },+ }),+ ],+ clips: [+ makeClip({+ id: "c1",+ assetId: "a",+ sourceStartSec: 0,+ sourceEndSec: 5,+ timelineStartSec: 0,+ timelineEndSec: 5,+ cropRegion: crop,+ }),+ ],+ zoomRanges: [+ makeZoom({ id: "z", startMs: 0, endMs: 1000, depth: 6, focus: { cx: 0.5, cy: 0.5 } }),+ ],+ legacyEditor: { padding: 50, aspectRatio: "16:9" },+ });+ return {+ scale: buildSceneDescription(doc).zoomRegions[0].scale,+ limit: zoomScaleLimit(doc, "z"),+ };+ };+ expect(at(1920, 1080)).toEqual({ scale: 2.5, limit: 2.5 });+ expect(at(3840, 2160)).toEqual({ scale: 5, limit: 5 });+ expect(at(1920, 1080, { x: 0.25, y: 0.25, width: 0.5, height: 0.5 })).toEqual({+ scale: 1.25,+ limit: 1.25,+ });+ });+it("customScale overrides the depth-derived value", () => {const z = makeZoom({id: "z",diff --git a/src/native/sceneDescription.ts b/src/native/sceneDescription.tsindex 7a2d53f4b..25f19fab6 100644--- a/src/native/sceneDescription.ts+++ b/src/native/sceneDescription.ts@@ -46,6 +46,11 @@ import { resolveClipSourceEndSec } from "@/lib/ai-edition/timeline/clipDuration"import { removedRawSpans } from "@/lib/ai-edition/timeline/programme-time";import { takeProgramme } from "@/lib/ai-edition/timeline/take-programme";import { projectRegionsToSource } from "@/lib/ai-edition/timeline/timelineMap";+import {+ MAGNIFICATION_REFERENCE_PX,+ MAX_ZOOM_SCALE,+ maxZoomScaleFor,+} from "@/lib/ai-edition/timeline/zoom-scale";import {computeCompositeLayout,paddedContentSize,@@ -608,6 +613,63 @@ export function resolveVisibleClips(document: AxcutDocument): PlaybackSegment[].filter((clip) => clipAssetIsResolvable(clip, assetById));}+/** A clip's screen source size in pixels: its recording × its crop (see `screenSourceSizeOf`). */+function screenSourceSize(+ video: { width?: number; height?: number } | null | undefined,+ crop: { width: number; height: number } | null | undefined,+) {+ return {+ width: Math.max(1, Math.round((video?.width || 1920) * (crop?.width ?? 1))),+ height: Math.max(1, Math.round((video?.height || 1080) * (crop?.height ?? 1))),+ };+}++/**+ * The deepest zoom a clip takes before its recording blurs: `maxZoomScaleFor` its+ * magnification at rest, frame pixels per source pixel, read on its screen box. The larger+ * axis, so a slot that covers its box (block layouts) counts the pixels it really blows up.+ *+ * Measured on the default export, a frame with a 1080 px short side+ * (`MAGNIFICATION_REFERENCE_PX`), not on `output`: `output` follows the largest clip, crop+ * included, so a cropped take would look small there and be upscaled at export. A 1080p take+ * at 50 % padding sits at 0.8 (limit 2.5×), a 2160p take at 0.4 (5×), half of a 1080p take+ * at 1.6 (1.25×).+ */+function zoomScaleLimitOf(+ rect: SceneRect | null,+ output: { width: number; height: number },+ source: { width: number; height: number },+): number {+ if (!rect) return MAX_ZOOM_SCALE;+ const toReference =+ MAGNIFICATION_REFERENCE_PX / Math.max(1, Math.min(output.width, output.height));+ const rest =+ toReference *+ Math.max(+ (rect.width * output.width) / source.width,+ (rect.height * output.height) / source.height,+ );+ return maxZoomScaleFor(rest);+}++/**+ * The deepest zoom the region `regionId` can take, for the inspector: the same bound the+ * scene applies, read on the clip the region belongs to. `MAX_ZOOM_SCALE` when the region+ * is not on screen.+ */+export function zoomScaleLimit(document: AxcutDocument, regionId: string): number {+ const scene = buildSceneDescription(document);+ const clipIndex = scene.zoomRegions.find((z) => z.id === regionId)?.clipIndex ?? 0;+ const clip = resolveVisibleClips(document)[clipIndex];+ if (!clip) return MAX_ZOOM_SCALE;+ const video = document.assets.find((a) => a.id === clip.assetId)?.video;+ return zoomScaleLimitOf(+ scene.layout.layoutByClip?.[clipIndex]?.screenRect ?? scene.layout.screenRect ?? null,+ scene.output,+ screenSourceSize(video, scene.cropByClip[clipIndex]),+ );+}+/** Serialize a document into a {@link SceneDescription}. Pure — no per-frame math. */export function buildSceneDescription(document: AxcutDocument,@@ -937,14 +999,9 @@ export function buildSceneDescription(* was already wrong for a document mixing recording resolutions — the crop only* made the existing defect visible, by letting one document hold two shapes.*/- const screenSourceSizeOf = (clip: AxcutClip, index: number) => {- const video = assetById.get(clip.assetId)?.video;- const crop = cropByClip[index]; // index-aligned; null = identity crop- return {- width: Math.max(1, Math.round((video?.width || 1920) * (crop?.width ?? 1))),- height: Math.max(1, Math.round((video?.height || 1080) * (crop?.height ?? 1))),- };- };+ const screenSourceSizeOf = (clip: AxcutClip, index: number) =>+ // index-aligned; null = identity crop+ screenSourceSize(assetById.get(clip.assetId)?.video, cropByClip[index]);/** Does THIS clip have a camera to lay out? Same expression as the `webcamPath` sent* with the clip above, so the layout and the decoder can never disagree about it.* Note this is NOT `hasAnyClipWithCamera` (which gates the Layout panel): that one@@ -1053,6 +1110,14 @@ export function buildSceneDescription(? toFrameFractions(computedLayout.webcamRect): null;const screenRect = computedLayout ? toFrameFractions(computedLayout.screenRect) : null;+ // The deepest zoom each clip takes before its recording blurs (`zoomScaleLimitOf`).+ const zoomLimitByClip = visibleClips.map((clip, index) =>+ zoomScaleLimitOf(+ layoutByClip[index]?.screenRect ?? screenRect,+ outputDims,+ screenSourceSizeOf(clip, index),+ ),+ );return {clips,@@ -1143,7 +1208,14 @@ export function buildSceneDescription(// [1.0, 5.0] que l'UI applique. Or `zoomRegionSchema` n'exige de `customScale`// que d'être positif : un document portant `customScale: 12` est valide, rendait// 5× dans l'aperçu web et 12× ici. Même désaccord que ci-dessus, un cran plus bas.- scale: getZoomScale(region),+ //+ // Bounded per clip: crop and zoom multiply, and past `MAX_SOURCE_MAGNIFICATION` the+ // recording blurs. The inspector greys those levels out; this catches a level set+ // before a crop or a format change made it too deep.+ scale: Math.min(+ getZoomScale(region),+ zoomLimitByClip[region.clipIndex ?? 0] ?? MAX_ZOOM_SCALE,+ ),focusX: region.focus.cx,focusY: region.focus.cy,// The global Auto-Focus toggle OVERRIDES each region's own mode rather than merely