Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Faceless: Frame by frame is a real Ken Burns, and music beds loop past what the model makes

Claude9973d8ccb7dd
diff --git a/src/components/explainer/explainer-studio.tsx b/src/components/explainer/explainer-studio.tsx
index 4ae6344c..586090f3 100644
--- a/src/components/explainer/explainer-studio.tsx
+++ b/src/components/explainer/explainer-studio.tsx
@@ -27,6 +27,7 @@ import {
getStyle,
MAX_SOURCES,
MAX_TOPIC,
+ MUSIC_HINT,
type EpisodeSettings,
type ExplainerSource,
type PickerData,
@@ -344,7 +345,7 @@ export function ExplainerStudio({ picker }: { picker: PickerData }) {
return engine === "open" ? m?.openCopy : m?.copy;
})()}</p>
</div>
- <ToggleRow label="Background music" hint={engine === "cloud" ? "A Sonilo instrumental bed under the voice, as long as the film" : "An ACE-Step instrumental bed (up to 4 minutes)"} checked={settings.music} onChange={(music) => set({ music })} />
+ <ToggleRow label="Background music" hint={MUSIC_HINT[engine]} checked={settings.music} onChange={(music) => set({ music })} />
<ToggleRow label="Review the script first" hint="Edit the scenes before anything renders" checked={review} onChange={setReview} />
</PopoverContent>
</Popover>
diff --git a/src/components/faceless/settings-form.tsx b/src/components/faceless/settings-form.tsx
index 21f6480a..72200254 100644
--- a/src/components/faceless/settings-form.tsx
+++ b/src/components/faceless/settings-form.tsx
@@ -13,6 +13,7 @@ import {
ENGINE_MODELS,
FACELESS_LENGTHS,
MAX_STYLE_REFS,
+ MUSIC_HINT,
type EpisodeSettings,
type PickerData,
} from "@/lib/catalog/faceless";
@@ -126,8 +127,11 @@ export function EpisodeSettingsForm({
}) {
const [own, setOwn] = useState(value.styleRefs.length > 0);
const maxRefs = picker.maxStyleRefs?.[value.engine] ?? MAX_STYLE_REFS;
- const videos = picker.videoModels.filter((m) => m.engine === value.engine);
- const video = videos.find((m) => m.id === value.videoModel) ?? videos.find((m) => m.id === ENGINE_MODELS[value.engine].video) ?? videos[0];
+ // Frame by frame moves a camera over each picture (Ken Burns, no video model); Fully animated picks a video model.
+ const frames = value.animation === "frames";
+ const camera = picker.cameraMoves?.[value.engine];
+ const videos = frames ? [] : picker.videoModels.filter((m) => m.engine === value.engine);
+ const video = frames ? (camera && { ...camera, engine: value.engine }) : (videos.find((m) => m.id === value.videoModel) ?? videos.find((m) => m.id === ENGINE_MODELS[value.engine].video) ?? videos[0]);
const resolution = value.resolution && video?.resolutions.includes(value.resolution) ? value.resolution : (DEFAULT_RESOLUTION[video?.id ?? ""]?.[value.animation] ?? video?.resolutions[0]);
return (
<div className="space-y-7">
@@ -181,12 +185,7 @@ export function EpisodeSettingsForm({
</div>
<div className="grid gap-3 rounded-xl border p-3 sm:grid-cols-2">
<ToggleRow label="Subtitles" hint="Burned into the video, timed to the voice" checked={value.subtitles} onChange={(subtitles) => onChange({ subtitles })} />
- <ToggleRow
- label="Background music"
- hint={value.engine === "cloud" ? "An instrumental bed under the voice, as long as the film (Sonilo)" : "An instrumental bed under the voice (ACE-Step, up to 4 minutes)"}
- checked={value.music}
- onChange={(music) => onChange({ music })}
- />
+ <ToggleRow label="Background music" hint={MUSIC_HINT[value.engine]} checked={value.music} onChange={(music) => onChange({ music })} />
</div>
</Section>
@@ -237,14 +236,14 @@ export function EpisodeSettingsForm({
</Section>
)}
{video && video.resolutions.length > 1 && (
- <Section title="Quality" hint={value.animation === "frames" ? "Frame by frame renders at a lower quality to keep it light; raise it here." : undefined}>
+ <Section title="Quality" hint={frames ? "The size the camera moves render at: no model runs, larger sizes take longer and more memory." : undefined}>
<Segmented label="Quality" value={resolution ?? ""} options={video.resolutions.map((r) => ({ value: r, label: r }))} onChange={(r) => onChange({ resolution: r })} />
</Section>
)}
<p className="text-[12px] text-muted-foreground">
{value.engine === "cloud"
- ? `Pictures: Nano Banana Pro · Video: ${video?.name ?? "Gemini Omni Flash"} · Voice: ElevenLabs v4 (Chatterbox for your own voice), timed word by word by ElevenLabs forced alignment · Music: Sonilo · Subtitles: Auto Subtitle`
- : "Pictures: Z-Image Turbo (Qwen-Image-Edit with your images) · Video: Wan 2.2 Lightning · Voice: Chatterbox, timed by Qwen3-ASR · Music: ACE-Step · Subtitles: Qwen3-ASR + burn-in"}
+ ? `Pictures: Nano Banana Pro · ${frames ? "Camera: Ken Burns zoom (fal), no video model" : `Video: ${video?.name ?? "Gemini Omni Flash"}`} · Voice: ElevenLabs v4 (Chatterbox for your own voice), timed word by word by ElevenLabs forced alignment · Music: Sonilo · Subtitles: Auto Subtitle`
+ : `Pictures: Z-Image Turbo (Qwen-Image-Edit with your images) · ${frames ? "Camera: Ken Burns pan and zoom, scenes over 10 s in pieces" : "Video: Wan 2.2 Lightning"} · Voice: Chatterbox, timed by Qwen3-ASR · Music: ACE-Step, looped past 4 minutes · Subtitles: Qwen3-ASR + burn-in`}
{" "}Each scene is cut to where its lines are spoken.
</p>
</CollapsibleContent>
diff --git a/src/lib/av/ken-burns.ts b/src/lib/av/ken-burns.ts
new file mode 100644
index 00000000..bec1e263
--- /dev/null
+++ b/src/lib/av/ken-burns.ts
@@ -0,0 +1,189 @@
+import type { FocusPoint } from "@/lib/catalog/types";
+
+/**
+ * Ken Burns moves over a still (Faceless / Explainer "Frame by frame"): a slow zoom and pan, planned per scene
+ * and sent as params.zoomFrom / zoomTo, panFrom / panTo and easing (op still-motion).
+ *
+ * - Open engine (kenburns-still): a real zoom and pan. The crop centre is a fraction of the still, kept where
+ * the crop stays inside it, at most 10 s per job: longer scenes are split into pieces that continue the
+ * same move (linear, so the speed doesn't dip at a seam) and joined.
+ * - Cloud (fal workflow-utilities image-to-video): a zoom only, which always starts (zooming in) or ends
+ * (zooming out) on the whole picture, toward a focal point. Pans become a zoom toward the side they head
+ * for, and scenes alternate in and out.
+ *
+ * Which move: the scene's motion words when they name one ("zoom out to reveal…", "pan left across…"), else
+ * the next in a cycle; where it heads: the place the words name ("towards the tower on the left"), else
+ * one of a few focal points near the thirds. Plain data (docs/research/comfyui-oss-4.md §d presets).
+ */
+
+export type MoveKind = "push-in" | "pull-out" | "pan-left" | "pan-right" | "tilt-up" | "tilt-down";
+
+export interface KenBurnsMove {
+ kind: MoveKind;
+ /** 1 = the whole picture (the widest crop with the output's shape), 1.2 = 20 % closer. */
+ zoomFrom: number;
+ zoomTo: number;
+ /** The crop's centre at the start and the end (0–1 of the still). */
+ panFrom: FocusPoint;
+ panTo: FocusPoint;
+ easing: "linear" | "ease-in-out";
+}
+
+/** The moves scenes take in turn when their words name none: zoom and pan on the open engine… */
+export const OPEN_CYCLE: MoveKind[] = ["push-in", "pan-right", "pull-out", "tilt-up", "pan-left", "push-in", "tilt-down", "pull-out"];
+/** …in and out on the cloud. */
+export const CLOUD_CYCLE: MoveKind[] = ["push-in", "pull-out"];
+
+/** Where a move heads when the words place nothing: near the thirds, a little above the middle (where faces and subjects sit). */
+export const FOCI: FocusPoint[] = [
+ { x: 0.5, y: 0.42 },
+ { x: 0.36, y: 0.44 },
+ { x: 0.64, y: 0.44 },
+ { x: 0.44, y: 0.58 },
+ { x: 0.58, y: 0.38 },
+];
+
+const CENTRE: FocusPoint = { x: 0.5, y: 0.5 };
+const clamp = (n: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, n));
+const r3 = (n: number) => Math.round(n * 1000) / 1000;
+// Rounded toward the middle, so a point at the edge of the room stays inside it.
+const inward = (v: number, k: number) => (v > 0.5 ? Math.floor(v * k + 1e-6) : Math.ceil(v * k - 1e-6)) / k;
+/** Three decimals for a whole move; five for the pieces of a split one (a frame's step is well under 0.001). */
+const pt = (p: FocusPoint, k = 1000): FocusPoint => ({ x: inward(p.x, k), y: inward(p.y, k) });
+
+/** The move the words ask for, if any. */
+export function readMove(text: string): MoveKind | null {
+ const t = ` ${text.toLowerCase()} `;
+ // Camera words only: "smoke rising" is not a tilt.
+ if (/\b(zoom(s|ing)? out|pull(s|ing)?[- ](back|out|away)|dolly(ing)? out|widen(s|ing)?|reveal(s|ing)?|draw(s|ing)? back)\b/.test(t)) return "pull-out";
+ if (/\b(zoom(s|ing)? in|push(es|ing)?[- ]in|push(es|ing)? (slowly |gently )?(towards?|closer|into)|dolly(ing)? in|clos(e|es|ing) in|(camera|it) moves? (in|closer))\b/.test(t)) return "push-in";
+ if (/\bpan(s|ning)? (slowly |gently )?(to the |towards? the )?left\b|\bright[- ]to[- ]left\b|\bleftwards?\b/.test(t)) return "pan-left";
+ if (/\bpan(s|ning)? (slowly |gently )?(to the |towards? the )?right\b|\bleft[- ]to[- ]right\b|\brightwards?\b/.test(t)) return "pan-right";
+ if (/\b(tilt(s|ing)?|crane(s|ing)?|pan(s|ning)?) (slowly |gently )?up(wards?)?\b|\bcamera (rises|rising|moves up)\b/.test(t)) return "tilt-up";
+ if (/\b(tilt(s|ing)?|crane(s|ing)?|pan(s|ning)?) (slowly |gently )?down(wards?)?\b|\bcamera (descends|descending|moves down)\b/.test(t)) return "tilt-down";
+ if (/\b(pan(s|ning)?|tracking shot|track(s|ing)? across)\b/.test(t)) return "pan-right";
+ return null;
+}
+
+/**
+ * A place the words name ("on the left", "the upper right corner", "the sky", "in the foreground"), as a
+ * focal point; null when they name none. "Left" alone is not a place ("the army left the city").
+ */
+export function focusFromText(text: string): FocusPoint | null {
+ const t = ` ${text.toLowerCase()} `;
+ const side = /\b(the |its |far )(upper |lower |top |bottom |far )?(left|right)\b|\b(upper|lower|top|bottom)[- ](left|right)\b|\b(left|right)(-hand)? (side|corner|edge|half)\b/.exec(t);
+ const word = side?.[0].includes("left") ? "left" : side?.[0].includes("right") ? "right" : null;
+ const up = /\b(upper|top|the sky|skies|overhead|above|ceiling|treetops|rooftops?|mountaintop|summit)\b/.test(t);
+ const down = /\b(lower|bottom|the ground|the floor|foreground|below|underground|at (his|her|their) feet)\b/.test(t);
+ if (!word && up === down) return null;
+ return { x: word === "left" ? 0.33 : word === "right" ? 0.67 : 0.5, y: up && !down ? 0.34 : down && !up ? 0.64 : 0.45 };
+}
+
+/** How far a crop centre can move from the middle at a zoom (the crop must stay inside the still). */
+const room = (zoom: number) => Math.max(0, 0.5 - 0.5 / zoom);
+const inside = (p: FocusPoint, zoom: number): FocusPoint => {
+ const r = room(zoom);
+ return pt({ x: clamp(p.x, 0.5 - r, 0.5 + r), y: clamp(p.y, 0.5 - r, 0.5 + r) });
+};
+
+/** How much closer a scene of this length gets: slow, about 2.5 % a second, between 8 % and 25 %. */
+export const zoomAmount = (seconds: number) => r3(clamp(0.025 * seconds, 0.08, 0.25));
+
+/** Pans and tilts toward a side become a zoom toward it when only zooms are possible (cloud). */
+const SIDE: Partial<Record<MoveKind, Partial<FocusPoint>>> = { "pan-left": { x: 0.3 }, "pan-right": { x: 0.7 }, "tilt-up": { y: 0.3 }, "tilt-down": { y: 0.7 } };
+
+/**
+ * One scene's move over `seconds`. Zooms start or end on the whole picture with the centre heading for the
+ * focal point; pans and tilts hold a zoom that leaves room and cross as far as the crop can go. With
+ * `zoomOnly` (cloud) a pan becomes a push-in toward the side it heads for.
+ */
+export function kenBurnsMove(kind: MoveKind, focus: FocusPoint, seconds: number, o: { zoomOnly?: boolean } = {}): KenBurnsMove {
+ const d = zoomAmount(seconds);
+ if (o.zoomOnly && SIDE[kind]) return { ...kenBurnsMove("push-in", { ...focus, ...SIDE[kind] }, seconds), kind };
+ const easing = "ease-in-out" as const;
+ if (kind === "push-in" || kind === "pull-out") {
+ const z = r3(1 + d);
+ const at = inside(focus, z);
+ return kind === "push-in" ? { kind, zoomFrom: 1, zoomTo: z, panFrom: CENTRE, panTo: at, easing } : { kind, zoomFrom: z, zoomTo: 1, panFrom: at, panTo: CENTRE, easing };
+ }
+ // A pan needs some zoom to have room to move: at least 12 % closer.
+ const z = r3(1 + Math.max(d, 0.12));
+ const r = room(z);
+ const f = inside(focus, z);
+ const from = kind === "pan-left" ? { x: 0.5 + r, y: f.y } : kind === "pan-right" ? { x: 0.5 - r, y: f.y } : kind === "tilt-up" ? { x: f.x, y: 0.5 + r } : { x: f.x, y: 0.5 - r };
+ const to = kind === "pan-left" ? { x: 0.5 - r, y: f.y } : kind === "pan-right" ? { x: 0.5 + r, y: f.y } : kind === "tilt-up" ? { x: f.x, y: 0.5 - r } : { x: f.x, y: 0.5 + r };
+ return { kind, zoomFrom: z, zoomTo: z, panFrom: pt(from), panTo: pt(to), easing };
+}
+
+const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
+
+/** Frames a second Faceless renders its Ken Burns clips at (the cloud's minimum; the open graph takes any). */
+export const KEN_BURNS_FPS = 24;
+
+/**
+ * A move cut into pieces of these lengths that play one after another as one move at one speed (linear). A
+ * clip shows its move's start on its first frame and its end on its last, so the pieces are cut between
+ * frames: piece k runs from the move's frame s to frame s + n − 1 of all N frames (n = its seconds × fps),
+ * and the next piece starts one frame-step on: no frame repeats at a seam. One piece keeps the move (eased).
+ */
+export function splitMove(move: KenBurnsMove, pieces: number[], fps = KEN_BURNS_FPS): KenBurnsMove[] {
+ if (pieces.length <= 1) return [move];
+ const frames = pieces.map((secs) => Math.max(2, Math.round(secs * fps)));
+ const last = frames.reduce((a, b) => a + b, 0) - 1;
+ const at = (k: number) => ({ zoom: Math.round(lerp(move.zoomFrom, move.zoomTo, k) * 1e5) / 1e5, pan: pt({ x: lerp(move.panFrom.x, move.panTo.x, k), y: lerp(move.panFrom.y, move.panTo.y, k) }, 1e5) });
+ let first = 0;
+ return frames.map((n) => {
+ const [s, e] = [at(first / last), at((first + n - 1) / last)];
+ first += n;
+ return { kind: move.kind, zoomFrom: s.zoom, zoomTo: e.zoom, panFrom: s.pan, panTo: e.pan, easing: "linear" as const };
+ });
+}
+
+/** The reverse move (the camera goes back the way it came). */
+export const reverseMove = (m: KenBurnsMove): KenBurnsMove => ({ ...m, kind: m.kind === "push-in" ? "pull-out" : m.kind === "pull-out" ? "push-in" : m.kind, zoomFrom: m.zoomTo, zoomTo: m.zoomFrom, panFrom: m.panTo, panTo: m.panFrom });
+
+/**
+ * Pieces of a scene when only whole-picture zooms are possible (cloud, over its 30 s per job): in, then back
+ * out to the same focal point, and so on, so each piece starts where the last one ended.
+ */
+export function zoomOnlyPieces(move: KenBurnsMove, pieces: number[]): KenBurnsMove[] {
+ return pieces.map((_, i) => (i % 2 === 0 ? move : reverseMove(move)));
+}
+
+export interface SceneMoveInput {
+ /** The scene's motion words, its picture's description, and its place in the film. */
+ motion: string;
+ visual: string;
+ index: number;
+ /** The clip lengths the scene is made of (one per job). */
+ pieces: number[];
+ /** Whole-picture zooms only (cloud). */
+ zoomOnly?: boolean;
+ /** Motion words that say nothing about this scene (a default the script starts every scene with). */
+ ignore?: string;
+ fps?: number;
+}
+
+/** The moves of a scene's clips: its own words' move (or the cycle's), toward the place they name (or a focal point), split per clip. */
+export function sceneMoves(s: SceneMoveInput): KenBurnsMove[] {
+ const own = s.motion.trim() && s.motion.trim() !== s.ignore ? s.motion : "";
+ const cycle = s.zoomOnly ? CLOUD_CYCLE : OPEN_CYCLE;
+ const kind = readMove(own) ?? cycle[s.index % cycle.length];
+ const focus = focusFromText(own) ?? focusFromText(s.visual) ?? FOCI[s.index % FOCI.length];
+ const move = kenBurnsMove(kind, focus, s.pieces.reduce((a, b) => a + b, 0), { zoomOnly: s.zoomOnly });
+ return s.zoomOnly ? zoomOnlyPieces(move, s.pieces) : splitMove(move, s.pieces, s.fps);
+}
+
+/** Where a point is, in words ("the upper left", "the centre"). */
+export function placeWords(p: FocusPoint): string {
+ const v = p.y < 0.46 ? "upper" : p.y > 0.54 ? "lower" : "";
+ const h = p.x < 0.46 ? "left" : p.x > 0.54 ? "right" : "";
+ return v || h ? `the ${[v, h].filter(Boolean).join(" ")}` : "the centre";
+}
+
+/** "Slow push-in toward the upper left" (a step's description; the providers take the numbers). */
+export function describeMove(m: KenBurnsMove): string {
+ if (m.kind === "push-in") return `Slow push-in toward ${placeWords(m.panTo)}`;
+ if (m.kind === "pull-out") return `Slow pull-out from ${placeWords(m.panFrom)}`;
+ return `Slow ${m.kind.startsWith("pan") ? "pan" : "tilt"} ${m.kind.split("-")[1]}`;
+}
diff --git a/src/lib/catalog/faceless.ts b/src/lib/catalog/faceless.ts
index 0ab8aeeb..b69dd409 100644
--- a/src/lib/catalog/faceless.ts
+++ b/src/lib/catalog/faceless.ts
@@ -1,3 +1,4 @@
+import { describeMove, KEN_BURNS_FPS, sceneMoves } from "@/lib/av/ken-burns";
import { estimateCost } from "./plan";
import type { ChainSlot, Engine, Generation, GenerationRequest, ModelDef } from "./types";
@@ -17,7 +18,10 @@ import type { ChainSlot, Engine, Generation, GenerationRequest, ModelDef } from
* - still: a picture per block in the episode's style (Nano Banana Pro / Z-Image Turbo; with style
* references Nano Banana Pro edit / Qwen-Image-Edit Style Reference).
* - clip: the still animated (Gemini Omni Flash, Higgsfield's engine, or Seedance 2.5 / Wan 2.2 Lightning).
- * Frame by frame keeps the still and moves the camera slowly over it (a Ken Burns prompt, cheaper settings).
+ * Frame by frame keeps the still and moves the camera slowly over it with no video model: a real Ken Burns
+ * (src/lib/av/ken-burns.ts) — fal's image-to-video zooms in and out by turns on the cloud; ComfyUI's
+ * kenburns-still zooms and pans on the open engine, at most 10 s a job, so longer scenes are split into
+ * pieces of one move, joined packet by packet with the others (video-concat-encoded).
* - narration: the whole reviewed script read in one take (one natural voice-over; ElevenLabs v4, or
* Chatterbox cloning a voice sample), then timed word by word (ElevenLabs forced alignment on the cloud,
* Qwen3-ASR on the open engine).
@@ -25,7 +29,9 @@ import type { ChainSlot, Engine, Generation, GenerationRequest, ModelDef } from
* cut to where its lines really fall (retimeBlocks) and the clips, joins, music, mix and subtitles follow,
* so picture and voice stay together over the whole film, whatever pace the narrator reads at.
* - music: an instrumental bed (Sonilo / ACE-Step) as long as the film, mixed under the voice: fal's compose
- * with the bed levelled to -28 LUFS on the cloud, oss-mux at -14 dB on the open engine.
+ * with the bed levelled to -28 LUFS on the cloud, oss-mux at -14 dB on the open engine. A film longer than
+ * the music model makes (ACE-Step: 240 s; Sonilo: 600 s) loops the bed: crossfaded seams on the open engine
+ * (audio-loop-crossfade, up to 600 s), whole plays on the cloud (merge-audios; the mix cuts it to the film).
* - captions: Auto Subtitle on the cloud; Qwen3-ASR timings + the open burn-in on the open engine.
*/
@@ -344,8 +350,8 @@ export const ANIMATION_MODES: { id: AnimationMode; label: string; tagline: strin
id: "frames",
label: "Frame by frame",
tagline: "Scene by scene video",
- copy: "Paced stills with a slow camera move, rendered at a lower quality — lighter on credits",
- openCopy: "Paced stills with a slow camera move — on your GPU it takes about as long as Fully animated",
+ copy: "Each picture with a slow Ken Burns zoom, in and out by turns — no video model, a fraction of the price",
+ openCopy: "Each picture with a slow pan and zoom (Ken Burns) — no video model, so no GPU needed for the motion",
},
];
@@ -547,9 +553,16 @@ export interface EngineModels {
longNarration: string;
narrationMaxChars: number;
music: string;
+ /** Extends a bed the music model can't make long enough (crossfaded on the open engine, whole plays on the cloud). */
+ loop: string;
+ /** Frame by frame: the camera move over each still (Ken Burns). */
+ kenBurns: string;
join: string;
/** Joins at most this many clips at once (longer films are folded). */
joinMax: number;
+ /** Frame by frame's join (open: packet copy of the Ken Burns clips, flat memory) and its fold size. */
+ framesJoin: string;
+ framesJoinMax: number;
/** Puts the voice on the film (no music). */
mux: string;
/** Lays the voice over a music bed on the film. */
@@ -580,8 +593,12 @@ export const ENGINE_MODELS: Record<Engine, EngineModels> = {
longNarration: "elevenlabs-multilingual-v2",
narrationMaxChars: 5000,
music: "sonilo-music",
+ loop: "join-audio",
+ kenBurns: "ken-burns",
join: "join-clips",
joinMax: 24,
+ framesJoin: "join-clips",
+ framesJoinMax: 24,
mux: "merge-audio-video",
mixMusic: "ffmpeg-compose",
levelMusic: "ffmpeg-loudnorm",
@@ -602,8 +619,12 @@ export const ENGINE_MODELS: Record<Engine, EngineModels> = {
longNarration: "oss-chatterbox",
narrationMaxChars: Infinity,
music: "oss-ace-step",
+ loop: "oss-audio-loop",
+ kenBurns: "oss-ken-burns",
join: "oss-join-clips",
joinMax: 4,
+ framesJoin: "oss-join-encoded",
+ framesJoinMax: 24,
mux: "oss-mux",
mixMusic: "oss-mux",
captions: "oss-captions-burnin",
@@ -616,15 +637,18 @@ export const ENGINE_MODELS: Record<Engine, EngineModels> = {
/**
* Clip lengths each block video model can make. Gemini Omni Flash takes any whole number of seconds
- * from 3 to 10 (research: duration 3–10); the others list their durations in the catalog.
+ * from 3 to 10 (research: duration 3–10); the Ken Burns moves 1–30 s (fal) and 1–10 s per job (ComfyUI,
+ * longer scenes split); the others list their durations in the catalog.
*/
-export const DURATION_RANGES: Record<string, [number, number]> = { "gemini-omni-flash": [3, 10] };
+export const DURATION_RANGES: Record<string, [number, number]> = { "gemini-omni-flash": [3, 10], "ken-burns": [1, 30], "oss-ken-burns": [1, 10] };
/** Default quality per mode. Frame by frame trades resolution for price on the cloud. */
export const DEFAULT_RESOLUTION: Record<string, Record<AnimationMode, string>> = {
"gemini-omni-flash": { animated: "720p", frames: "360p" },
"seedance-2-5": { animated: "720p", frames: "480p" },
"oss-wan22-14b-fast": { animated: "480p", frames: "480p" },
+ // No model in the loop: 720p costs CPU time and memory (~11 MB a frame), not a GPU.
+ "oss-ken-burns": { animated: "720p", frames: "720p" },
};
/**
@@ -640,6 +664,12 @@ export const PRICE_PER_SECOND: Record<string, Record<string, number>> = {
/** Music models that make any whole length up to this (Sonilo: up to 600 s; ACE-Step's workflow: up to 240 s). */
export const MUSIC_MAX: Record<string, number> = { "sonilo-music": 600, "oss-ace-step": 240 };
+/** Longest bed a loop model makes (the open loop graph's limit; the cloud's whole plays go past any film). */
+export const LOOP_MAX: Record<string, number> = { "oss-audio-loop": 600 };
+
+/** Seconds of crossfade at each seam of a looped bed (open engine): long enough to hide the restart. */
+export const BED_CROSSFADE = 3;
+
/** How far the bed sits under the voice: levelled to -28 LUFS on the cloud, lowered by 14 dB by the open mixer. */
export const BED_LUFS = -28;
export const BED_DB = -14;
@@ -683,16 +713,6 @@ export function blockShots(seconds: number, model: ModelDef | undefined): number
// ---------------------------------------------------------------------------
// Prompts
-/** Slow camera moves for Frame by frame, one per block in turn. */
-export const KEN_BURNS = [
- "slow push-in towards the centre of the picture",
- "slow pull-out revealing the whole picture",
- "slow pan from left to right across the picture",
- "slow pan from right to left across the picture",
- "slow tilt upward across the picture",
- "slow diagonal drift with a gentle zoom",
-];
-
const clean = (s: string) => s.replace(/\s+/g, " ").trim().replace(/[.\s]+$/, "");
/** The picture for a block, in the episode's style (or its style references). */
@@ -705,12 +725,8 @@ export function stillPrompt(style: VisualStyle, block: Pick<ScriptBlock, "visual
return [clean(block.visual), look, sources, frame, "No text, letters, captions or watermarks in the image"].filter(Boolean).join(". ") + ".";
}
-/** What moves when a block's still is animated (Frame by frame: a slow camera over a still picture). */
-export function motionPrompt(style: VisualStyle, block: Pick<ScriptBlock, "motion">, mode: AnimationMode, blockIndex: number, shot = 0): string {
- if (mode === "frames") {
- const move = KEN_BURNS[(blockIndex + shot) % KEN_BURNS.length];
- return `A still illustration with a ${move}. The picture itself doesn't change: nothing moves, nothing new appears, no morphing. Smooth and steady, like a documentary.`;
- }
+/** What moves when a block's still is animated (Fully animated; Frame by frame moves the camera with no model, see sceneMoves). */
+export function motionPrompt(style: VisualStyle, block: Pick<ScriptBlock, "motion">, shot = 0): string {
const then = shot ? "The camera keeps moving from where the last shot ended. " : "";
return `${then}${clean(block.motion) || DEFAULT_MOTION}. ${style.motion.charAt(0).toUpperCase()}${style.motion.slice(1)}. Keep the art style, characters and colours exactly as in the first frame. No text.`;
}
@@ -757,6 +773,8 @@ export interface ResolvedModels {
resolution: string;
narration: string;
music: string | null;
+ /** Extends the bed past what the music model makes. */
+ loop: string | null;
/** Brings the bed down under the voice before the mix (cloud). */
level: string | null;
mux: string;
@@ -772,7 +790,9 @@ export interface ResolvedModels {
/** Which models an episode runs on, from its engine and settings. */
export function resolveModels(settings: EpisodeSettings, narrationChars: number, lookup: ModelLookup): ResolvedModels {
const m = ENGINE_MODELS[settings.engine];
- const video = settings.videoModel && m.videoChoices.includes(settings.videoModel) ? settings.videoModel : m.video;
+ // Frame by frame moves a camera over each still (Ken Burns); the video model choice is for Fully animated.
+ const frames = settings.animation === "frames";
+ const video = frames ? m.kenBurns : settings.videoModel && m.videoChoices.includes(settings.videoModel) ? settings.videoModel : m.video;
const videoDef = lookup(video);
const offered = videoDef?.options.resolutions ?? [];
const wanted = settings.resolution && offered.includes(settings.resolution) ? settings.resolution : (DEFAULT_RESOLUTION[video]?.[settings.animation] ?? videoDef?.defaults?.resolution ?? offered[0] ?? "720p");
@@ -787,10 +807,11 @@ export function resolveModels(settings: EpisodeSettings, narrationChars: number,
resolution: wanted,
narration,
music: settings.music ? m.music : null,
+ loop: settings.music ? m.loop : null,
level: settings.music ? (m.levelMusic ?? null) : null,
mux: settings.music ? m.mixMusic : m.mux,
- join: m.join,
- joinMax: m.joinMax,
+ join: frames ? m.framesJoin : m.join,
+ joinMax: frames ? m.framesJoinMax : m.joinMax,
captions: settings.subtitles ? m.captions : null,
align: m.align,
captionsUseWords: m.captionsUseWords,
@@ -844,6 +865,36 @@ export function musicLength(model: ModelDef | undefined, seconds: number): numbe
return ds.find((d) => d >= seconds) ?? ds[ds.length - 1];
}
+export interface MusicPlan {
+ /** Seconds the music model makes. */
+ bed: number;
+ /**
+ * The bed extended to cover the film: crossfaded seams (open), or whole plays the mix cuts to the film
+ * (cloud). Null when the bed already covers it.
+ */
+ loop: { duration: number; crossfade?: number; plays?: number } | null;
+ /** Seconds at the end of the film with no music (past what the loop makes, 600 s on the open engine). */
+ short: number;
+}
+
+/**
+ * The music for a film of `seconds`: the bed the music model makes (musicLength) and, when that is shorter
+ * than the film, the loop that extends it. 0 seconds of music short means the whole film has music.
+ */
+export function musicPlan(music: ModelDef | undefined, loop: ModelDef | undefined, seconds: number): MusicPlan {
+ const bed = musicLength(music, seconds);
+ const need = Math.ceil(seconds) + 1;
+ if (bed >= need || !loop) return { bed, loop: null, short: Math.max(0, Math.ceil(seconds - bed)) };
+ const duration = Math.min(LOOP_MAX[loop.id] ?? Infinity, need);
+ // A route that only repeats the clip (fal merge-audios) plays it whole; ComfyUI crossfades each seam.
+ const repeats = loop.routes.some((r) => r.op === "audio-loop" && !!r.map?.loop);
+ return {
+ bed,
+ loop: { duration, ...(repeats ? { plays: Math.ceil(duration / bed) } : { crossfade: BED_CROSSFADE }) },
+ short: Math.max(0, Math.ceil(seconds - duration)),
+ };
+}
+
/** Seconds of film a block's shots make (its planned or timed length, rounded up to what the model makes). */
export const filmSeconds = (seconds: number, video: ModelDef | undefined) => blockShots(seconds, video).reduce((a, c) => a + c, 0);
@@ -877,6 +928,10 @@ export function buildEpisodeGraph(input: GraphInput, lookup: ModelLookup): Graph
const stillImages =
models.stillOp === "edit" ? sources.slice(0, maxImages) : !takesRefs ? [] : stillDef.engine === "open" && refs.length ? refs.slice(0, maxImages) : [...refs, ...sources].slice(0, maxImages);
const refCount = models.stillOp === "edit" ? 0 : Math.min(refs.length, stillImages.length);
+ // Frame by frame: a camera move over the still, no video model. A route that sends the move as one zoom
+ // (fal's zoompan) can't pan: those scenes zoom in and out by turns.
+ const kenBurns = videoDef.routes.some((r) => r.op === "still-motion");
+ const zoomOnly = videoDef.routes.some((r) => r.op === "still-motion" && !!r.map?.zoom);
blocks.forEach((b, i) => {
const edit = input.stillEdits?.[b.id];
@@ -908,10 +963,14 @@ export function buildEpisodeGraph(input: GraphInput, lookup: ModelLookup): Graph
},
});
const shots = blockShots(b.seconds, videoDef);
+ // A scene longer than one Ken Burns job is one move cut into pieces (each starts where the last ended).
+ const moves = kenBurns ? sceneMoves({ motion: b.motion, visual: b.visual, index: i, pieces: shots, zoomOnly, ignore: DEFAULT_MOTION, fps: KEN_BURNS_FPS }) : null;
shots.forEach((secs, s) => {
const key = `clip-${b.id}-${s + 1}`;
clipKeys.push(key);
- const clipLabel = shots.length > 1 ? `Scene ${i + 1} · clip ${s + 1} of ${shots.length}` : `Scene ${i + 1} · clip`;
+ const noun = moves ? "camera move" : "clip";
+ const clipLabel = shots.length > 1 ? `Scene ${i + 1} · ${noun} ${s + 1} of ${shots.length}` : `Scene ${i + 1} · ${noun}`;
+ const move = moves?.[s];
steps.push({
key,
part: "clip",
@@ -921,21 +980,41 @@ export function buildEpisodeGraph(input: GraphInput, lookup: ModelLookup): Graph
seconds: secs,
after: [stillKey],
chain: [{ slot: "images", position: "first" }],
- request: {
- ...base,
- modelId: models.video,
- op: "i2v",
- prompt: motionPrompt(style, b, settings.animation, i, s),
- params: {
- aspectRatio: ar,
- duration: secs,
- resolution: models.resolution,
- numOutputs: 1,
- // The narration replaces the clip's own sound.
- ...(videoDef.options.audio === true && { generateAudio: false }),
- },
- step: { label: clipLabel, index: i, of: n },
- },
+ request: move
+ ? {
+ ...base,
+ modelId: models.video,
+ op: "still-motion",
+ prompt: describeMove(move),
+ params: {
+ aspectRatio: ar,
+ duration: secs,
+ resolution: models.resolution,
+ fps: KEN_BURNS_FPS,
+ zoomFrom: move.zoomFrom,
+ zoomTo: move.zoomTo,
+ panFrom: move.panFrom,
+ panTo: move.panTo,
+ easing: move.easing,
+ numOutputs: 1,
+ },
+ step: { label: clipLabel, index: i, of: n },
+ }
+ : {
+ ...base,
+ modelId: models.video,
+ op: "i2v",
+ prompt: motionPrompt(style, b, s),
+ params: {
+ aspectRatio: ar,
+ duration: secs,
+ resolution: models.resolution,
+ numOutputs: 1,
+ // The narration replaces the clip's own sound.
+ ...(videoDef.options.audio === true && { generateAudio: false }),
+ },
+ step: { label: clipLabel, index: i, of: n },
+ },
});
});
});
@@ -997,9 +1076,11 @@ export function buildEpisodeGraph(input: GraphInput, lookup: ModelLookup): Graph
request: { ...base, modelId: models.align, op: "transcribe", ...(alignReadsText && { prompt: voiceText }), step: { label: "Narration timing", index: n, of: n } },
});
+ let bedKey = "music";
if (models.music) {
const musicDef = pick(lookup, models.music);
- const bed = musicLength(musicDef, length);
+ const plan = musicPlan(musicDef, models.loop ? lookup(models.loop) : undefined, length);
+ const bed = plan.bed;
steps.push({
key: "music",
part: "music",
@@ -1014,29 +1095,49 @@ export function buildEpisodeGraph(input: GraphInput, lookup: ModelLookup): Graph
step: { label: "Music", index: n, of: n },
},
});
+ // A film longer than the bed: the bed looped (crossfaded seams, or whole plays the mix cuts to the film).
+ if (plan.loop && models.loop) {
+ const { duration, crossfade } = plan.loop;
+ steps.push({
+ key: "music-loop",
+ part: "music",
+ label: "Music bed · looped",
+ after: ["music"],
+ chain: [{ slot: "audio" }],
+ seconds: duration,
+ request: {
+ ...base,
+ modelId: models.loop,
+ op: "audio-loop",
+ params: { duration, sourceDuration: bed, ...(crossfade && { crossfade }) },
+ step: { label: "Music loop", index: n, of: n },
+ },
+ });
+ bedKey = "music-loop";
+ }
if (models.level) {
steps.push({
key: "level",
part: "music",
label: "Music level",
- after: ["music"],
+ after: [bedKey],
chain: [{ slot: "audio" }],
request: { ...base, modelId: models.level, op: "level", params: { extra: { integrated_loudness: BED_LUFS } }, step: { label: "Music level", index: n, of: n } },
});
+ bedKey = "level";
}
}
const muxDef = pick(lookup, models.mux);
// A timeline mixer (fal compose) places every track for the film's length.
const timeline = muxDef.routes.some((r) => r.op === "mux" && !!r.map?.tracks);
- const bed = models.level ? "level" : "music";
const mixLabel = models.music ? "Mixing voice and music" : "Mixing";
steps.push({
key: "mix",
part: "mix",
label: mixLabel,
seconds: length,
- after: models.music ? [film, "narration", bed] : [film, "narration"],
+ after: models.music ? [film, "narration", bedKey] : [film, "narration"],
chain: models.music ? [{ slot: "video" }, { slot: "audio" }, { slot: "audio2" }] : [{ slot: "video" }, { slot: "audio" }],
request: {
...base,
@@ -1688,6 +1789,8 @@ export function defaultSettings(engine: Engine, genre: GenreInfo, o: { explainer
export interface PickerData {
voices: { id: string; name: string; hint?: string }[];
videoModels: { id: string; name: string; engine: Engine; resolutions: string[] }[];
+ /** Frame by frame's camera move per engine (Ken Burns) and the qualities it renders at (none: the still's own size). */
+ cameraMoves?: Record<Engine, { id: string; name: string; resolutions: string[] }>;
/** How many style references each engine's picture model reads (the open one takes 2). */
maxStyleRefs: Record<Engine, number>;
}
@@ -1703,13 +1806,24 @@ export function pickerData(lookup: ModelLookup): PickerData {
return m ? [{ id, name: m.name, engine, resolutions: m.options.resolutions ?? [] }] : [];
}),
);
+ const camera = (engine: Engine) => {
+ const id = ENGINE_MODELS[engine].kenBurns;
+ return { id, name: lookup(id)?.name ?? "Ken Burns", resolutions: lookup(id)?.options.resolutions ?? [] };
+ };
return {
voices: voices.map((v) => ({ id: v.id, name: v.name, ...(v.hint && { hint: v.hint }) })),
videoModels,
+ cameraMoves: { cloud: camera("cloud"), open: camera("open") },
maxStyleRefs: { cloud: styleRefLimit("cloud", lookup), open: styleRefLimit("open", lookup) },
};
}
+/** What the music switch does on each engine (settings, the Explainer's popover). */
+export const MUSIC_HINT: Record<Engine, string> = {
+ cloud: "An instrumental bed under the voice, as long as the film (Sonilo, up to 10 minutes)",
+ open: "An instrumental bed under the voice (ACE-Step); past 4 minutes it loops with a soft crossfade",
+};
+
/** A short line the narrator reads for a voice preview. */
export const previewLine = (name: string) => `Hi, I'm ${name}. I'll be narrating your episode — here's how I sound.`;
diff --git a/src/server/faceless.ts b/src/server/faceless.ts
index 39559e17..9f4a4229 100644
--- a/src/server/faceless.ts
+++ b/src/server/faceless.ts
@@ -17,7 +17,7 @@ import {
getStyle,
MAX_SCRIPT,
MAX_SOURCES,
- musicLength,
+ musicPlan,
narrationText,
normalizeBlocks,
OFFLINE_NOTE,
@@ -797,11 +797,12 @@ function advance(ep: FacelessEpisode): FacelessEpisode {
const changed = graph
.filter((s) => !plan.ids[s.key] || status[s.key] === "failed" || status[s.key] === "canceled" || (s.part === "clip" && moved.has(blocks[s.block!].id)))
.map((s) => s.key);
- // A bed that no longer covers the film is made again.
- const music = graph.find((s) => s.key === "music");
- if (music && plan.ids.music && !changed.includes("music")) {
- const had = getGeneration(plan.ids.music, { includeDeleted: true })?.request.params?.duration ?? 0;
- if (had < (music.request.params?.duration ?? 0)) changed.push("music");
+ // A bed (or its loop) that no longer covers the film is made again.
+ for (const key of ["music", "music-loop"]) {
+ const step = graph.find((s) => s.key === key);
+ if (!step || !plan.ids[key] || changed.includes(key)) continue;
+ const had = getGeneration(plan.ids[key], { includeDeleted: true })?.request.params?.duration ?? 0;
+ if (had < (step.request.params?.duration ?? 0)) changed.push(key);
}
const rerun = planRerun(graph, changed).rerun.filter((k) => !TIMING_PARTS.has(part(k)));
const ids = prune(relaunch(graph, plan.ids, rerun, plan.batchId), graph);
@@ -1264,8 +1265,11 @@ function notesFor(settings: EpisodeSettings, seconds: number): { notes?: string[
if (settings.styleRefs.length > limit) notes.push(`The open-source picture model follows the first ${limit} style references.`);
if (settings.engine === "open" && settings.styleRefs.length && settings.sourceImages?.length) notes.push("Your style references set the look; the attached images aren't used for the open-source pictures.");
if (m.music) {
- const max = musicLength(getModel(m.music), Number.MAX_SAFE_INTEGER);
- if (seconds > max) notes.push(`The music bed is at most ${Math.floor(max / 60)} min ${max % 60 ? `${max % 60} s ` : ""}long, so the last ${Math.ceil(seconds - max)} s play without music.`);
+ const plan = musicPlan(getModel(m.music), m.loop ? getModel(m.loop) : undefined, seconds);
+ const minutes = (s: number) => `${Math.floor(s / 60)} min${s % 60 ? ` ${s % 60} s` : ""}`;
+ if (plan.loop?.crossfade) notes.push(`The music is made ${minutes(plan.bed)} long, then looped with a ${plan.loop.crossfade}-second crossfade to cover the film.`);
+ else if (plan.loop) notes.push(`The music is made ${minutes(plan.bed)} long and plays again to cover the film.`);
+ if (plan.short) notes.push(`The music bed goes up to ${minutes(plan.loop?.duration ?? plan.bed)}, so the last ${plan.short} s play without music.`);
}
return notes.length ? { notes } : {};
}
diff --git a/tests/av-ken-burns.test.ts b/tests/av-ken-burns.test.ts
new file mode 100644
index 00000000..6a4a3fc7
--- /dev/null
+++ b/tests/av-ken-burns.test.ts
@@ -0,0 +1,96 @@
+import { describe, expect, it } from "vitest";
+import { describeMove, focusFromText, kenBurnsMove, readMove, sceneMoves, splitMove, zoomAmount, type KenBurnsMove } from "@/lib/av/ken-burns";
+
+/** The crop centre must keep the crop inside the still at that zoom. */
+const fits = (m: KenBurnsMove) =>
+ [
+ [m.zoomFrom, m.panFrom],
+ [m.zoomTo, m.panTo],
+ ].every(([z, p]) => {
+ const r = 0.5 - 0.5 / (z as number);
+ const { x, y } = p as { x: number; y: number };
+ return x >= 0.5 - r - 1e-9 && x <= 0.5 + r + 1e-9 && y >= 0.5 - r - 1e-9 && y <= 0.5 + r + 1e-9;
+ });
+
+describe("Ken Burns moves", () => {
+ it("reads the move from the scene's camera words, not from what moves in it", () => {
+ expect(readMove("slow camera push-in, subtle movement in the scene")).toBe("push-in");
+ expect(readMove("The camera slowly zooms out to reveal the whole valley")).toBe("pull-out");
+ expect(readMove("pan left across the battlefield as smoke drifts")).toBe("pan-left");
+ expect(readMove("slow pan from left to right")).toBe("pan-right");
+ expect(readMove("tilt up to the stars")).toBe("tilt-up");
+ expect(readMove("smoke rising from the chimney")).toBeNull();
+ expect(readMove("camera pans across the market")).toBe("pan-right");
+ expect(readMove("leaves flutter in the wind")).toBeNull();
+ });
+
+ it("finds the place the words name, and not a past tense of leave", () => {
+ expect(focusFromText("a lighthouse on the far left, the sea beyond")).toEqual({ x: 0.33, y: 0.45 });
+ expect(focusFromText("towards the tower in the upper right corner")).toEqual({ x: 0.67, y: 0.34 });
+ expect(focusFromText("footprints in the foreground")).toEqual({ x: 0.5, y: 0.64 });
+ expect(focusFromText("the army left the burning city")).toBeNull();
+ expect(focusFromText("a quiet street at dawn")).toBeNull();
+ });
+
+ it("zooms slowly from the whole picture toward the focal point, and pans as far as the crop can go", () => {
+ expect(zoomAmount(10)).toBe(0.25);
+ expect(zoomAmount(4)).toBe(0.1);
+ expect(zoomAmount(2)).toBe(0.08);
+ const push = kenBurnsMove("push-in", { x: 0.2, y: 0.3 }, 8);
+ expect(push).toMatchObject({ zoomFrom: 1, zoomTo: 1.2, panFrom: { x: 0.5, y: 0.5 }, easing: "ease-in-out" });
+ expect(push.panTo).toEqual({ x: 0.417, y: 0.417 }); // as far toward it as the crop stays inside
+ expect(fits(push)).toBe(true);
+ const out = kenBurnsMove("pull-out", { x: 0.55, y: 0.45 }, 8);
+ expect(out).toMatchObject({ zoomFrom: 1.2, zoomTo: 1, panFrom: { x: 0.55, y: 0.45 }, panTo: { x: 0.5, y: 0.5 } });
+ const pan = kenBurnsMove("pan-left", { x: 0.5, y: 0.45 }, 10);
+ expect(pan).toMatchObject({ zoomFrom: 1.25, zoomTo: 1.25, panFrom: { x: 0.6, y: 0.45 }, panTo: { x: 0.4, y: 0.45 } });
+ const short = kenBurnsMove("tilt-up", { x: 0.5, y: 0.5 }, 3);
+ expect(short.zoomFrom).toBe(1.12); // a pan always keeps room to move
+ expect(short.panFrom.y).toBeGreaterThan(short.panTo.y);
+ for (const m of [push, out, pan, short]) expect(fits(m)).toBe(true);
+ expect(describeMove(push)).toBe("Slow push-in toward the upper left");
+ expect(describeMove(pan)).toBe("Slow pan left");
+ });
+
+ it("turns pans into a zoom toward their side when only zooms are possible (cloud)", () => {
+ const m = kenBurnsMove("pan-right", { x: 0.5, y: 0.42 }, 6, { zoomOnly: true });
+ expect(m).toMatchObject({ kind: "pan-right", zoomFrom: 1, zoomTo: 1.15, panFrom: { x: 0.5, y: 0.5 } });
+ expect(m.panTo.x).toBeGreaterThan(0.5);
+ expect(m.panTo.y).toBe(0.435);
+ });
+
+ it("splits a long scene into pieces that continue one move at one speed, cut between frames", () => {
+ const whole = kenBurnsMove("pan-right", { x: 0.5, y: 0.45 }, 14);
+ const [a, b] = splitMove(whole, [7, 7], 24);
+ expect(a).toMatchObject({ zoomFrom: whole.zoomFrom, panFrom: whole.panFrom, easing: "linear" });
+ expect(b).toMatchObject({ zoomTo: whole.zoomTo, panTo: whole.panTo, easing: "linear" });
+ // 336 frames in all: piece 1 shows frames 0–167 of the move, piece 2 frames 168–335, so the step from
+ // piece 1's last frame to piece 2's first is one frame's worth, like every other step (no frame repeats).
+ const step = (whole.panTo.x - whole.panFrom.x) / 335;
+ expect(a.panTo.x).toBeCloseTo(whole.panFrom.x + step * 167, 3);
+ expect(b.panFrom.x - a.panTo.x).toBeCloseTo(step, 3);
+ expect((a.panTo.x - a.panFrom.x) / 167).toBeCloseTo(step, 4);
+ // Unequal pieces: 6 + 3 s → the seam two thirds of the way.
+ const push = kenBurnsMove("push-in", { x: 0.3, y: 0.4 }, 9);
+ const [c] = splitMove(push, [6, 3], 24);
+ expect(c.zoomTo).toBeCloseTo(1 + ((push.zoomTo - 1) * 143) / 215, 3);
+ expect(splitMove(whole, [9])).toEqual([whole]);
+ });
+
+ it("plans each scene: its own words, else the cycle; in and out in turn on the cloud", () => {
+ const base = { visual: "A harbour at dusk", pieces: [6], ignore: "slow camera push-in, subtle movement in the scene" };
+ const open = [0, 1, 2, 3].map((index) => sceneMoves({ ...base, motion: base.ignore, index })[0].kind);
+ expect(open).toEqual(["push-in", "pan-right", "pull-out", "tilt-up"]);
+ const cloud = [0, 1, 2, 3].map((index) => sceneMoves({ ...base, motion: base.ignore, index, zoomOnly: true })[0]);
+ expect(cloud.map((m) => (m.zoomTo > m.zoomFrom ? "in" : "out"))).toEqual(["in", "out", "in", "out"]);
+ const said = sceneMoves({ ...base, motion: "zoom out from the lighthouse on the left", index: 0 })[0];
+ expect(said).toMatchObject({ kind: "pull-out", panFrom: { x: 0.435, y: 0.45 } }); // 1.15× leaves 6.5 % of room
+ // A scene the open engine makes in two jobs.
+ const split = sceneMoves({ ...base, motion: "pan left across the bay", index: 5, pieces: [7, 6] });
+ expect(split.map((m) => m.easing)).toEqual(["linear", "linear"]);
+ expect(split[1].panFrom.x).toBeLessThan(split[0].panTo.x); // a pan left goes on from where the first piece ended
+ // The cloud's pieces go in, then back out from the same point.
+ const back = sceneMoves({ ...base, motion: base.ignore, index: 0, pieces: [20, 20], zoomOnly: true });
+ expect(back[1]).toMatchObject({ zoomFrom: back[0].zoomTo, zoomTo: back[0].zoomFrom, panFrom: back[0].panTo });
+ });
+});
diff --git a/tests/faceless-api.test.ts b/tests/faceless-api.test.ts
index 5a4cbe0f..b56a1537 100644
--- a/tests/faceless-api.test.ts
+++ b/tests/faceless-api.test.ts
@@ -181,9 +181,9 @@ describe("Episodes", () => {
} finally {
setSetting("engineMode", "both");
}
- // What the render will do differently: two of three style references on the open engine, a short music bed.
+ // What the render will do differently: two of three style references on the open engine, a bed looped past 4 minutes.
const notes = (await est({ ...open, length: 300, styleRefs: ["/api/files/a.png", "/api/files/b.png", "/api/files/c.png"] })).notes;
- expect(notes).toEqual(expect.arrayContaining([expect.stringMatching(/first 2 style references/), expect.stringMatching(/at most 4 min/)]));
+ expect(notes).toEqual(expect.arrayContaining([expect.stringMatching(/first 2 style references/), expect.stringMatching(/made 4 min long, then looped with a 3-second crossfade/)]));
});
it(
@@ -220,13 +220,17 @@ describe("Episodes", () => {
const ids = timed.episode.plan!.ids;
expect(timed.timing).toBe("planned");
expect(timed.episode.plan!.untimed).toBe(true);
- // Open, frame by frame: 5-second Wan shots, folded joins, music, timed captions.
+ // Open, frame by frame: one Ken Burns move per scene (no video model), one packet-copy join, music, timed captions.
const clips = Object.keys(ids).filter((k) => k.startsWith("clip-"));
- expect(clips.length).toBeGreaterThan(6);
+ expect(clips).toHaveLength(6);
expect(clips).toHaveLength(timed.steps.filter((s) => s.part === "clip").length);
- expect(Object.keys(ids)).toEqual(expect.arrayContaining(["join", "join-1-1", "narration", "music", "mix", "words", "captions"]));
- expect(gens.getGeneration(ids[`clip-${blocks[0].id}-1`])!.request.prompt).toMatch(/still illustration/);
- // The timeline shows the film as the clips make it (Wan's 3- and 5-second shots).
+ expect(Object.keys(ids)).toEqual(expect.arrayContaining(["join", "narration", "music", "mix", "words", "captions"]));
+ const move = gens.getGeneration(ids[`clip-${blocks[0].id}-1`])!;
+ expect(move).toMatchObject({ modelId: "oss-ken-burns", op: "still-motion" });
+ expect(move.request.params).toMatchObject({ zoomFrom: 1, fps: 24, easing: "ease-in-out", resolution: "720p" });
+ expect(move.request.prompt).toMatch(/^Slow push-in toward/);
+ expect(gens.getGeneration(ids.join)!.modelId).toBe("oss-join-encoded");
+ // The timeline shows the film as the clips make it.
expect(timed.scenes.reduce((n, s) => n + s.seconds, 0)).toBe(clips.reduce((n, k) => n + Number(gens.getGeneration(ids[k])!.request.params?.duration), 0));
const [doneCloud, doneOpen] = await Promise.all([settled(cloudId), settled(openId)]);
diff --git a/tests/faceless.test.ts b/tests/faceless.test.ts
index d626a794..134f3169 100644
--- a/tests/faceless.test.ts
+++ b/tests/faceless.test.ts
@@ -2,6 +2,8 @@ import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { getModel } from "@/lib/catalog";
+import { buildPayload } from "@/lib/catalog/payload";
+import type { GenerationRequest } from "@/lib/catalog/types";
import {
blockCount,
blockShots,
@@ -44,7 +46,9 @@ import {
ANIMATION_MODES,
filmSeconds,
musicLength,
+ musicPlan,
plannedTiming,
+ resolveModels,
sceneSpans,
sceneTiming,
spokenTimes,
@@ -167,15 +171,59 @@ describe("render graph", () => {
expect(g.every((s) => s.request.feature === "faceless" && s.request.batchTitle === "How tides work")).toBe(true);
});
- it("cloud, frame by frame: a slow camera over each still at a cheaper quality", () => {
- const g = graphFor({ engine: "cloud", animation: "frames", music: false }, six);
- const clip = g.find((s) => s.part === "clip")!;
- expect(clip.request.params?.resolution).toBe("360p");
- expect(clip.request.prompt).toMatch(/slow push-in.*doesn't change/i);
+ it("cloud, frame by frame: a Ken Burns zoom over each still (fal image-to-video), in and out by turns, no video model", () => {
+ // Scenes whose motion words name no move take the cycle; one that names it gets it.
+ const still = six.map((b, i) => ({ ...b, motion: i === 4 ? "zoom out to reveal the valley on the left" : "" }));
+ const g = graphFor({ engine: "cloud", animation: "frames", music: false }, still);
+ const clips = g.filter((s) => s.part === "clip");
+ expect(clips).toHaveLength(6);
+ expect(clips[0]).toMatchObject({ label: "Scene 1 · camera move", after: ["still-b0"], chain: [{ slot: "images", position: "first" }] });
+ expect(clips[0].request).toMatchObject({ modelId: "ken-burns", op: "still-motion", params: { duration: 9, fps: 24, zoomFrom: 1, easing: "ease-in-out", aspectRatio: "16:9" } });
+ expect(clips[0].request.prompt).toMatch(/^Slow push-in toward/);
+ const dir = (p: GenerationRequest["params"]) => (p!.zoomTo! > p!.zoomFrom! ? "in" : "out");
+ expect(clips.map((c) => dir(c.request.params))).toEqual(["in", "out", "in", "out", "out", "out"]);
+ // What fal gets: the zoomed-in end and its focal point (in percent), the direction and the easing.
+ const route = getModel("ken-burns")!.routes[0];
+ const payload = buildPayload(route.map!, { ...clips[4].request.params, images: ["/still.png"] });
+ expect(payload).toMatchObject({ image_url: "/still.png", zoom_direction: "out", easing: "ease_in_out", frames_per_second: 24, duration: 9 });
+ expect(payload.zoom_factor).toBeCloseTo(1.225, 3);
+ expect(payload.zoom_x).toBeLessThan(50); // the valley on the left
+ // Joined with the cloud join; priced as Ken Burns, far below animating every scene.
+ expect(g.find((s) => s.key === "join")!.request.modelId).toBe("join-clips");
const animated = estimateGraph(graphFor({ engine: "cloud", animation: "animated", music: false }, six), getModel);
const frames = estimateGraph(g, getModel);
- expect(frames.parts.clip).toBeLessThan(animated.parts.clip!);
- expect(frames.total).toBeLessThan(animated.total);
+ expect(frames.parts.clip).toBeCloseTo(0.006, 5);
+ expect(frames.total).toBeLessThan(animated.total - 5);
+ });
+
+ it("open, frame by frame: zoom and pan per scene; a scene over 10 s is one move in pieces; one packet-copy join", () => {
+ const blocks = [{ ...block(0, 20, 14), motion: "pan left across the harbour" }, { ...block(1, 20, 6), motion: "" }, { ...block(2, 20, 8), motion: "" }];
+ const g = graphFor({ engine: "open", animation: "frames", music: false, voice: null }, blocks);
+ const clips = g.filter((s) => s.part === "clip");
+ expect(clips.map((c) => [c.key, c.seconds, c.label])).toEqual([
+ ["clip-b0-1", 7, "Scene 1 · camera move 1 of 2"],
+ ["clip-b0-2", 7, "Scene 1 · camera move 2 of 2"],
+ ["clip-b1-1", 6, "Scene 2 · camera move"],
+ ["clip-b2-1", 8, "Scene 3 · camera move"],
+ ]);
+ const [a, b] = clips.map((c) => c.request.params!);
+ expect(clips[0].request).toMatchObject({ modelId: "oss-ken-burns", op: "still-motion", params: { resolution: "720p", fps: 24, aspectRatio: "16:9", easing: "linear" } });
+ // One pan left in two pieces: the second goes on from the first, at the same zoom.
+ expect(a.zoomFrom).toBe(a.zoomTo);
+ expect(b.zoomFrom).toBe(a.zoomTo);
+ expect(a.panFrom!.x).toBeGreaterThan(a.panTo!.x);
+ expect(b.panFrom!.x).toBeLessThan(a.panTo!.x);
+ expect(a.panTo!.x - b.panFrom!.x).toBeLessThan(0.002); // one frame's step
+ // Scenes that fit one job keep the eased move; the cycle gives the second scene a pan right.
+ expect(clips[2].request.params).toMatchObject({ easing: "ease-in-out" });
+ expect(clips[2].request.prompt).toBe("Slow pan right");
+ const join = g.find((s) => s.key === "join")!;
+ expect(join.request.modelId).toBe("oss-join-encoded");
+ expect(join.after).toEqual(clips.map((c) => c.key));
+ expect(estimateGraph(g, getModel).total).toBe(0);
+ // A 10-minute explainer joins 24 scenes at a time (packet copy needs no memory per frame).
+ const long = graphFor({ engine: "open", animation: "frames", music: false, voice: null }, Array.from({ length: 60 }, (_, i) => block(i)));
+ expect(long.filter((s) => s.part === "join").map((j) => j.after!.length)).toEqual([24, 24, 12, 3]);
});
it("open: Wan 2.2 Lightning in 5-second shots, joins folded 4 at a time, Chatterbox, music under the voice, Qwen3-ASR timed burn-in", () => {
@@ -504,12 +552,44 @@ describe("pictures from sources, style references, music length, frame pricing",
expect(musicLength(getModel("elevenlabs-music"), 50)).toBe(60);
});
- it("makes Frame by frame cheaper with Seedance 2.5 too, and says what it saves on each engine", () => {
+ it("makes Frame by frame a camera move whatever video model Fully animated would use, and says so on each engine", () => {
const priced = (animation: "animated" | "frames") => estimateGraph(graphFor({ engine: "cloud", music: false, videoModel: "seedance-2-5", animation }, placeholderBlocks(300)), getModel);
- expect(priced("frames").parts.clip).toBeLessThan(priced("animated").parts.clip! * 0.6);
+ expect(priced("frames").parts.clip).toBeLessThan(0.05);
+ expect(priced("animated").parts.clip).toBeGreaterThan(50);
+ expect(resolveModels({ ...defaultSettings("cloud", genreInfo("history")), animation: "frames", videoModel: "seedance-2-5" }, 100, getModel).video).toBe("ken-burns");
const frames = ANIMATION_MODES.find((m) => m.id === "frames")!;
- expect(frames.copy).toMatch(/lighter on credits/);
- expect(frames.openCopy).not.toMatch(/credits/);
+ expect(frames.copy).toMatch(/Ken Burns zoom.*a fraction of the price/);
+ expect(frames.openCopy).toMatch(/pan and zoom.*no GPU/);
+ });
+
+ it("loops a music bed past what the model makes: crossfaded on the open engine, whole plays on the cloud", () => {
+ const [ace, sonilo, openLoop, cloudLoop] = ["oss-ace-step", "sonilo-music", "oss-audio-loop", "join-audio"].map((id) => getModel(id));
+ expect(musicPlan(ace, openLoop, 200)).toEqual({ bed: 201, loop: null, short: 0 });
+ expect(musicPlan(ace, openLoop, 300)).toEqual({ bed: 240, loop: { duration: 301, crossfade: 3 }, short: 0 });
+ expect(musicPlan(ace, openLoop, 700)).toEqual({ bed: 240, loop: { duration: 600, crossfade: 3 }, short: 100 });
+ expect(musicPlan(sonilo, cloudLoop, 300)).toEqual({ bed: 301, loop: null, short: 0 });
+ expect(musicPlan(sonilo, cloudLoop, 650)).toEqual({ bed: 600, loop: { duration: 651, plays: 2 }, short: 0 });
+ expect(musicPlan(ace, undefined, 300)).toEqual({ bed: 240, loop: null, short: 60 });
+
+ // A five-minute open episode: ACE-Step's 240 s bed, looped to the film with 3 s crossfades, under the voice.
+ const open = graphFor({ engine: "open", music: true, voice: null }, placeholderBlocks(300));
+ const length = open.filter((s) => s.part === "clip").reduce((n, s) => n + s.seconds!, 0);
+ expect(open.find((s) => s.key === "music")!.request.params?.duration).toBe(240);
+ const loop = open.find((s) => s.key === "music-loop")!;
+ expect(loop).toMatchObject({ part: "music", after: ["music"], chain: [{ slot: "audio" }], seconds: length + 1 });
+ expect(loop.request).toMatchObject({ modelId: "oss-audio-loop", op: "audio-loop", params: { duration: length + 1, sourceDuration: 240, crossfade: 3 } });
+ expect(open.find((s) => s.key === "mix")!.after).toEqual(["join", "narration", "music-loop"]);
+ // A ten-minute cloud explainer: Sonilo's 600 s, played twice (the compose cuts it to the film), then levelled.
+ const cloud = graphFor({ engine: "cloud", music: true, animation: "frames" }, placeholderBlocks(640));
+ const cl = cloud.find((s) => s.key === "music-loop")!;
+ expect(cl.request).toMatchObject({ modelId: "join-audio", op: "audio-loop", params: { sourceDuration: 600 } });
+ expect(cl.request.params?.crossfade).toBeUndefined();
+ expect(buildPayload(getModel("join-audio")!.routes.find((r) => r.op === "audio-loop")!.map!, { ...cl.request.params, audio: "/bed.mp3" }).audio_urls).toEqual(["/bed.mp3", "/bed.mp3"]);
+ expect(cloud.find((s) => s.key === "level")!.after).toEqual(["music-loop"]);
+ expect(cloud.find((s) => s.key === "mix")!.after).toEqual(["join", "narration", "level"]);
+ expect(estimateGraph(cloud, getModel, ["music-loop"]).total).toBeLessThan(0.01);
+ // Short films need no loop.
+ expect(graphFor({ engine: "open", music: true, voice: null }, six).some((s) => s.key === "music-loop")).toBe(false);
});
});