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.

N7-5: Cinema's path action: H3 Max on the cloud, Uni3C on the GPU, a new take next to the scene

Claude265f90b5f560
diff --git a/src/components/cinema/cinema-feed.tsx b/src/components/cinema/cinema-feed.tsx
index 6737dcc6..5238a626 100644
--- a/src/components/cinema/cinema-feed.tsx
+++ b/src/components/cinema/cinema-feed.tsx
@@ -156,10 +156,10 @@ function dayLabel(ts: number): string {
return d.toLocaleDateString(undefined, { weekday: diff < 7 ? "long" : undefined, month: "short", day: "numeric", year: d.getFullYear() === today.getFullYear() ? undefined : "numeric" });
}
-const FEATURE_TITLES: Record<string, string> = { "cinema-scene": "3D scene", "cinema-recompose": "Recomposed view" };
+const FEATURE_TITLES: Record<string, string> = { "cinema-scene": "3D scene", "cinema-recompose": "Recomposed view", "cinema-path": "Fly path" };
const promptOf = (g: CinemaGeneration) => g.take?.prompt?.trim() || FEATURE_TITLES[g.feature] || g.request.prompt?.trim() || g.prompt || "Untitled";
-const STEP_HINT: Record<string, string> = { "cinema-cast": "Cast", "cinema-location": "Location", "cinema-grid": "Grid", "cinema-scene": "3D scene", "cinema-recompose": "Recomposed" };
+const STEP_HINT: Record<string, string> = { "cinema-cast": "Cast", "cinema-location": "Location", "cinema-grid": "Grid", "cinema-scene": "3D scene", "cinema-recompose": "Recomposed", "cinema-path": "Fly path" };
function Badge({ children, className }: { children: React.ReactNode; className?: string }) {
return <span className={cn("inline-flex h-5 items-center rounded-full bg-black/50 px-1.5 text-[10.5px] font-medium text-white backdrop-blur", className)}>{children}</span>;
diff --git a/src/lib/catalog/cinema.ts b/src/lib/catalog/cinema.ts
index 122c004d..b1b35328 100644
--- a/src/lib/catalog/cinema.ts
+++ b/src/lib/catalog/cinema.ts
@@ -1,3 +1,4 @@
+import { DEFAULT_MOTION, PATH_FPS, PATH_FRAMES, normalizeKeys, toH3MaxTrajectory, type CameraKey } from "@/lib/camera-path";
import { APERTURE, LENS, anglesNote, poseWords, recomposePrompt, type ScenePose } from "@/lib/scene3d";
import { getModel, getPreset } from "./index";
import { DOP_MODEL, LTX25_HOSTED } from "./dop";
@@ -161,6 +162,8 @@ export interface CinemaTakeInfo {
grid?: { size: GridSize; type: GridType };
/** A recomposition: the camera of the captured view. */
camera?: { lens: number; aperture: number; pose: ScenePose };
+ /** A filmed path: its keyframes, length and the move it started from. */
+ path?: { keys: CameraKey[]; duration: number; preset?: string };
}
/** A generation's membership in a project (and its folder = scene). */
@@ -195,7 +198,7 @@ export interface DirectorMessage {
}
export type CinemaMode = "video" | "image";
-export type CinemaAction = "generate" | "extend-forward" | "extend-backward" | "edit" | "grid" | "cast" | "location" | "location-view" | "scene" | "recompose";
+export type CinemaAction = "generate" | "extend-forward" | "extend-backward" | "edit" | "grid" | "cast" | "location" | "location-view" | "scene" | "recompose" | "path";
export type GridSize = "2x2" | "3x3" | "4x4";
export type GridType = "freeform" | "zooms" | "shots" | "next_shots" | "prev_shots";
export type CastValues = Record<string, string | number | string[] | undefined>;
@@ -229,6 +232,19 @@ export interface CinemaGenerateInput {
view?: string;
/** "recompose": the view captured in the 3D scene (an uploaded PNG) and the camera it was taken with. */
capture?: SceneCapture;
+ /** "path": the camera path keyframed in the 3D scene (and, on the open engine, the browser's render along it). */
+ path?: ScenePath;
+}
+
+export interface ScenePath {
+ /** The keyframes (src/lib/camera-path.ts); the first is the still's own camera. */
+ keys: CameraKey[];
+ /** Seconds (the cloud takes 1–15; the open engine always makes 81 frames at 16 fps). */
+ duration?: number;
+ /** The open engine: the browser's render of the scene along the path (an uploaded video), Uni3C's guide. */
+ render?: string;
+ /** The move it started from (a preset id), kept on the take. */
+ preset?: string;
}
/**
@@ -1346,6 +1362,7 @@ const FEATURES: Partial<Record<CinemaAction, string>> = {
"location-view": "cinema-location",
scene: "cinema-scene",
recompose: "cinema-recompose",
+ path: "cinema-path",
};
const feature = (action: CinemaAction, mode: CinemaMode) => FEATURES[action] ?? (mode === "image" ? "cinema-image" : "cinema");
@@ -1948,6 +1965,57 @@ function planRecompose(input: CinemaGenerateInput): CinemaPlan {
return finish(model, [{ key: "main", request }], notes, blocker);
}
+// ---------------------------------------------------------------------------
+// Fly path (build plan N7-5; new-models-7.md §3.3, §3.6, §3.7): film the still along a camera path keyframed in its 3D scene
+
+/** What films a path: H3 Max camera-controls on fal; Wan 2.1 I2V guided by Uni3C on your GPU, from the browser's render. */
+export const PATH_MODELS: Record<Engine, string> = { cloud: "minimax-h3-max-camera", open: "oss-uni3c-path" };
+/** The cloud's lengths (H3 Max takes 0.92–15 s; the open engine is always about 5 s). */
+export const PATH_DURATIONS = [3, 5, 8, 10, 15];
+/** The open engine's blocker until the browser has recorded and uploaded the render (the viewer does that on Film). */
+export const PATH_RENDER_FIRST = "Record the path first";
+
+/**
+ * Film the still along a path. Cloud: H3 Max camera-controls gets the still as its first frame and the keyframes as its
+ * camera_trajectory (a pure slide as its own truck move), prompt expansion off, and motion words that let the subject move
+ * (its default prompt freezes the scene). Open: the still is Wan 2.1's start image and the browser's render of the 3D scene
+ * along the path guides the camera through Uni3C; 81 frames at 16 fps.
+ */
+function planPath(input: CinemaGenerateInput): CinemaPlan {
+ const open = input.engine === "open";
+ const model = getModel(PATH_MODELS[input.engine])!;
+ const src = input.source?.kind === "image" ? input.source.url : undefined;
+ const path = input.path;
+ const keys = normalizeKeys(path?.keys ?? []);
+ const moving = keys.length > 1;
+ const prompt = tidy(input.prompt) || DEFAULT_MOTION;
+ const notes: string[] = [];
+ const offered = model.options.resolutions ?? [];
+ const resolution = offered.find((r) => r.toLowerCase() === input.resolution?.toLowerCase()) ?? model.defaults?.resolution;
+ let request: GenerationRequest;
+ if (open) {
+ const seconds = Math.round((PATH_FRAMES / PATH_FPS) * 10) / 10;
+ notes.push(
+ `Your browser renders the 3D scene along the path, then Wan 2.1 starts from the still and Uni3C keeps its camera on that render — ${PATH_FRAMES} frames at ${PATH_FPS} fps (${seconds} s) on your GPU, which needs about 48 GB`,
+ );
+ if (path?.duration && Math.abs(path.duration - seconds) > 0.5) notes.push(`The open engine always films about ${seconds} s, so the path is spread over that`);
+ const params: GenParams = { numOutputs: 1, aspectRatio: "auto", ...(resolution ? { resolution } : {}), cameraPath: keys };
+ request = { feature: "cinema-path", modelId: model.id, op: "camera-path", prompt, inputs: src && path?.render ? { images: [src], video: path.render } : undefined, params };
+ } else {
+ const range = model.routes[0]?.map?.ranges?.duration;
+ const duration = Math.min(range?.max ?? 15, Math.max(Math.max(1, range?.min ?? 1), Math.round((path?.duration ?? 5) * 10) / 10));
+ if (moving) {
+ const cam = toH3MaxTrajectory(keys);
+ notes.push("trajectory" in cam ? `H3 Max follows your ${cam.trajectory.length} keyframes from the still, with prompt expansion off so your motion words reach it as written` : cam.notes[0]);
+ if ("trajectory" in cam) notes.push(...cam.notes);
+ }
+ const params: GenParams = { numOutputs: 1, duration, ...(resolution ? { resolution } : {}), cameraPath: keys };
+ request = { feature: "cinema-path", modelId: model.id, op: "camera-path", prompt, inputs: src ? { images: [src] } : undefined, params };
+ }
+ const blocker = !src ? "Pick the scene's still" : !moving ? "Add a keyframe or pick a move first" : open && !path?.render ? PATH_RENDER_FIRST : undefined;
+ return finish(model, [{ key: "main", request }], notes, blocker);
+}
+
/** Everything a Generate press would run, priced, without running it (the browser shows it live). */
export function planCinema(input: CinemaGenerateInput, ctx: CinemaContext): CinemaPlan {
const i = { ...input, settings: input.settings ?? {}, prompt: input.prompt ?? "" };
@@ -1968,6 +2036,8 @@ export function planCinema(input: CinemaGenerateInput, ctx: CinemaContext): Cine
return planScene(i);
case "recompose":
return planRecompose(i);
+ case "path":
+ return planPath(i);
default:
return i.mode === "image" ? planStill(i) : planVideo(i, ctx);
}
diff --git a/src/server/cinema-generate.ts b/src/server/cinema-generate.ts
index 80ae5518..b9a4d8f3 100644
--- a/src/server/cinema-generate.ts
+++ b/src/server/cinema-generate.ts
@@ -140,6 +140,9 @@ export function generateInProject(projectId: string, input: CinemaRequest, folde
...(input.moves?.length ? { moves: input.moves } : {}),
...(input.action === "grid" && input.grid ? { grid: input.grid } : {}),
...(input.action === "recompose" && input.capture ? { camera: { lens: input.capture.lens, aperture: input.capture.aperture, pose: input.capture.pose } } : {}),
+ ...(input.action === "path" && input.path
+ ? { path: { keys: input.path.keys, duration: plan.steps[0]?.request.params?.duration ?? 5, ...(input.path.preset ? { preset: input.path.preset } : {}) } }
+ : {}),
};
const batchId = nanoid(10);
const made: Record<string, Generation[]> = {};
diff --git a/src/server/cinema-schemas.ts b/src/server/cinema-schemas.ts
index 9c2f2005..fff6d4e1 100644
--- a/src/server/cinema-schemas.ts
+++ b/src/server/cinema-schemas.ts
@@ -1,5 +1,6 @@
import "server-only";
import { z } from "zod";
+import { DISTANCE, MAX_KEYS } from "@/lib/camera-path";
import { APERTURE, LENS } from "@/lib/scene3d";
import { CinemaError } from "./cinema";
@@ -79,7 +80,7 @@ export const GenerateBody = z.object({
input: z.object({
engine: z.enum(["cloud", "open"]),
mode: z.enum(["video", "image"]),
- action: z.enum(["generate", "extend-forward", "extend-backward", "edit", "grid", "cast", "location", "location-view", "scene", "recompose"]).default("generate"),
+ action: z.enum(["generate", "extend-forward", "extend-backward", "edit", "grid", "cast", "location", "location-view", "scene", "recompose", "path"]).default("generate"),
modelId: z.string().max(80).optional(),
prompt: z.string().max(60_000).default(""),
moves: z.array(z.string().max(40)).max(12).optional(),
@@ -117,6 +118,26 @@ export const GenerateBody = z.object({
pose: z.object({ horizontal: z.number().min(0).max(360), vertical: z.number().min(-30).max(90), zoom: z.number().min(0).max(10) }),
})
.optional(),
+ // Fly path (N7-5): the keyframes, the length, the open engine's render along the path and the move it started from.
+ path: z
+ .object({
+ keys: z
+ .array(
+ z.object({
+ t: z.number().min(0).max(1),
+ azimuth: z.number().min(-360 * 32).max(360 * 32),
+ elevation: z.number().min(-90).max(90),
+ distance: z.number().min(DISTANCE.min).max(DISTANCE.max),
+ truck: z.number().min(-4).max(4).optional(),
+ }),
+ )
+ .min(1)
+ .max(MAX_KEYS),
+ duration: z.number().min(1).max(15).optional(),
+ render: FileRef.optional(),
+ preset: z.string().max(40).optional(),
+ })
+ .optional(),
}),
});
diff --git a/tests/cinema-path.test.ts b/tests/cinema-path.test.ts
new file mode 100644
index 00000000..734b52f5
--- /dev/null
+++ b/tests/cinema-path.test.ts
@@ -0,0 +1,288 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";
+import type { CinemaGenerateInput } from "@/lib/catalog/cinema";
+import type { ModelDef } from "@/lib/catalog/types";
+
+/** Fly path (build plan N7-5): Cinema's "Film this path" on both engines, the H3 Max payload, the Uni3C graph and the API. */
+
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-cinema-path-"));
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://127.0.0.1:9";
+process.env.OLLAMA_URL = "http://127.0.0.1:9";
+
+const { setSetting } = await import("@/server/settings");
+const gens = await import("@/server/generations");
+const cinema = await import("@/server/cinema");
+const generateRoute = await import("@/app/api/cinema/projects/[id]/generate/route");
+const { saveFile } = await import("@/server/storage");
+const { encodePng } = await import("@/server/png");
+const { getModel } = await import("@/lib/catalog");
+const { buildPayload } = await import("@/lib/catalog/payload");
+const { estimateCost } = await import("@/lib/catalog/plan");
+const { getWorkflow, prepareWorkflow } = await import("@/server/providers/comfyui");
+const { mockProvider } = await import("@/server/providers/mock");
+const { planCinema, PATH_MODELS, PATH_RENDER_FIRST } = await import("@/lib/catalog/cinema");
+const { DEFAULT_MOTION, PHOTO_KEY, presetKeys } = await import("@/lib/camera-path");
+
+beforeAll(() => {
+ setSetting("demoMode", "auto");
+ setSetting("enhanceProvider", "none");
+});
+afterEach(() => vi.useRealTimers());
+afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));
+
+const STILL = "/api/files/uploads/still.png";
+const RENDER = "/api/files/uploads/render.webm";
+const ctx = { cloudAllowed: true };
+const orbit = presetKeys("orbit_360")!;
+const film = (engine: "cloud" | "open", over: Partial<CinemaGenerateInput> = {}): CinemaGenerateInput => ({
+ engine,
+ mode: "video",
+ action: "path",
+ prompt: "",
+ settings: {},
+ source: { url: STILL, kind: "image" },
+ path: { keys: orbit, duration: 5, ...(engine === "open" ? { render: RENDER } : {}) },
+ ...over,
+});
+
+/** The research record of fal's camera-controls endpoint (docs/research/paid-model-apis-2.json). */
+interface FieldSpec {
+ required?: boolean;
+ values?: string[];
+ minItems?: number;
+ maxItems?: number;
+ itemRequired?: string[];
+ itemSchema?: Record<string, { minimum?: number; maximum?: number }>;
+}
+const RECORD = (JSON.parse(fs.readFileSync(path.join(process.cwd(), "docs/research/paid-model-apis-2.json"), "utf8")).endpoints as { endpoint: string; inputs: Record<string, FieldSpec> }[]).find(
+ (e) => e.endpoint === "minimax/h3-max/camera-controls",
+)!;
+
+describe("planning a fly path", () => {
+ it("cloud: H3 Max camera-controls films the still for 5 s at 768P, with motion words that let the subject move", () => {
+ vi.useFakeTimers({ now: Date.parse("2026-10-29T12:00:00Z"), toFake: ["Date"] });
+ const plan = planCinema(film("cloud"), ctx);
+ expect(plan.blocker).toBeUndefined();
+ expect(plan.model.id).toBe(PATH_MODELS.cloud);
+ expect(plan.model.id).toBe("minimax-h3-max-camera");
+ expect(plan.steps).toHaveLength(1);
+ const req = plan.steps[0].request;
+ expect(req).toMatchObject({ feature: "cinema-path", op: "camera-path", inputs: { images: [STILL] }, params: { duration: 5, resolution: "768P", cameraPath: orbit } });
+ expect(req.prompt).toBe(DEFAULT_MOTION);
+ expect(plan.notes[0]).toMatch(/H3 Max follows your 5 keyframes from the still, with prompt expansion off/);
+ // fal's launch price until 2026-10-31: $0.052 a second at 768P.
+ expect(plan.costUsd).toBe(0.26);
+ });
+
+ it("cloud: the price is the one of the run's date — $0.08 a second at 768P from November", () => {
+ vi.useFakeTimers({ now: Date.parse("2026-11-01T09:00:00Z"), toFake: ["Date"] });
+ expect(planCinema(film("cloud"), ctx).costUsd).toBe(0.4);
+ expect(planCinema(film("cloud", { resolution: "1080p", path: { keys: orbit, duration: 10 } }), ctx).costUsd).toBe(1.6);
+ expect(planCinema(film("cloud", { resolution: "480P", path: { keys: orbit, duration: 3 } }), ctx).costUsd).toBe(0.15);
+ vi.useFakeTimers({ now: Date.parse("2026-10-31T23:00:00Z"), toFake: ["Date"] });
+ expect(planCinema(film("cloud", { resolution: "1080P" }), ctx).costUsd).toBe(0.52);
+ });
+
+ it("cloud: the user's motion words are sent as written, and the length stays inside 1–15 s", () => {
+ const plan = planCinema(film("cloud", { prompt: "She turns and smiles.", path: { keys: orbit, duration: 40 } }), ctx);
+ expect(plan.steps[0].request.prompt).toBe("She turns and smiles");
+ expect(plan.steps[0].request.params?.duration).toBe(15);
+ });
+
+ it("cloud: a pure slide says it runs as H3 Max's own truck move", () => {
+ const plan = planCinema(film("cloud", { path: { keys: presetKeys("truck_left")!, duration: 5 } }), ctx);
+ expect(plan.blocker).toBeUndefined();
+ expect(plan.notes[0]).toMatch(/own truck move/);
+ });
+
+ it("open: Wan 2.1 + Uni3C on the browser's render, the still as the first frame, free", () => {
+ const plan = planCinema(film("open"), ctx);
+ expect(plan.model.id).toBe("oss-uni3c-path");
+ const req = plan.steps[0].request;
+ expect(req).toMatchObject({ feature: "cinema-path", op: "camera-path", inputs: { images: [STILL], video: RENDER }, params: { aspectRatio: "auto", resolution: "480p" } });
+ expect(req.prompt).toBe(DEFAULT_MOTION);
+ expect(plan.costUsd).toBe(0);
+ expect(plan.notes[0]).toMatch(/81 frames at 16 fps \(5.1 s\) on your GPU, which needs about 48 GB/);
+ });
+
+ it("waits for the still, a path that moves, and (open) the browser's render", () => {
+ expect(planCinema(film("cloud", { source: undefined }), ctx).blocker).toBe("Pick the scene's still");
+ expect(planCinema(film("cloud", { path: { keys: [PHOTO_KEY] } }), ctx).blocker).toBe("Add a keyframe or pick a move first");
+ expect(planCinema(film("cloud", { path: undefined }), ctx).blocker).toBe("Add a keyframe or pick a move first");
+ expect(planCinema(film("open", { path: { keys: orbit } }), ctx).blocker).toBe(PATH_RENDER_FIRST);
+ });
+});
+
+describe("cloud: MiniMax H3 Max camera controls (minimax/h3-max/camera-controls)", () => {
+ const m = getModel("minimax-h3-max-camera") as ModelDef;
+ const route = m.routes[0];
+
+ it("is a hidden helper on the camera-controls endpoint (not the legacy multi-angle alias), priced by resolution", () => {
+ expect(m.hidden).toBe(true);
+ expect(route).toMatchObject({ op: "camera-path", provider: "fal", endpoint: "minimax/h3-max/camera-controls" });
+ expect(m.routes.some((r) => r.endpoint.includes("multi-angle"))).toBe(false);
+ expect(m.options.resolutions).toEqual(["480P", "768P", "1080P"]);
+ expect(m.defaults).toMatchObject({ duration: 5, resolution: "768P" });
+ vi.useFakeTimers({ now: Date.parse("2026-10-30T00:00:00Z"), toFake: ["Date"] });
+ expect(estimateCost(m, { duration: 5, resolution: "480P" }, 1, "camera-path")).toBe(0.163);
+ vi.useFakeTimers({ now: Date.parse("2026-12-01T00:00:00Z"), toFake: ["Date"] });
+ expect(estimateCost(m, { duration: 5, resolution: "480P" }, 1, "camera-path")).toBe(0.25);
+ });
+
+ it("sends a payload the endpoint's schema takes: the still, the trajectory, prompt expansion off, the prompt, length, size and seed", () => {
+ const body = buildPayload(route.map!, { prompt: DEFAULT_MOTION, images: ["https://fal.test/still.png"], duration: 5, resolution: "768P", seed: 7, cameraPath: orbit });
+ expect(body).toEqual({
+ prompt: DEFAULT_MOTION,
+ image_url: "https://fal.test/still.png",
+ camera_trajectory: [0, 90, 180, 270, 360].map((azimuth, i) => ({ time: i / 4, azimuth, elevation: 0, distance: 1 })),
+ prompt_expansion_mode: "disabled",
+ duration: 5,
+ resolution: "768P",
+ seed: 7,
+ });
+ // Every field is one the schema has, the required ones are there, and every value is inside its limits.
+ for (const k of Object.keys(body)) expect(RECORD.inputs, k).toHaveProperty(k);
+ for (const [k, spec] of Object.entries(RECORD.inputs)) if (spec.required) expect(body, k).toHaveProperty(k);
+ expect(RECORD.inputs.resolution.values).toContain(body.resolution);
+ const traj = body.camera_trajectory as Record<string, number>[];
+ const item = RECORD.inputs.camera_trajectory;
+ expect(traj.length).toBeGreaterThanOrEqual(item.minItems!);
+ expect(traj.length).toBeLessThanOrEqual(item.maxItems!);
+ const limits = item.itemSchema!;
+ for (const k of traj) {
+ expect(Object.keys(k).sort()).toEqual([...item.itemRequired!].sort());
+ expect(k.time).toBeGreaterThanOrEqual(limits.time.minimum!);
+ expect(k.time).toBeLessThanOrEqual(limits.time.maximum!);
+ expect(k.elevation).toBeGreaterThanOrEqual(limits.elevation.minimum!);
+ expect(k.elevation).toBeLessThanOrEqual(limits.elevation.maximum!);
+ expect(k.distance).toBeGreaterThan(0);
+ }
+ });
+
+ it("sends a slide as the endpoint's own truck move instead of the trajectory", () => {
+ const body = buildPayload(route.map!, { prompt: "x", images: ["https://fal.test/still.png"], cameraPath: presetKeys("truck_right")! });
+ expect(body.free_camera_preset).toBe("truck_right");
+ expect(RECORD.inputs.free_camera_preset.values).toContain("truck_right");
+ expect(body).not.toHaveProperty("camera_trajectory");
+ });
+
+ it("keeps a long path to 12 keyframes and the length inside the schema's 0.92–15 s", () => {
+ const keys = Array.from({ length: 30 }, (_, i) => ({ t: i / 29, azimuth: i * 12, elevation: (i % 4) * 5, distance: 1 }));
+ const body = buildPayload(route.map!, { prompt: "x", images: ["https://fal.test/still.png"], cameraPath: keys, duration: 40 });
+ expect((body.camera_trajectory as unknown[]).length).toBe(12);
+ expect(body.duration).toBe(15);
+ });
+});
+
+describe("open: the Uni3C path graph (wan21-i2v-uni3c-path)", () => {
+ const manifest = () => getWorkflow("wan21-i2v-uni3c-path").manifest;
+
+ it("is validated, core nodes only, with Uni3C pinned in model_patches and the 720P base", () => {
+ const w = manifest();
+ expect(w.validated).toBe(true);
+ expect(w.capability).toBe("camera-path");
+ expect(w.customNodes).toEqual([]);
+ const files = Object.fromEntries(w.models.map((m) => [m.file, m]));
+ expect(files["Wan21_Uni3C_controlnet_fp16.safetensors"]).toMatchObject({ folder: "model_patches", url: expect.stringContaining("Kijai/WanVideo_comfy/resolve/8260d429d19fd7a72304cad059160b95d843913f/") });
+ expect(files["wan2.1_i2v_720p_14B_fp8_scaled.safetensors"]).toMatchObject({ folder: "diffusion_models", url: expect.stringContaining("Comfy-Org/Wan-2.1/resolve/123acf1cc74bccbb9bfff8ac1ee72edc08c2341d/") });
+ expect(files["Wan2_1-I2V-14B-480p_fp8_e4m3fn_scaled_KJ.safetensors"]).toMatchObject({ optional: true });
+ for (const m of w.models) expect(m.sizeGb, m.file).toBeGreaterThan(0);
+ expect(Object.keys(w.bindings).sort()).toEqual(
+ ["image", "video", "prompt", "negativePrompt", "width", "height", "seed", "steps", "cfg", "shift", "strength", "checkpoint", "filenamePrefix"].sort(),
+ );
+ expect(w.license).toMatch(/Apache-2.0/);
+ const m = getModel("oss-uni3c-path")!;
+ expect(m.routes).toEqual([expect.objectContaining({ op: "camera-path", provider: "comfyui", endpoint: "wan21-i2v-uni3c-path" })]);
+ });
+
+ it("binds the still, the render, the words, the size of the still's shape, the strength and the file prefix", async () => {
+ const { workflow } = await prepareWorkflow(
+ "wan21-i2v-uni3c-path",
+ { prompt: "She walks on", images: ["still.png"], video: "render.webm", aspectRatio: "auto", resolution: "480p", seed: 11, extra: { strength: 0.8 } },
+ { generationId: "gen-path", op: "camera-path", upload: async (_d, _t, name) => name, media: (name) => (name === "still.png" ? { width: 1080, height: 1920 } : undefined) as never },
+ );
+ expect(workflow["5"].inputs.image).toBe("still.png");
+ expect(workflow["7"].inputs.file).toBe("render.webm");
+ expect(workflow["10"].inputs.text).toBe("She walks on");
+ expect(String(workflow["11"].inputs.text)).toMatch(/^色调艳丽/);
+ expect([workflow["12"].inputs.width, workflow["12"].inputs.height]).toEqual([480, 848]);
+ expect(workflow["12"].inputs.length).toBe(81);
+ expect(workflow["13"].inputs.seed).toBe(11);
+ expect(workflow["9"].inputs).toMatchObject({ strength: 0.8, start_percent: 0, end_percent: 1, render_video: ["17", 0], model: ["18", 0] });
+ expect(workflow["15"].inputs.fps).toBe(16);
+ expect(workflow["16"].inputs.filename_prefix).toBe("fuobe/gen-path");
+ expect(workflow["1"].inputs.unet_name).toBe("wan2.1_i2v_720p_14B_fp8_scaled.safetensors");
+ });
+
+ it("asks for the render when there is none", async () => {
+ await expect(prepareWorkflow("wan21-i2v-uni3c-path", { prompt: "", images: ["still.png"] }, { generationId: "g", op: "camera-path", upload: async () => "x" })).rejects.toThrow(/Add a video/);
+ });
+});
+
+describe("demo mode", () => {
+ it("films a sample clip on both engines", async () => {
+ for (const id of ["minimax-h3-max-camera", "oss-uni3c-path"]) {
+ const model = getModel(id)!;
+ const route = model.routes[0];
+ const sub = await mockProvider.submit({ generationId: "g", model, route, input: { prompt: "", images: ["still.png"], video: "render.webm", cameraPath: orbit } });
+ const res = await mockProvider.poll({ externalId: sub.externalId, meta: { ...sub.meta, startedAt: 0 }, route, model, createdAt: 0 });
+ if (res.state !== "succeeded") throw new Error(res.state);
+ expect(res.outputs[0].kind).toBe("video");
+ }
+ });
+});
+
+const json = (body: unknown) => new Request("http://x/api", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
+const params = (id: string) => ({ params: Promise.resolve({ id }) });
+
+async function settle(id: string, ms = 30_000) {
+ const until = Date.now() + ms;
+ for (;;) {
+ const g = gens.getGeneration(id)!;
+ if (["succeeded", "failed", "canceled"].includes(g.status)) return g;
+ if (Date.now() > until) throw new Error(`timed out: ${g.status} ${g.message}`);
+ await new Promise((r) => setTimeout(r, 300));
+ }
+}
+
+const upload = (name: string) => saveFile({ data: encodePng({ width: 32, height: 18, data: Buffer.alloc(32 * 18 * 4, 128) }), contentType: "image/png", name, source: "upload" }).url;
+
+describe("Cinema API: Film this path in demo mode", () => {
+ it("files the filmed path next to the scene as a new take that remembers the path", async () => {
+ const p = cinema.createProject({ name: "Paths" });
+ const folder = cinema.createFolder(p.id, { name: "Rooftop" });
+ const still = upload("still.png");
+ const input = film("cloud", { prompt: "the dancer spins", source: { url: still, kind: "image" }, path: { keys: orbit, duration: 8, preset: "orbit_360" } });
+ const res = await generateRoute.POST(json({ input, folderId: folder.id }), params(p.id));
+ expect(res.status).toBe(201);
+ const { items, plan } = await res.json();
+ expect(plan.modelId).toBe("minimax-h3-max-camera");
+ expect(items[0]).toMatchObject({ feature: "cinema-path", op: "camera-path" });
+ expect(items[0].request.params.cameraPath).toEqual(orbit);
+ const take = cinema.listItems(p.id, { folderId: folder.id }).find((g) => g.id === items[0].id)!.take!;
+ expect(take).toMatchObject({ action: "path", prompt: "the dancer spins", path: { keys: orbit, duration: 8, preset: "orbit_360" } });
+ const done = await settle(items[0].id);
+ expect(done).toMatchObject({ status: "succeeded", kind: "video" });
+ }, 40_000);
+
+ it("refuses a path out of range, a render not uploaded here, and an open run without its render", async () => {
+ const p = cinema.createProject({ name: "Bad paths" });
+ for (const bad of [
+ { keys: [{ t: 2, azimuth: 0, elevation: 0, distance: 1 }] },
+ { keys: [{ t: 0, azimuth: 0, elevation: 120, distance: 1 }] },
+ { keys: [{ t: 0, azimuth: 0, elevation: 0, distance: 0 }] },
+ { keys: Array.from({ length: 13 }, (_, i) => ({ t: i / 12, azimuth: i, elevation: 0, distance: 1 })) },
+ { keys: orbit, render: "https://elsewhere.test/r.webm" },
+ { keys: orbit, duration: 30 },
+ ]) {
+ const res = await generateRoute.POST(json({ input: film("cloud", { path: bad }) }), params(p.id));
+ expect(res.status, JSON.stringify(bad).slice(0, 80)).toBe(400);
+ }
+ const none = await generateRoute.POST(json({ input: film("open", { path: { keys: orbit } }) }), params(p.id));
+ expect(none.status).toBe(422);
+ expect((await none.json()).error).toBe(PATH_RENDER_FIRST);
+ });
+});