Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat(format): fill a fixed format with a window that follows the cursor

EtienneLescot51fc97404f7e
diff --git a/crates/compositor/src/frame_geometry.rs b/crates/compositor/src/frame_geometry.rs
index bfab0d4d2..18e1f9246 100644
--- a/crates/compositor/src/frame_geometry.rs
+++ b/crates/compositor/src/frame_geometry.rs
@@ -369,6 +369,23 @@ pub(crate) fn cover_uv_rect(uv: [f32; 4], tex: [f32; 2], box_ar: f32) -> [f32; 4
let (cx, cy) = (uv[0] + w_uv * 0.5, uv[1] + h_uv * 0.5);
[cx - new_w * 0.5, cy - new_h * 0.5, cx + new_w * 0.5, cy + new_h * 0.5]
}
+/// `cover_uv_rect`, la fenêtre centrée sur `at` (UV) au lieu du centre de `uv`, et bornée à `uv` :
+/// le remplissage du format, qui suit le curseur lissé dans l'enregistrement. Même taille que la
+/// fenêtre centrée, donc même grossissement ; seule sa position change.
+pub(crate) fn follow_cover_uv_rect(
+ uv: [f32; 4],
+ tex: [f32; 2],
+ box_ar: f32,
+ at: [f32; 2],
+) -> [f32; 4] {
+ let c = cover_uv_rect(uv, tex, box_ar);
+ let (hw, hh) = (0.5 * (c[2] - c[0]), 0.5 * (c[3] - c[1]));
+ // `max` puis `min`, pas `clamp` : à la précision flottante près la fenêtre peut dépasser `uv`
+ // d'un epsilon, et `clamp` panique quand sa borne basse passe la haute.
+ let cx = at[0].max(uv[0] + hw).min(uv[2] - hw);
+ let cy = at[1].max(uv[1] + hh).min(uv[3] - hh);
+ [cx - hw, cy - hh, cx + hw, cy + hh]
+}
pub const HALF_W: u32 = OUT_W / 2;
pub const HALF_H: u32 = OUT_H / 2;
pub const FIXTURE_FRAMES: u32 = 360;
@@ -2933,23 +2950,39 @@ pub fn plan_frame(input: &FrameGeometryInput) -> FrameGeometry {
.screen_cover
.then_some((s_base[2] * rw) / (s_base[3] * rh).max(0.0001))
});
- let cover = |uv: [f32; 4]| -> [f32; 4] {
- match cover_box_ar {
- Some(ar) => cover_uv_rect(uv, [stw as f32, sth as f32], ar),
- None => uv,
+ // Remplissage du format (`screen_follow`) : la fenêtre du cover suit le curseur lissé,
+ // en UV. Sans piste, elle reste centrée.
+ let follow = cover_box_ar.is_some() && scene.is_some_and(|s| s.layout.screen_follow);
+ let follow_at = |t: f32| -> Option<[f32; 2]> {
+ let (x, y) = cursor.filter(|_| follow)?.follow_at(t)?;
+ Some([x * u_max, y * v_max])
+ };
+ let cover = |uv: [f32; 4], at: Option<[f32; 2]>| -> [f32; 4] {
+ match (cover_box_ar, at) {
+ (Some(ar), Some(at)) => follow_cover_uv_rect(uv, [stw as f32, sth as f32], ar, at),
+ (Some(ar), None) => cover_uv_rect(uv, [stw as f32, sth as f32], ar),
+ (None, _) => uv,
}
};
// La coupe RÉFÉRENCE (zoom entier) est celle qui remplissait la boîte paddée avant
// ce correctif ; la coupe DESSINÉE ne porte plus que le crop. `remap_box` reporte la
// seconde à travers le mapping de la première, ce qui conserve le cadrage exact.
// Le focus courant reste volontairement utilisé pour la frame précédente, comme avant.
- let cut_ref = cover(screen_source_rect(u_max, v_max, active_crop, p.zoom, p.focus));
- let cut_ref_prev = cover(screen_source_rect(u_max, v_max, active_crop, pp.zoom, p.focus));
+ let cut_ref =
+ cover(screen_source_rect(u_max, v_max, active_crop, p.zoom, p.focus), follow_at(source_t));
+ let cut_ref_prev = cover(
+ screen_source_rect(u_max, v_max, active_crop, pp.zoom, p.focus),
+ follow_at(source_t_prev),
+ );
+ // Sous le remplissage, la coupe dessinée est le crop ENTIER : la fenêtre bouge, et une
+ // coupe dessinée qui ne la contiendrait plus laisserait un trou dans le slot. Le masque du
+ // slot (`screen_mask`) rogne le reste.
let crop_cut = screen_source_rect(u_max, v_max, active_crop, 1.0, p.focus);
- let cut = cover(crop_cut);
- // L'enregistrement affiché au repos, en entier : le `cover` d'un slot en rogne une partie,
- // on la rajoute (même échelle px/UV que la boîte).
- let shown = |i: usize| (crop_cut[i + 2] - crop_cut[i]) / (cut[i + 2] - cut[i]).max(1e-6);
+ let cut = if follow { crop_cut } else { cover(crop_cut, None) };
+ // Ce que l'écran montre au repos : la fenêtre couverte, suivie ou non. Le curseur, les coins
+ // et l'ombre se mesurent sur elle, pas sur la coupe entière que le remplissage dessine.
+ let window = cover(crop_cut, follow_at(source_t));
+ let shown = |i: usize| (crop_cut[i + 2] - crop_cut[i]) / (window[i + 2] - window[i]).max(1e-6);
let screen_unit_px =
screen_unit_px([s_base[2] * rw * shown(0), s_base[3] * rh * shown(1)], padding_scale);
// Impact du clic : mêmes piste, coupe, porte et budget que la parallaxe sous un angle fixe ;
@@ -5544,6 +5577,69 @@ mod tests {
)))
}
+ /// Un clip 16:9 dans une sortie 9:16 remplie (`screenCover` + `screenFollow`) : la boîte écran
+ /// est la zone paddée entière, `follow` décide si la fenêtre suit le pointeur.
+ fn fill_plan(follow: bool, pointer: Option<(f32, f32)>) -> FrameGeometry {
+ let scene = Scene::from_json(&format!(
+ r##"{{
+ "clips":[{{"screenPath":"/s.mp4","webcamPath":"","sourceStartSec":0,"sourceEndSec":10,"webcamOffsetSec":0,"hasAudio":false}}],
+ "layout":{{"preset":"no-webcam","webcamSize":1,"webcamShape":"rounded","webcamMirror":false,"webcamPosition":null,
+ "webcamReactiveZoom":false,"screenRect":{{"x":0.1,"y":0.1,"width":0.8,"height":0.8}},
+ "screenCover":true,"screenFollow":{follow}}},
+ "effects":{{"padding":0.5,"blur":false,"shadow":0.5,"roundnessFrac":0.02,"motionBlur":0}},
+ "background":{{"kind":"color","color":"#1e1e2e"}},
+ "zoomRegions":[],
+ "cursor":{{"show":false,"size":1,"smoothing":0,"motionBlur":0,"clickBounce":1,"clipToBounds":false,"theme":"default"}},
+ "cropByClip":[null],
+ "output":{{"width":1080,"height":1920,"fps":60}}
+ }}"##
+ ))
+ .expect("scène remplie");
+ let cfg = crate::config::all().pop().expect("au moins une config");
+ let mut input = golden_input(&scene, &cfg);
+ input.render_px = [1080.0, 1920.0];
+ input.cursor = pointer.map(|(x, y)| parked_track(x, y));
+ plan_frame(&input)
+ }
+
+ /// Le remplissage du format : un clip 16:9 remplit une sortie 9:16, et la fenêtre 9:16 qu'il
+ /// y montre suit le pointeur lissé, bornée à l'enregistrement.
+ ///
+ /// * la fenêtre a le ratio de la boîte, toute la hauteur de l'enregistrement ;
+ /// * elle se centre sur le pointeur, et bute sur le bord quand il s'en approche ;
+ /// * sans `screenFollow`, ou sans piste, elle reste centrée ;
+ /// * la coupe DESSINÉE est l'enregistrement entier, et sa boîte couvre le slot : la fenêtre
+ /// peut bouger sans jamais laisser de trou.
+ #[test]
+ fn a_filled_format_follows_the_pointer_inside_the_recording() {
+ let (u, v) = (1.0f32, 1080.0f32 / 1088.0);
+ // Ce que le slot montre de l'enregistrement, en 0..1 : le slot reporté par s_dst → cut.
+ let seen = |g: &FrameGeometry| -> [f32; 4] {
+ let (s, d, c) = (g.s_ann, g.s_dst, g.cut);
+ let x = |f: f32| (c[0] + (f - d[0]) / d[2] * (c[2] - c[0])) / u;
+ let y = |f: f32| (c[1] + (f - d[1]) / d[3] * (c[3] - c[1])) / v;
+ [x(s[0]), y(s[1]), x(s[0] + s[2]), y(s[1] + s[3])]
+ };
+
+ let at = fill_plan(true, Some((0.7, 0.5)));
+ let w = seen(&at);
+ assert!((0.5 * (w[0] + w[2]) - 0.7).abs() < 1e-3, "fenêtre {w:?}, pointeur en 0.7");
+ assert!(w[1].abs() < 1e-3 && (w[3] - 1.0).abs() < 1e-3, "toute la hauteur : {w:?}");
+ let shown_ar = ((w[2] - w[0]) * 1920.0) / ((w[3] - w[1]) * 1080.0);
+ assert!((shown_ar - 864.0 / 1536.0).abs() < 1e-3, "ratio montré {shown_ar}");
+ assert!(contains(at.s_dst, at.s_ann, 1e-5), "la boîte dessinée ne couvre pas le slot");
+
+ // Au bord : la fenêtre bute sur l'enregistrement.
+ let edge = seen(&fill_plan(true, Some((0.98, 0.5))));
+ assert!((edge[2] - 1.0).abs() < 1e-3, "fenêtre {edge:?}");
+
+ // Sans suivi, ou sans piste : centrée.
+ for g in [fill_plan(false, Some((0.7, 0.5))), fill_plan(true, None)] {
+ let w = seen(&g);
+ assert!((0.5 * (w[0] + w[2]) - 0.5).abs() < 1e-3, "fenêtre centrée attendue, {w:?}");
+ }
+ }
+
/// `slot_scene` à 1,5 s (zoom tenu), pointeur garé en `pointer` (la caméra en orbite le suit).
fn slot_plan(scene: &Scene, pointer: Option<(f32, f32)>) -> FrameGeometry {
let cfg = crate::config::all().pop().expect("au moins une config");
diff --git a/crates/compositor/src/scene.rs b/crates/compositor/src/scene.rs
index b6004c7c9..12296b1eb 100644
--- a/crates/compositor/src/scene.rs
+++ b/crates/compositor/src/scene.rs
@@ -90,6 +90,13 @@ pub struct SceneLayout {
/// `#[serde(default)]` : absent → `false` → comportement "contain" historique.
#[serde(default)]
pub screen_cover: bool,
+ /// Remplissage du format : la boîte écran est la zone paddée entière, et la fenêtre que le
+ /// `cover` y découpe SUIT le curseur lissé au lieu de rester centrée
+ /// (`frame_geometry::follow_cover`). Sans effet si `screen_cover` est faux.
+ ///
+ /// `#[serde(default)]` : absent → `false` → fenêtre centrée, comme avant.
+ #[serde(default)]
+ pub screen_follow: bool,
/// Un layout résolu PAR CLIP visible, aligné par index sur `Scene::clips` / `crop_by_clip`.
/// Les champs scalaires ci-dessus sont ceux du PREMIER clip (repli pour un payload sans ce
/// tableau, et valeur de départ tant qu'aucun clip n'est actif).
diff --git a/src/components/ai-edition/PreviewCanvas.tsx b/src/components/ai-edition/PreviewCanvas.tsx
index f0950c82b..fe2a1eef4 100644
--- a/src/components/ai-edition/PreviewCanvas.tsx
+++ b/src/components/ai-edition/PreviewCanvas.tsx
@@ -31,7 +31,10 @@ import {
type ZoomFocus,
} from "@/components/video-editor/types";
import { useScopedT } from "@/contexts/I18nContext";
-import { resolveAspectRatioValue } from "@/lib/ai-edition/document/outputFormat";
+import {
+ isFormatFillActive,
+ resolveAspectRatioValue,
+} from "@/lib/ai-edition/document/outputFormat";
import type {
AxcutAnnotationRegion,
AxcutAudioTrack,
@@ -237,6 +240,7 @@ export function PreviewCanvas(props: PreviewCanvasProps) {
);
const activeClipHasCamera = Boolean(activeCameraTrack?.visible && activeCameraTrack.sourcePath);
+ const formatFill = useMemo(() => (document ? isFormatFillActive(document) : false), [document]);
const layout = useMemo(() => {
// A clip with no camera lays out as "no-webcam", whatever the panel says. Hiding
// only the webcam slot is not enough: the block presets size the SCREEN off the
@@ -265,7 +269,8 @@ export function PreviewCanvas(props: PreviewCanvasProps) {
return computeCompositeLayout({
canvasSize: frameSize,
maxContentSize,
- screenSize: croppedScreenSize,
+ // Same box as the scene: a filled format gives the screen the whole padded area.
+ screenSize: formatFill ? maxContentSize : croppedScreenSize,
webcamSize: preset === "no-webcam" ? null : WEBCAM_SOURCE_SIZE,
layoutPreset: preset,
webcamSizePreset: settings.webcamSizePreset,
@@ -286,6 +291,7 @@ export function PreviewCanvas(props: PreviewCanvasProps) {
settings.webcamRoundness,
settings.padding,
settings.aspectRatio,
+ formatFill,
]);
// Full Camera: during a cameraFullscreen region the webcam takes the whole
diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsx
index 2ddda2fe9..0128e813c 100644
--- a/src/components/ai-edition/RightPanes.tsx
+++ b/src/components/ai-edition/RightPanes.tsx
@@ -51,6 +51,8 @@ import { resolveCaptionLane } from "@/lib/ai-edition/captions/settings";
import { collapseTracksToPills, trackGroupId } from "@/lib/ai-edition/document/audioTracks";
import {
collectNativeFormats,
+ type FormatFillAvailability,
+ formatFillAvailability,
isAutoFormatAvailable,
pickOutputDims,
} from "@/lib/ai-edition/document/outputFormat";
@@ -2340,6 +2342,14 @@ const RECORDING_FRAME_LABEL_KEYS: Record<RecordingFrame, string> = {
monitor: "effects.frameScreen",
};
+/** What the fill row says under itself: what "follow" does, or why it cannot. */
+const FORMAT_FILL_HINT_KEYS: Record<Exclude<FormatFillAvailability, "none">, string> = {
+ available: "effects.formatFillHelp",
+ mixed: "effects.formatFillMixed",
+ layout: "effects.formatFillLayout",
+ frame: "effects.formatFillFrame",
+};
+
const FRAME_THEME_LABEL_KEYS: Record<FrameTheme, string> = {
light: "effects.frameThemeLight",
dark: "effects.frameThemeDark",
@@ -2378,6 +2388,14 @@ export function VideoEffectsPane() {
[document],
);
const hasTiltedZoom = (document?.zoomRanges ?? []).some((z) => z.rotationPreset != null);
+ const fillAvailability = useMemo(
+ () => (document ? formatFillAvailability(document) : "none"),
+ [document],
+ );
+ const fillActive = settings.formatFollowCursor === true && fillAvailability === "available";
+ // Filling is the default for a format picked from now on; a project that already had one
+ // keeps showing its recording whole until the user says otherwise.
+ const fillDefault = settings.formatFollowCursor === null ? { formatFollowCursor: true } : {};
const [fitMenuOpen, setFitMenuOpen] = useState(false);
const [ratioMenuOpen, setRatioMenuOpen] = useState(false);
const [frameMenuOpen, setFrameMenuOpen] = useState(false);
@@ -2552,7 +2570,7 @@ export function VideoEffectsPane() {
}`}
onClick={() => {
setRatioMenuOpen(false);
- void set({ aspectRatio: ratio });
+ void set({ aspectRatio: ratio, ...fillDefault });
}}
>
<span className={styles.actionMenuMain}>{ratio}</span>
@@ -2575,7 +2593,7 @@ export function VideoEffectsPane() {
}`}
onClick={() => {
setRatioMenuOpen(false);
- void set({ aspectRatio: format.token });
+ void set({ aspectRatio: format.token, ...fillDefault });
}}
>
{/* Token leads and the pixel size rides on the right, exactly as this
@@ -2595,6 +2613,25 @@ export function VideoEffectsPane() {
</PopoverContent>
</Popover>
</div>
+ {/* How a recording of another shape sits in a fixed format: whole, or filling it with a
+ window that follows the cursor. Only listed when the two shapes differ; greyed out,
+ saying why, when the timeline has no single rule it could follow. */}
+ {fillAvailability !== "none" ? (
+ <div className={`${styles.field} ${styles.fieldStack}`}>
+ <span className={styles.fieldLabel}>{ts("effects.formatFill")}</span>
+ <ChoiceRow<"fit" | "follow">
+ label={ts("effects.formatFill")}
+ options={[
+ { value: "fit", label: ts("effects.formatFillFit") },
+ { value: "follow", label: ts("effects.formatFillFollow") },
+ ]}
+ value={fillActive ? "follow" : "fit"}
+ disabled={!hasDocument || fillAvailability !== "available"}
+ onChange={(v) => void set({ formatFollowCursor: v === "follow" })}
+ />
+ <p className={styles.hint}>{ts(FORMAT_FILL_HINT_KEYS[fillAvailability])}</p>
+ </div>
+ ) : null}
{/* The frame drawn around the recording, and its theme. Two menus like Format above
them, and for the same reason: each picks one project-wide look among a few. With a
frame on, Roundness rounds the footage within that frame's own range, the body
diff --git a/src/components/ai-edition/formatFill.test.tsx b/src/components/ai-edition/formatFill.test.tsx
new file mode 100644
index 000000000..132d6f5d5
--- /dev/null
+++ b/src/components/ai-edition/formatFill.test.tsx
@@ -0,0 +1,110 @@
+// @vitest-environment jsdom
+// The fill row under Format only appears when the format is not the recording's shape, says
+// why when it cannot act, and writes the project setting the scene reads.
+
+import "@testing-library/jest-dom";
+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { I18nProvider } from "@/contexts/I18nContext";
+import type { AxcutDocument } from "@/lib/ai-edition/schema";
+import { createEmptyDocument } from "@/lib/ai-edition/schema";
+import { useProjectStore } from "@/lib/ai-edition/store/projectStore";
+import { VideoEffectsPane } from "./RightPanes";
+
+vi.mock("sonner", () => ({ toast: { error: vi.fn(), success: vi.fn(), info: vi.fn() } }));
+
+function hdTake(editor: Record<string, unknown>): AxcutDocument {
+ const base = createEmptyDocument({ title: "T", projectId: "p1" });
+ return {
+ ...base,
+ assets: [
+ {
+ kind: "video",
+ id: "a1",
+ label: "a1",
+ originalPath: "/a1.mp4",
+ cameraTrack: null,
+ video: { codec: "h264", width: 1920, height: 1080, fps: 30 },
+ },
+ ],
+ timeline: {
+ ...base.timeline,
+ clips: [
+ {
+ id: "c1",
+ assetId: "a1",
+ sourceStartSec: 0,
+ sourceEndSec: 5,
+ timelineStartSec: 0,
+ timelineEndSec: 5,
+ wordRefs: [],
+ origin: "user",
+ reason: "",
+ },
+ ],
+ },
+ legacyEditor: editor,
+ } as unknown as AxcutDocument;
+}
+
+function mount(doc: AxcutDocument) {
+ useProjectStore.setState({ document: doc });
+ render(
+ <I18nProvider>
+ <VideoEffectsPane />
+ </I18nProvider>,
+ );
+}
+
+const stored = () =>
+ (useProjectStore.getState().document?.legacyEditor as Record<string, unknown> | undefined)
+ ?.formatFollowCursor;
+
+beforeEach(() => {
+ localStorage.clear();
+ useProjectStore.setState({ document: null });
+});
+afterEach(() => {
+ cleanup();
+ localStorage.clear();
+});
+
+describe("format fill", () => {
+ it("is not listed when the format is the recording's shape", () => {
+ mount(hdTake({ aspectRatio: "16:9" }));
+ expect(screen.queryByRole("group", { name: "Recording" })).not.toBeInTheDocument();
+ });
+
+ it("switches a 9:16 project between the whole recording and a window on the cursor", async () => {
+ mount(hdTake({ aspectRatio: "9:16" }));
+ const follow = screen.getByRole("button", { name: "Follow cursor" });
+ expect(screen.getByRole("button", { name: "Whole" })).toHaveAttribute("aria-pressed", "true");
+ fireEvent.click(follow);
+ await waitFor(() => expect(stored()).toBe(true));
+ await waitFor(() => expect(follow).toHaveAttribute("aria-pressed", "true"));
+ });
+
+ it("fills a format picked from now on, and leaves an earlier project whole", async () => {
+ mount(hdTake({ aspectRatio: "16:9" }));
+ fireEvent.click(screen.getByRole("button", { name: "Format" }));
+ fireEvent.click(await screen.findByRole("menuitem", { name: "9:16" }));
+ await waitFor(() => expect(stored()).toBe(true));
+ cleanup();
+
+ mount(hdTake({ aspectRatio: "16:9", formatFollowCursor: false }));
+ fireEvent.click(screen.getByRole("button", { name: "Format" }));
+ fireEvent.click(await screen.findByRole("menuitem", { name: "9:16" }));
+ await waitFor(() =>
+ expect(
+ (useProjectStore.getState().document?.legacyEditor as Record<string, unknown>).aspectRatio,
+ ).toBe("9:16"),
+ );
+ expect(stored()).toBe(false);
+ });
+
+ it("is greyed out with the reason under a device frame", () => {
+ mount(hdTake({ aspectRatio: "9:16", frame: "laptop", formatFollowCursor: true }));
+ expect(screen.getByRole("button", { name: "Follow cursor" })).toBeDisabled();
+ expect(screen.getByText("Unavailable with a device frame.")).toBeInTheDocument();
+ });
+});
diff --git a/src/components/video-editor/projectPersistence.test.ts b/src/components/video-editor/projectPersistence.test.ts
index ef3f76f12..f976995b2 100644
--- a/src/components/video-editor/projectPersistence.test.ts
+++ b/src/components/video-editor/projectPersistence.test.ts
@@ -100,6 +100,12 @@ describe("projectPersistence media compatibility", () => {
});
});
+ it("passes the format fill choice through, and leaves it unset when absent", () => {
+ expect(normalizeProjectEditor({ formatFollowCursor: true }).formatFollowCursor).toBe(true);
+ expect(normalizeProjectEditor({ formatFollowCursor: false }).formatFollowCursor).toBe(false);
+ expect("formatFollowCursor" in normalizeProjectEditor({})).toBe(false);
+ });
+
it("omits cursor tuning keys that are absent or malformed", () => {
const editor = normalizeProjectEditor({
cursorSize: Number.NaN,
diff --git a/src/components/video-editor/projectPersistence.ts b/src/components/video-editor/projectPersistence.ts
index 69b17428e..3bef10b14 100644
--- a/src/components/video-editor/projectPersistence.ts
+++ b/src/components/video-editor/projectPersistence.ts
@@ -117,6 +117,7 @@ export interface ProjectEditorState {
// `getEditorSettings` splits them into a frame and a theme (`readRecordingFrame`).
frame?: RecordingFrame | "window-light" | "window-dark";
frameTheme?: FrameTheme;
+ formatFollowCursor?: boolean;
}
export interface EditorProjectData {
@@ -508,6 +509,9 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): Pro
: {}),
...(readRecordingFrame(editor.frame) ? { frame: editor.frame } : {}),
...(isFrameTheme(editor.frameTheme) ? { frameTheme: editor.frameTheme } : {}),
+ ...(typeof editor.formatFollowCursor === "boolean"
+ ? { formatFollowCursor: editor.formatFollowCursor }
+ : {}),
wallpaper:
typeof editor.wallpaper === "string"
? normalizeWallpaperValue(editor.wallpaper)
diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.json
index e213c16b6..c04b950d3 100644
--- a/src/i18n/locales/ar/settings.json
+++ b/src/i18n/locales/ar/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "مقطع واحد",
"formatAuto": "تلقائي",
"formatAutoMixed": "المقاطع مختلفة",
+ "formatFill": "التسجيل",
+ "formatFillFit": "كاملًا",
+ "formatFillFollow": "تتبّع المؤشر",
+ "formatFillHelp": "يملأ التنسيق بنافذة من التسجيل تتبع المؤشر.",
+ "formatFillMixed": "غير متاح: المقاطع بأشكال مختلفة.",
+ "formatFillLayout": "غير متاح: تخطيطا جنبًا إلى جنب والمكدّس يملآن موضعهما بالفعل.",
+ "formatFillFrame": "غير متاح مع إطار جهاز.",
"formatOriginal": "الأصلي",
"fitClipMany": "{{count}} مقاطع",
"frame": "الإطار",
diff --git a/src/i18n/locales/cs/settings.json b/src/i18n/locales/cs/settings.json
index e1c30a512..63421ec57 100644
--- a/src/i18n/locales/cs/settings.json
+++ b/src/i18n/locales/cs/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} klip",
"formatAuto": "Auto",
"formatAutoMixed": "Klipy se liší",
+ "formatFill": "Záznam",
+ "formatFillFit": "Celý",
+ "formatFillFollow": "Sledovat kurzor",
+ "formatFillHelp": "Vyplní formát výřezem záznamu, který sleduje kurzor.",
+ "formatFillMixed": "Nedostupné: klipy mají různé tvary.",
+ "formatFillLayout": "Nedostupné: rozložení vedle sebe a nad sebou už své místo vyplňují.",
+ "formatFillFrame": "Nedostupné s rámečkem zařízení.",
"formatOriginal": "Původní",
"fitClipMany": "{{count}} klipů",
"frame": "Rám",
diff --git a/src/i18n/locales/de/settings.json b/src/i18n/locales/de/settings.json
index 2d2d0c8ba..41b6f402c 100644
--- a/src/i18n/locales/de/settings.json
+++ b/src/i18n/locales/de/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} Clip",
"formatAuto": "Auto",
"formatAutoMixed": "Clips unterschiedlich",
+ "formatFill": "Aufnahme",
+ "formatFillFit": "Ganz",
+ "formatFillFollow": "Cursor folgen",
+ "formatFillHelp": "Füllt das Format mit einem Ausschnitt der Aufnahme, der dem Cursor folgt.",
+ "formatFillMixed": "Nicht verfügbar: Die Clips haben unterschiedliche Formen.",
+ "formatFillLayout": "Nicht verfügbar: Die Layouts nebeneinander und gestapelt füllen ihren Platz bereits.",
+ "formatFillFrame": "Mit einem Geräterahmen nicht verfügbar.",
"formatOriginal": "Original",
"fitClipMany": "{{count}} Clips",
"frame": "Rahmen",
diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.json
index 66e0e3d6e..108ba025b 100644
--- a/src/i18n/locales/en/settings.json
+++ b/src/i18n/locales/en/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} clip",
"formatAuto": "Auto",
"formatAutoMixed": "Clips differ",
+ "formatFill": "Recording",
+ "formatFillFit": "Whole",
+ "formatFillFollow": "Follow cursor",
+ "formatFillHelp": "Fills the format with a window of the recording that follows the cursor.",
+ "formatFillMixed": "Unavailable: the clips have different shapes.",
+ "formatFillLayout": "Unavailable: the side-by-side and stacked layouts already fill their slot.",
+ "formatFillFrame": "Unavailable with a device frame.",
"formatOriginal": "Original",
"fitClipMany": "{{count}} clips",
"frame": "Frame",
diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.json
index 112bea29a..f139d1aa4 100644
--- a/src/i18n/locales/es/settings.json
+++ b/src/i18n/locales/es/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} clip",
"formatAuto": "Auto",
"formatAutoMixed": "Clips distintos",
+ "formatFill": "Grabación",
+ "formatFillFit": "Completa",
+ "formatFillFollow": "Seguir el cursor",
+ "formatFillHelp": "Llena el formato con una ventana de la grabación que sigue al cursor.",
+ "formatFillMixed": "No disponible: los clips tienen formas distintas.",
+ "formatFillLayout": "No disponible: los diseños lado a lado y apilado ya llenan su espacio.",
+ "formatFillFrame": "No disponible con un marco de dispositivo.",
"formatOriginal": "Original",
"fitClipMany": "{{count}} clips",
"frame": "Marco",
diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.json
index 1cab573a1..527c77073 100644
--- a/src/i18n/locales/fr/settings.json
+++ b/src/i18n/locales/fr/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} clip",
"formatAuto": "Auto",
"formatAutoMixed": "Clips différents",
+ "formatFill": "Enregistrement",
+ "formatFillFit": "En entier",
+ "formatFillFollow": "Suivre le curseur",
+ "formatFillHelp": "Remplit le format avec une fenêtre de l'enregistrement qui suit le curseur.",
+ "formatFillMixed": "Indisponible : les clips n'ont pas la même forme.",
+ "formatFillLayout": "Indisponible : les dispositions côte à côte et empilée remplissent déjà leur emplacement.",
+ "formatFillFrame": "Indisponible avec un cadre d'appareil.",
"formatOriginal": "Original",
"fitClipMany": "{{count}} clips",
"frame": "Cadre",
diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.json
index 10a55f8a6..a987c6079 100644
--- a/src/i18n/locales/it/settings.json
+++ b/src/i18n/locales/it/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} clip",
"formatAuto": "Auto",
"formatAutoMixed": "Clip diversi",
+ "formatFill": "Registrazione",
+ "formatFillFit": "Intera",
+ "formatFillFollow": "Segui il cursore",
+ "formatFillHelp": "Riempie il formato con una finestra della registrazione che segue il cursore.",
+ "formatFillMixed": "Non disponibile: le clip hanno forme diverse.",
+ "formatFillLayout": "Non disponibile: i layout affiancato e impilato riempiono già il loro spazio.",
+ "formatFillFrame": "Non disponibile con una cornice dispositivo.",
"formatOriginal": "Originale",
"fitClipMany": "{{count}} clip",
"frame": "Cornice",
diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.json
index c57ac7506..09a2e9624 100644
--- a/src/i18n/locales/ja-JP/settings.json
+++ b/src/i18n/locales/ja-JP/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} クリップ",
"formatAuto": "自動",
"formatAutoMixed": "クリップが不揃い",
+ "formatFill": "録画",
+ "formatFillFit": "全体",
+ "formatFillFollow": "カーソルを追う",
+ "formatFillHelp": "カーソルを追う録画の一部でフォーマットを埋めます。",
+ "formatFillMixed": "利用不可:クリップの形が異なります。",
+ "formatFillLayout": "利用不可:横並びと縦積みのレイアウトはすでに枠を埋めています。",
+ "formatFillFrame": "デバイスフレームとは併用できません。",
"formatOriginal": "元のサイズ",
"fitClipMany": "{{count}} クリップ",
"frame": "フレーム",
diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.json
index 4daf28e3a..f23459804 100644
--- a/src/i18n/locales/ko-KR/settings.json
+++ b/src/i18n/locales/ko-KR/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}}개 클립",
"formatAuto": "자동",
"formatAutoMixed": "클립이 서로 다름",
+ "formatFill": "녹화",
+ "formatFillFit": "전체",
+ "formatFillFollow": "커서 따라가기",
+ "formatFillHelp": "커서를 따라가는 녹화 창으로 포맷을 채웁니다.",
+ "formatFillMixed": "사용할 수 없음: 클립의 모양이 서로 다릅니다.",
+ "formatFillLayout": "사용할 수 없음: 나란히 및 위아래 레이아웃은 이미 자리를 채웁니다.",
+ "formatFillFrame": "기기 프레임과 함께 사용할 수 없습니다.",
"formatOriginal": "원본",
"fitClipMany": "{{count}}개 클립",
"frame": "프레임",
diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.json
index be298cd21..d003a943b 100644
--- a/src/i18n/locales/pt-BR/settings.json
+++ b/src/i18n/locales/pt-BR/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} clipe",
"formatAuto": "Auto",
"formatAutoMixed": "Clipes diferentes",
+ "formatFill": "Gravação",
+ "formatFillFit": "Inteira",
+ "formatFillFollow": "Seguir o cursor",
+ "formatFillHelp": "Preenche o formato com uma janela da gravação que segue o cursor.",
+ "formatFillMixed": "Indisponível: os clipes têm formatos diferentes.",
+ "formatFillLayout": "Indisponível: os layouts lado a lado e empilhado já preenchem seu espaço.",
+ "formatFillFrame": "Indisponível com uma moldura de dispositivo.",
"formatOriginal": "Original",
"fitClipMany": "{{count}} clipes",
"frame": "Moldura",
diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.json
index 726225aaf..284622846 100644
--- a/src/i18n/locales/ru/settings.json
+++ b/src/i18n/locales/ru/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} клип",
"formatAuto": "Авто",
"formatAutoMixed": "Клипы различаются",
+ "formatFill": "Запись",
+ "formatFillFit": "Целиком",
+ "formatFillFollow": "Следовать за курсором",
+ "formatFillHelp": "Заполняет формат окном записи, которое следует за курсором.",
+ "formatFillMixed": "Недоступно: у клипов разная форма.",
+ "formatFillLayout": "Недоступно: макеты «рядом» и «друг над другом» уже заполняют своё место.",
+ "formatFillFrame": "Недоступно с рамкой устройства.",
"formatOriginal": "Исходный",
"fitClipMany": "{{count}} клипов",
"frame": "Рамка",
diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.json
index d4c56a70a..af4dd0e7c 100644
--- a/src/i18n/locales/tr/settings.json
+++ b/src/i18n/locales/tr/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} klip",
"formatAuto": "Otomatik",
"formatAutoMixed": "Klipler farklı",
+ "formatFill": "Kayıt",
+ "formatFillFit": "Tamamı",
+ "formatFillFollow": "İmleci takip et",
+ "formatFillHelp": "Formatı, imleci takip eden bir kayıt penceresiyle doldurur.",
+ "formatFillMixed": "Kullanılamaz: klipler farklı biçimlerde.",
+ "formatFillLayout": "Kullanılamaz: yan yana ve üst üste düzenler zaten kendi alanlarını dolduruyor.",
+ "formatFillFrame": "Cihaz çerçevesiyle kullanılamaz.",
"formatOriginal": "Orijinal",
"fitClipMany": "{{count}} klip",
"frame": "Çerçeve",
diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.json
index d676471c2..8f8f9e71d 100644
--- a/src/i18n/locales/vi/settings.json
+++ b/src/i18n/locales/vi/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} clip",
"formatAuto": "Tự động",
"formatAutoMixed": "Các clip khác nhau",
+ "formatFill": "Bản ghi",
+ "formatFillFit": "Toàn bộ",
+ "formatFillFollow": "Theo con trỏ",
+ "formatFillHelp": "Lấp đầy định dạng bằng một khung của bản ghi đi theo con trỏ.",
+ "formatFillMixed": "Không khả dụng: các clip có hình dạng khác nhau.",
+ "formatFillLayout": "Không khả dụng: bố cục cạnh nhau và xếp chồng đã lấp đầy vị trí của chúng.",
+ "formatFillFrame": "Không khả dụng khi có khung thiết bị.",
"formatOriginal": "Gốc",
"fitClipMany": "{{count}} clip",
"frame": "Khung",
diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.json
index 343240e48..0c80edd76 100644
--- a/src/i18n/locales/zh-CN/settings.json
+++ b/src/i18n/locales/zh-CN/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} 个片段",
"formatAuto": "自动",
"formatAutoMixed": "片段不一致",
+ "formatFill": "录制内容",
+ "formatFillFit": "完整",
+ "formatFillFollow": "跟随光标",
+ "formatFillHelp": "用跟随光标的录制窗口填满画面比例。",
+ "formatFillMixed": "不可用:片段形状不一致。",
+ "formatFillLayout": "不可用:并排和上下布局已填满各自的位置。",
+ "formatFillFrame": "使用设备边框时不可用。",
"formatOriginal": "原始",
"fitClipMany": "{{count}} 个片段",
"frame": "画框",
diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.json
index a9bfe2a76..a8284ffaa 100644
--- a/src/i18n/locales/zh-TW/settings.json
+++ b/src/i18n/locales/zh-TW/settings.json
@@ -109,6 +109,13 @@
"fitClipOne": "{{count}} 個片段",
"formatAuto": "自動",
"formatAutoMixed": "片段不一致",
+ "formatFill": "錄製內容",
+ "formatFillFit": "完整",
+ "formatFillFollow": "跟隨游標",
+ "formatFillHelp": "以跟隨游標的錄製視窗填滿畫面比例。",
+ "formatFillMixed": "無法使用:片段形狀不一致。",
+ "formatFillLayout": "無法使用:並排與上下版面已填滿各自的位置。",
+ "formatFillFrame": "使用裝置邊框時無法使用。",
"formatOriginal": "原始",
"fitClipMany": "{{count}} 個片段",
"frame": "外框",
diff --git a/src/lib/ai-edition/document/outputFormat.test.ts b/src/lib/ai-edition/document/outputFormat.test.ts
index 61aa52b04..06f4faeb7 100644
--- a/src/lib/ai-edition/document/outputFormat.test.ts
+++ b/src/lib/ai-edition/document/outputFormat.test.ts
@@ -13,7 +13,9 @@ import {
import {
collectEffectiveClipDims,
collectNativeFormats,
+ formatFillAvailability,
isAutoFormatAvailable,
+ isFormatFillActive,
pickOutputDims,
referenceClipDims,
resolveAspectRatioValue,
@@ -419,3 +421,43 @@ describe("Auto", () => {
expect(resolveAspectRatioValue(null, "auto")).toBeCloseTo(16 / 9, 6);
});
});
+
+describe("formatFillAvailability", () => {
+ const at = (d: AxcutDocument, editor: Record<string, unknown>): AxcutDocument => ({
+ ...d,
+ legacyEditor: { aspectRatio: "9:16", ...editor },
+ });
+ const hd = doc([asset("a1", 1920, 1080)], [clip("c1", "a1")]);
+
+ it("is only offered when a fixed format differs from the recording", () => {
+ expect(formatFillAvailability(at(hd, {}))).toBe("available");
+ expect(formatFillAvailability(at(hd, { aspectRatio: "16:9" }))).toBe("none");
+ expect(formatFillAvailability(at(hd, { aspectRatio: "auto" }))).toBe("none");
+ // 1366×768 is 16:9 to within 0.1 %: nothing worth a window.
+ const laptop = doc([asset("a1", 1366, 768)], [clip("c1", "a1")]);
+ expect(formatFillAvailability(at(laptop, { aspectRatio: "16:9" }))).toBe("none");
+ });
+
+ it("says why it is unavailable instead of picking a clip", () => {
+ const mixed = doc(
+ [asset("wide", 1920, 1080), asset("mac", 1440, 900)],
+ [clip("c1", "wide"), clip("c2", "mac")],
+ );
+ expect(formatFillAvailability(at(mixed, {}))).toBe("mixed");
+ const camera = { sourcePath: "/c.mp4", startMs: 0, offsetMs: 0, visible: true };
+ const cam = doc([{ ...asset("a1", 1920, 1080), cameraTrack: camera }], [clip("c1", "a1")]);
+ expect(formatFillAvailability(at(cam, { webcamLayoutPreset: "vertical-stack" }))).toBe(
+ "layout",
+ );
+ expect(formatFillAvailability(at(cam, { webcamLayoutPreset: "picture-in-picture" }))).toBe(
+ "available",
+ );
+ expect(formatFillAvailability(at(hd, { frame: "laptop" }))).toBe("frame");
+ });
+
+ it("is drawn only when asked for and available", () => {
+ expect(isFormatFillActive(at(hd, {}))).toBe(false);
+ expect(isFormatFillActive(at(hd, { formatFollowCursor: true }))).toBe(true);
+ expect(isFormatFillActive(at(hd, { formatFollowCursor: true, frame: "phone" }))).toBe(false);
+ });
+});
diff --git a/src/lib/ai-edition/document/outputFormat.ts b/src/lib/ai-edition/document/outputFormat.ts
index a2726d8af..d4b660de9 100644
--- a/src/lib/ai-edition/document/outputFormat.ts
+++ b/src/lib/ai-edition/document/outputFormat.ts
@@ -16,6 +16,7 @@
import {
autoFrameAspect,
+ getWebcamLayoutPresetDefinition,
resolveWebcamLayoutPreset,
restingCompositionAspect,
type WebcamLayoutPreset,
@@ -216,6 +217,57 @@ export function isAutoFormatAvailable(
return compositions.size <= 1;
}
+/**
+ * Whether the format can be filled with a window that follows the cursor, and if not, why.
+ *
+ * - `"none"`: nothing to fill. The format is Auto or has the recording's own shape, so the
+ * recording already fills it; the option is not shown.
+ * - `"mixed"`: clips differ in shape, crop included. One window rule cannot suit them all.
+ * - `"layout"`: a side-by-side or stacked camera layout already fills its own slot.
+ * - `"frame"`: a device frame is drawn around the whole recording.
+ * - `"available"`: one shape, not the format's, alone in its frame.
+ */
+export type FormatFillAvailability = "none" | "mixed" | "layout" | "frame" | "available";
+
+export function formatFillAvailability(
+ document: AxcutDocument,
+ probedAssetDims: Record<string, Dims> = {},
+): FormatFillAvailability {
+ const settings = getEditorSettings(document);
+ if (settings.aspectRatio === "auto" || settings.aspectRatio === "native") return "none";
+ const assetById = new Map(document.assets.map((a) => [a.id, a]));
+ const shapes = new Set<string>();
+ let blockLayout = false;
+ for (const clip of document.timeline.clips) {
+ const dims = clipEffectiveDims(clip, assetById, probedAssetDims);
+ if (!dims) continue;
+ shapes.add(toAspectRatioToken(dims.width, dims.height) ?? "");
+ const preset = clipLayoutPreset(clip, document.assets, settings.webcamLayoutPreset);
+ blockLayout ||= getWebcamLayoutPresetDefinition(preset).transform.type === "block";
+ }
+ if (shapes.size > 1) return "mixed";
+ const [shape] = shapes;
+ // Within 1 %: a 1366×768 take is 16:9 to the eye, and a window would crop 3 px of it.
+ const format = getAspectRatioValue(settings.aspectRatio);
+ if (!shape || Math.abs(getAspectRatioValue(shape as AspectRatio) / format - 1) < 0.01) {
+ return "none";
+ }
+ if (blockLayout) return "layout";
+ if (settings.frame !== "none") return "frame";
+ return "available";
+}
+
+/** The fill is drawn: the user asked for it and the timeline allows it. */
+export function isFormatFillActive(
+ document: AxcutDocument,
+ probedAssetDims: Record<string, Dims> = {},
+): boolean {
+ return (
+ getEditorSettings(document).formatFollowCursor === true &&
+ formatFillAvailability(document, probedAssetDims) === "available"
+ );
+}
+
/**
* The clip that opens the timeline, among those whose dimensions are known: where Auto reads
* the composition it frames.
diff --git a/src/lib/ai-edition/store/editorSettings.ts b/src/lib/ai-edition/store/editorSettings.ts
index 9329eae52..dd5f14d69 100644
--- a/src/lib/ai-edition/store/editorSettings.ts
+++ b/src/lib/ai-edition/store/editorSettings.ts
@@ -93,6 +93,13 @@ export interface EditorSettingsSnapshot {
/** Light or dark, for whichever frame is on. Inert with `frame: "none"`. */
frameTheme: FrameTheme;
aspectRatio: AspectRatio;
+ /**
+ * Under a fixed format that is not the recording's shape: fill the frame with a window of
+ * the recording that follows the smoothed cursor (true), or show it whole (false). `null`
+ * until the user picks a format or this option: projects from before it keep showing the
+ * recording whole. See `formatFillAvailability`.
+ */
+ formatFollowCursor: boolean | null;
shadowIntensity: number;
showBlur: boolean;
motionBlurAmount: number;
@@ -136,6 +143,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettingsSnapshot = {
webcamCropRegion: DEFAULT_CROP_REGION,
webcamCropPan: DEFAULT_CROP_PAN,
audioGainDb: 0,
+ formatFollowCursor: null,
};
interface LegacyShape {
@@ -145,6 +153,7 @@ interface LegacyShape {
frame?: unknown;
frameTheme?: FrameTheme;
aspectRatio?: AspectRatio;
+ formatFollowCursor?: boolean;
shadowIntensity?: number;
showBlur?: boolean;
motionBlurAmount?: number;
@@ -248,6 +257,8 @@ export function getEditorSettings(doc: AxcutDocument | null | undefined): Editor
? legacy.frameTheme
: (stored?.theme ?? DEFAULT_EDITOR_SETTINGS.frameTheme),
aspectRatio: legacy?.aspectRatio ?? DEFAULT_EDITOR_SETTINGS.aspectRatio,
+ formatFollowCursor:
+ typeof legacy?.formatFollowCursor === "boolean" ? legacy.formatFollowCursor : null,
// Every number below is read into its `SETTING_BOUNDS` range: the slider's range, and the
// one a preset and the agent are held to. A stored value past it plays at the bound.
shadowIntensity: readBounded(
@@ -315,6 +326,7 @@ export interface EditorSettingsPatch {
frame?: RecordingFrame;
frameTheme?: FrameTheme;
aspectRatio?: AspectRatio;
+ formatFollowCursor?: boolean;
shadowIntensity?: number;
showBlur?: boolean;
motionBlurAmount?: number;
diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.ts
index 4610b011f..a175d636b 100644
--- a/src/native/sceneDescription.test.ts
+++ b/src/native/sceneDescription.test.ts
@@ -1150,6 +1150,55 @@ describe("buildSceneDescription.audio", () => {
// --- settings mapping ------------------------------------------------------
+describe("buildSceneDescription format fill", () => {
+ const doc = (editor: Record<string, unknown>) =>
+ makeDoc({
+ assets: [
+ makeAsset({
+ id: "a",
+ originalPath: "/a.mp4",
+ durationSec: 5,
+ video: { codec: "h264", width: 1920, height: 1080, fps: 30 },
+ }),
+ ],
+ clips: [
+ makeClip({
+ id: "c1",
+ assetId: "a",
+ sourceStartSec: 0,
+ sourceEndSec: 5,
+ timelineStartSec: 0,
+ timelineEndSec: 5,
+ }),
+ ],
+ legacyEditor: { aspectRatio: "9:16", padding: 50, ...editor },
+ });
+
+ it("gives a 16:9 take the whole padded 9:16 area, covered and following the cursor", () => {
+ const { layout } = buildSceneDescription(doc({ formatFollowCursor: true }));
+ const zone = { x: 0.1, y: 0.1, width: 0.8, height: 0.8 };
+ for (const rect of [layout.screenRect, layout.layoutByClip?.[0]?.screenRect]) {
+ expect(rect?.x).toBeCloseTo(zone.x, 3);
+ expect(rect?.y).toBeCloseTo(zone.y, 3);
+ expect(rect?.width).toBeCloseTo(zone.width, 3);
+ expect(rect?.height).toBeCloseTo(zone.height, 3);
+ }
+ expect(layout.screenCover).toBe(true);
+ expect(layout.layoutByClip?.[0]?.screenCover).toBe(true);
+ expect(layout.screenFollow).toBe(true);
+ });
+
+ it("keeps the recording whole, and the payload unchanged, when not asked for", () => {
+ for (const editor of [{}, { formatFollowCursor: false }]) {
+ const { layout } = buildSceneDescription(doc(editor));
+ // The 16:9 band inside the 9:16 frame: 864×486 of 1080×1920.
+ expect(layout.screenRect?.height).toBeCloseTo(486 / 1920, 3);
+ expect(layout.screenCover).toBe(false);
+ expect("screenFollow" in layout).toBe(false);
+ }
+ });
+});
+
describe("buildSceneDescription.settings mapping", () => {
it("divides padding by 100", () => {
const doc = makeDoc({ legacyEditor: { padding: 50 } });
diff --git a/src/native/sceneDescription.ts b/src/native/sceneDescription.ts
index 9094a616f..3317949dd 100644
--- a/src/native/sceneDescription.ts
+++ b/src/native/sceneDescription.ts
@@ -32,7 +32,7 @@ import {
} from "@/lib/ai-edition/captions";
import { collapseTracksToPills, trackGroupId } from "@/lib/ai-edition/document/audioTracks";
import { createId } from "@/lib/ai-edition/document/ids";
-import { pickOutputDims } from "@/lib/ai-edition/document/outputFormat";
+import { isFormatFillActive, pickOutputDims } from "@/lib/ai-edition/document/outputFormat";
import {
type PlaybackSegment,
projectRawTimelineSecToPlayback,
@@ -316,6 +316,12 @@ export interface SceneLayout {
* spilling over the camera (`ScreenMask` in `frame_geometry.rs`).
*/
screenCover?: boolean;
+ /**
+ * The format is filled (`isFormatFillActive`): the screen box is the whole padded area,
+ * `screenCover` is on, and the window the cover cuts out follows the smoothed cursor
+ * instead of staying centred. Omitted when off, so other payloads are unchanged.
+ */
+ screenFollow?: true;
/**
* One resolved layout per visible clip, index-aligned with `SceneDescription.clips`
* and `cropByClip`. The scalar fields above are the FIRST clip's entry (fallback for
@@ -1003,6 +1009,7 @@ export function buildSceneDescription(
// padded content area the preview uses — `compositor.rs` consumes an app-provided
// `webcamRect` verbatim (it only scale_frame's the SCREEN by padding), so an
// unpadded rect here would leave the camera behind while the screen moved.
+ const formatFill = isFormatFillActive(document);
const maxContentSize = paddedContentSize(
outputDims,
settings.padding,
@@ -1078,7 +1085,8 @@ export function buildSceneDescription(
return computeCompositeLayout({
canvasSize: outputDims,
maxContentSize,
- screenSize,
+ // Filled, the screen takes the whole padded area; the compositor cuts the window.
+ screenSize: formatFill ? maxContentSize : screenSize,
webcamSize: preset === "no-webcam" ? null : camSize,
layoutPreset: preset,
webcamSizePreset: settings.webcamSizePreset,
@@ -1109,7 +1117,7 @@ export function buildSceneDescription(
screenRadiusFrac: radiusFractionOf(layout.screenRect, layout.screenBorderRadius),
webcamRadiusFrac: radiusFractionOf(layout.webcamRect, layout.webcamRect?.borderRadius),
webcamShape: layout.webcamRect?.maskShape ?? settings.webcamMaskShape,
- screenCover: layout.screenCover ?? false,
+ screenCover: formatFill || (layout.screenCover ?? false),
}
: null;
// One resolved layout per visible clip, index-aligned with `clips` / `cropByClip`.
@@ -1172,7 +1180,8 @@ export function buildSceneDescription(
computedLayout?.screenRect,
computedLayout?.screenBorderRadius,
),
- screenCover: computedLayout?.screenCover ?? false,
+ screenCover: formatFill || (computedLayout?.screenCover ?? false),
+ ...(formatFill ? { screenFollow: true as const } : {}),
webcamRadiusFrac: radiusFractionOf(
computedLayout?.webcamRect,
computedLayout?.webcamRect?.borderRadius,