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.

Blockout to film: the scene maths, beats, prompt compiler, shots and windows, and Cinema's plan on both engines

Claude7f6f37bdf1d4
diff --git a/docs/research/paid-model-apis-4.json b/docs/research/paid-model-apis-4.json
index e9ac6ba6..d5a15242 100644
--- a/docs/research/paid-model-apis-4.json
+++ b/docs/research/paid-model-apis-4.json
@@ -22299,6 +22299,88 @@
},
"license": "commercial",
"capability": "frontier"
+ },
+ {
+ "family": "minimax-h3",
+ "model": "MiniMax H3 Max 3D to Video",
+ "title": "H3 Max 3D to Video",
+ "vendor": "MiniMax",
+ "operation": "v2v",
+ "provider": "fal",
+ "endpoint": "minimax/h3-max/3d-to-video",
+ "falCategory": "video-to-video",
+ "status": "active",
+ "inputs": {
+ "video_url": {
+ "type": "string",
+ "required": true,
+ "desc": "Blender video, up to 15 seconds and 32 shots, at a public HTTPS URL."
+ },
+ "prompt": {
+ "type": "string",
+ "required": false,
+ "nullable": true,
+ "maxLength": 2000,
+ "desc": "Optional clarification of what your proxies represent or how they move, for example: 'The moving block represents a running person.' Camera, trajectories, timing and object count remain defined by the video."
+ },
+ "reference_image_urls": {
+ "type": "array",
+ "required": false,
+ "items": "string",
+ "maxItems": 8,
+ "desc": "Optional environment, subject, interior or detail references. When supplied, uses these images directly without visual planning or generating new images; Scene Intent is optional. Without references, automatically creates appearance references within your new-image limit. Camera and movement always come from the video."
+ },
+ "max_generated_reference_images": {
+ "type": "integer",
+ "required": false,
+ "minimum": 1,
+ "maximum": 8,
+ "default": 2,
+ "desc": "Maximum NEW images to generate when no reference images are supplied. Ignored when reference images are supplied. Uses fewer when enough views are covered. Uncovered shots stay in the video."
+ },
+ "resolution": {
+ "type": "enum",
+ "required": false,
+ "values": [
+ "480P",
+ "768P",
+ "1080P"
+ ],
+ "valueType": "string",
+ "default": "768P",
+ "desc": "Output quality. Duration is taken automatically from the video."
+ },
+ "enable_safety_checker": {
+ "type": "boolean",
+ "required": false,
+ "default": true,
+ "desc": "Authorized callers may set false to request relaxed screening."
+ }
+ },
+ "keyFields": {
+ "video": "video_url",
+ "images": "reference_image_urls",
+ "prompt": "prompt",
+ "resolution": "resolution"
+ },
+ "output": "video.url",
+ "outputShape": {
+ "video": "object{file_name,url,content_type,file_size}"
+ },
+ "price": "For every second of video you generate you will be charged $0.05 at 480p, $0.08 at 768p or $0.16 at 1080p (minimum 5 seconds). Each shot is rounded up to a whole second, with a minimum of 5 billed seconds per shot; a $0.50 processing fee per request; input tokens beyond the 4,096 included per shot are extra; automatically generated references are billed at $0.10 per image (the page's header says about $0.02-$0.04 each).",
+ "pricing": {
+ "usd": 0.08,
+ "unit": "second",
+ "note": "768P; 480P $0.05, 1080P $0.16; minimum 5 s a shot; + $0.50 processing a request"
+ },
+ "replicateEquivalent": null,
+ "license": "commercial",
+ "notes": "Blockout to film (package blockout-film; research new-models-10.md section 5). A grey-box / previs animation (up to 15 s, up to 32 shots) plus up to 8 reference stills -> a finished video as long as the input; camera, trajectories, timing and object count come from the video, the prompt (scene intent, at most 2000 characters) says what the proxies are. No audio field and no audio in the description: the result is treated as silent. Read from fal's OpenAPI and model page on 2026-11-01.",
+ "verified": true,
+ "checked": "2026-11-01",
+ "sourceUrl": "https://fal.ai/models/minimax/h3-max/3d-to-video/api",
+ "schemaUrl": "https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=minimax/h3-max/3d-to-video",
+ "capability": "video"
}
]
}
diff --git a/scripts/comfy/hand-built/video-blockout-wan22-fun-vace.json b/scripts/comfy/hand-built/video-blockout-wan22-fun-vace.json
new file mode 100644
index 00000000..e4f44126
--- /dev/null
+++ b/scripts/comfy/hand-built/video-blockout-wan22-fun-vace.json
@@ -0,0 +1,500 @@
+{
+ "1": {
+ "class_type": "LoadVideo",
+ "inputs": {
+ "file": "segment.mp4"
+ },
+ "_meta": {
+ "title": "blockout depth segment (<=81 frames @16 fps, near = bright)"
+ }
+ },
+ "2": {
+ "class_type": "GetVideoComponents",
+ "inputs": {
+ "video": [
+ "1",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "GetVideoComponents"
+ }
+ },
+ "3": {
+ "class_type": "ImageScale",
+ "inputs": {
+ "image": [
+ "2",
+ 0
+ ],
+ "upscale_method": "lanczos",
+ "width": 832,
+ "height": 480,
+ "crop": "center"
+ },
+ "_meta": {
+ "title": "depth frames at the work size"
+ }
+ },
+ "4": {
+ "class_type": "LoadImage",
+ "inputs": {
+ "image": "first_frame.png"
+ },
+ "_meta": {
+ "title": "first frame drawn from the references (Qwen-Image-Edit 2511), or the last frame of the window before"
+ }
+ },
+ "5": {
+ "class_type": "ImageScale",
+ "inputs": {
+ "image": [
+ "4",
+ 0
+ ],
+ "upscale_method": "lanczos",
+ "width": 832,
+ "height": 480,
+ "crop": "center"
+ },
+ "_meta": {
+ "title": "ImageScale"
+ }
+ },
+ "30": {
+ "class_type": "PrimitiveInt",
+ "inputs": {
+ "value": 81
+ },
+ "_meta": {
+ "title": "frames (4n+1, <= source frames)"
+ }
+ },
+ "31": {
+ "class_type": "ComfyMathExpression",
+ "inputs": {
+ "expression": "a - 1",
+ "values.a": [
+ "30",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "ComfyMathExpression"
+ }
+ },
+ "32": {
+ "class_type": "ImageFromBatch",
+ "inputs": {
+ "image": [
+ "3",
+ 0
+ ],
+ "batch_index": 1,
+ "length": [
+ "31",
+ 1
+ ]
+ },
+ "_meta": {
+ "title": "depth frames 1..N-1 (frame 0 is the first frame)"
+ }
+ },
+ "33": {
+ "class_type": "BatchImagesNode",
+ "inputs": {
+ "images.image0": [
+ "5",
+ 0
+ ],
+ "images.image1": [
+ "32",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "BatchImagesNode"
+ }
+ },
+ "34": {
+ "class_type": "SolidMask",
+ "inputs": {
+ "value": 0.0,
+ "width": 832,
+ "height": 480
+ },
+ "_meta": {
+ "title": "SolidMask"
+ }
+ },
+ "35": {
+ "class_type": "SolidMask",
+ "inputs": {
+ "value": 1.0,
+ "width": 832,
+ "height": 480
+ },
+ "_meta": {
+ "title": "SolidMask"
+ }
+ },
+ "36": {
+ "class_type": "RepeatImageBatch",
+ "inputs": {
+ "image": [
+ "37",
+ 0
+ ],
+ "amount": [
+ "31",
+ 1
+ ]
+ },
+ "_meta": {
+ "title": "RepeatImageBatch"
+ }
+ },
+ "37": {
+ "class_type": "MaskToImage",
+ "inputs": {
+ "mask": [
+ "35",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "MaskToImage"
+ }
+ },
+ "38": {
+ "class_type": "MaskToImage",
+ "inputs": {
+ "mask": [
+ "34",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "MaskToImage"
+ }
+ },
+ "39": {
+ "class_type": "BatchImagesNode",
+ "inputs": {
+ "images.image0": [
+ "38",
+ 0
+ ],
+ "images.image1": [
+ "36",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "BatchImagesNode"
+ }
+ },
+ "40": {
+ "class_type": "ImageToMask",
+ "inputs": {
+ "image": [
+ "39",
+ 0
+ ],
+ "channel": "red"
+ },
+ "_meta": {
+ "title": "ImageToMask"
+ }
+ },
+ "11": {
+ "class_type": "CLIPLoader",
+ "inputs": {
+ "clip_name": "umt5_xxl_fp8_e4m3fn_scaled.safetensors",
+ "type": "wan",
+ "device": "default"
+ },
+ "_meta": {
+ "title": "CLIPLoader"
+ }
+ },
+ "12": {
+ "class_type": "CLIPTextEncode",
+ "inputs": {
+ "clip": [
+ "11",
+ 0
+ ],
+ "text": "A woman walks slowly down a narrow corridor holding a torch; the door at the end swings open. Cinematic, photographic, natural motion."
+ },
+ "_meta": {
+ "title": "CLIPTextEncode"
+ }
+ },
+ "13": {
+ "class_type": "CLIPTextEncode",
+ "inputs": {
+ "clip": [
+ "11",
+ 0
+ ],
+ "text": "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
+ },
+ "_meta": {
+ "title": "CLIPTextEncode"
+ }
+ },
+ "14": {
+ "class_type": "VAELoader",
+ "inputs": {
+ "vae_name": "wan_2.1_vae.safetensors"
+ },
+ "_meta": {
+ "title": "VAELoader"
+ }
+ },
+ "15": {
+ "class_type": "WanVaceToVideo",
+ "inputs": {
+ "positive": [
+ "12",
+ 0
+ ],
+ "negative": [
+ "13",
+ 0
+ ],
+ "vae": [
+ "14",
+ 0
+ ],
+ "width": 832,
+ "height": 480,
+ "length": [
+ "30",
+ 0
+ ],
+ "batch_size": 1,
+ "strength": 1.0,
+ "control_video": [
+ "33",
+ 0
+ ],
+ "control_masks": [
+ "40",
+ 0
+ ],
+ "reference_image": [
+ "5",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "WanVaceToVideo"
+ }
+ },
+ "16": {
+ "class_type": "UNETLoader",
+ "inputs": {
+ "unet_name": "wan2.2_fun_vace_high_noise_14B_fp8_scaled.safetensors",
+ "weight_dtype": "default"
+ },
+ "_meta": {
+ "title": "UNETLoader"
+ }
+ },
+ "17": {
+ "class_type": "UNETLoader",
+ "inputs": {
+ "unet_name": "wan2.2_fun_vace_low_noise_14B_fp8_scaled.safetensors",
+ "weight_dtype": "default"
+ },
+ "_meta": {
+ "title": "UNETLoader"
+ }
+ },
+ "18": {
+ "class_type": "LoraLoaderModelOnly",
+ "inputs": {
+ "model": [
+ "16",
+ 0
+ ],
+ "lora_name": "wan2.2_t2v_lightx2v_4steps_lora_v1.1_high_noise.safetensors",
+ "strength_model": 1.0
+ },
+ "_meta": {
+ "title": "LoraLoaderModelOnly"
+ }
+ },
+ "19": {
+ "class_type": "LoraLoaderModelOnly",
+ "inputs": {
+ "model": [
+ "17",
+ 0
+ ],
+ "lora_name": "wan2.2_t2v_lightx2v_4steps_lora_v1.1_low_noise.safetensors",
+ "strength_model": 1.0
+ },
+ "_meta": {
+ "title": "LoraLoaderModelOnly"
+ }
+ },
+ "20": {
+ "class_type": "ModelSamplingSD3",
+ "inputs": {
+ "model": [
+ "18",
+ 0
+ ],
+ "shift": 5.0
+ },
+ "_meta": {
+ "title": "ModelSamplingSD3"
+ }
+ },
+ "21": {
+ "class_type": "ModelSamplingSD3",
+ "inputs": {
+ "model": [
+ "19",
+ 0
+ ],
+ "shift": 5.0
+ },
+ "_meta": {
+ "title": "ModelSamplingSD3"
+ }
+ },
+ "22": {
+ "class_type": "KSamplerAdvanced",
+ "inputs": {
+ "model": [
+ "20",
+ 0
+ ],
+ "add_noise": "enable",
+ "noise_seed": 0,
+ "steps": 4,
+ "cfg": 1.0,
+ "sampler_name": "euler",
+ "scheduler": "simple",
+ "positive": [
+ "15",
+ 0
+ ],
+ "negative": [
+ "15",
+ 1
+ ],
+ "latent_image": [
+ "15",
+ 2
+ ],
+ "start_at_step": 0,
+ "end_at_step": 2,
+ "return_with_leftover_noise": "enable"
+ },
+ "_meta": {
+ "title": "KSamplerAdvanced"
+ }
+ },
+ "23": {
+ "class_type": "KSamplerAdvanced",
+ "inputs": {
+ "model": [
+ "21",
+ 0
+ ],
+ "add_noise": "disable",
+ "noise_seed": 0,
+ "steps": 4,
+ "cfg": 1.0,
+ "sampler_name": "euler",
+ "scheduler": "simple",
+ "positive": [
+ "15",
+ 0
+ ],
+ "negative": [
+ "15",
+ 1
+ ],
+ "latent_image": [
+ "22",
+ 0
+ ],
+ "start_at_step": 2,
+ "end_at_step": 10000,
+ "return_with_leftover_noise": "disable"
+ },
+ "_meta": {
+ "title": "KSamplerAdvanced"
+ }
+ },
+ "24": {
+ "class_type": "TrimVideoLatent",
+ "inputs": {
+ "samples": [
+ "23",
+ 0
+ ],
+ "trim_amount": [
+ "15",
+ 3
+ ]
+ },
+ "_meta": {
+ "title": "TrimVideoLatent"
+ }
+ },
+ "25": {
+ "class_type": "VAEDecode",
+ "inputs": {
+ "samples": [
+ "24",
+ 0
+ ],
+ "vae": [
+ "14",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "VAEDecode"
+ }
+ },
+ "26": {
+ "class_type": "CreateVideo",
+ "inputs": {
+ "images": [
+ "25",
+ 0
+ ],
+ "fps": 16.0,
+ "bit_depth": "auto",
+ "color_space": "sRGB",
+ "codec": "none"
+ },
+ "_meta": {
+ "title": "CreateVideo (silent: sound comes afterwards)"
+ }
+ },
+ "27": {
+ "class_type": "SaveVideo",
+ "inputs": {
+ "video": [
+ "26",
+ 0
+ ],
+ "filename_prefix": "fuobe/video-blockout-wan22-fun-vace",
+ "format": "auto",
+ "format.codec": "auto",
+ "codec": "auto"
+ },
+ "_meta": {
+ "title": "SaveVideo"
+ }
+ }
+}
diff --git a/scripts/comfy/library.spec.mjs b/scripts/comfy/library.spec.mjs
index 167822a1..374b8e4f 100644
--- a/scripts/comfy/library.spec.mjs
+++ b/scripts/comfy/library.spec.mjs
@@ -2899,6 +2899,29 @@ export const SPEC = [
'Wan 2.2\'s high-noise expert takes only the steps at or above its switch point (sigma 0.875; ComfySwitchNode gives the first sampler the low-noise expert when the run starts below it, as all three intensities do). ' +
'Control: Depth Anything 3 depth on every frame (no kept frame, no masks); the direction frame is the VACE reference. Same weights as the restyle graph.',
},
+ {
+ // Blockout to film (package blockout-film): the open engine's render of a grey-box blockout.
+ id: 'video-blockout-wan22-fun-vace',
+ title: 'Blockout to film: Wan 2.2 Fun VACE driven by the blockout\'s own depth + a first frame drawn from the references',
+ capability: 'v2v',
+ handBuilt: 'hand-built/video-blockout-wan22-fun-vace.json',
+ bindings: {
+ video: [b('1', 'file')], image: [b('4', 'image')], prompt: [b('12', 'text')], negativePrompt: [b('13', 'text')],
+ width: [b('3', 'width'), b('5', 'width'), b('34', 'width'), b('35', 'width'), b('15', 'width')],
+ height: [b('3', 'height'), b('5', 'height'), b('34', 'height'), b('35', 'height'), b('15', 'height')],
+ frames: [b('30', 'value')], fps: [b('26', 'fps')], seed: [b('22', 'noise_seed'), b('23', 'noise_seed')], steps: [b('22', 'steps'), b('23', 'steps')],
+ cfg: [b('22', 'cfg'), b('23', 'cfg')], shift: [b('20', 'shift'), b('21', 'shift')], controlStrength: [b('15', 'strength')],
+ },
+ outputs: [{ node: '27', kind: 'video' }],
+ limits: { maxWidth: 1280, maxHeight: 1280, dimensionMultiple: 16, maxFrames: 81, frameStep: 4 },
+ vramGb: 24,
+ license: 'Apache-2.0 (Wan 2.2 Fun VACE, lightx2v)',
+ notes:
+ 'Cinema\'s Blockout on your GPU: the browser renders the grey box and its depth (near = bright, as Depth Anything draws it) at 16 fps; video-segment-resample cuts the depth into 81-frame windows that overlap by one frame; ' +
+ 'qwen-image-edit-2511 draws the first frame from the grey box\'s first frame and up to two references; each window runs this graph with the first frame (window 1) or the last frame of the window before (frame-extract), then video-concat-encoded joins them. ' +
+ 'The same graph as video-restyle-wan22-fun-vace without Depth Anything 3: control frame 0 = the first frame (kept), frames 1..N-1 = the depth video as it is; the first frame is also the VACE reference. Lightx2v 4 steps. Silent (no audio input): sound comes afterwards (Sound for video). ' +
+ 'A blockout uploaded without a depth pass runs video-restyle-wan22-fun-vace instead (Depth Anything 3 on the grey box).',
+ },
{
id: 'mixed-media-zimage-frames',
title: 'Mixed Media: per-frame stylisation at 4-24 fps (Z-Image Turbo img2img + Fun Union ControlNet canny)',
diff --git a/scripts/comfy/validation-state.json b/scripts/comfy/validation-state.json
index 0e0ed1b6..caad61dc 100644
--- a/scripts/comfy/validation-state.json
+++ b/scripts/comfy/validation-state.json
@@ -605,6 +605,12 @@
"error": null,
"at": "2026-10-23T16:47:53.446Z"
},
+ "video-blockout-wan22-fun-vace": {
+ "sha256": "80b322a686c79d85d97fe5754a70ac45a582495d41526477db48a130abad150d",
+ "validated": true,
+ "error": null,
+ "at": "2026-11-01T14:55:37.596Z"
+ },
"video-character-swap-h3": {
"sha256": "37496982555a84ada4ccb22a155639d6ed8817b0cf0a868aa1497bd05c1c9de2",
"validated": false,
diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.py
index aaffcd0a..59b8dc2f 100644
--- a/scripts/gen-cloud-models.py
+++ b/scripts/gen-cloud-models.py
@@ -541,6 +541,15 @@ model("minimax-h3-max-camera", "MiniMax H3 Max camera controls", "MiniMax", "hai
pricing=("second", 0.08, "768P; 480P $0.05, 1080P $0.16 — launch price $0.052 (480P $0.0325, 1080P $0.104) until 2026-10-31",
{"byResolution": {"480P": 0.05, "768P": 0.08, "1080P": 0.16},
"promo": {"until": "2026-10-31", "usd": 0.052, "byResolution": {"480P": 0.0325, "768P": 0.052, "1080P": 0.104}}}))
+# Blockout to film (package blockout-film; new-models-10.md §5): H3 Max renders a grey-box / previs animation (≤ 15 s,
+# ≤ 32 shots) with up to 8 reference stills; camera, blocking and timing come from the video. A hidden helper Cinema's
+# Blockout offers under its own name beside Seedance 2.5. Billed per second by resolution, at least 5 s a shot, plus a
+# $0.50 processing fee a request (fal's page, read 2026-11-01). No sound.
+model("minimax-h3-max-3d", "MiniMax H3 Max 3D to video", "MiniMax", "hailuo", "video",
+ "A grey-box blockout from Blender or the browser, rendered as a finished shot from your reference stills",
+ [("v2v", "minimax/h3-max/3d-to-video")], hidden=True, defaults={"resolution": "768P"},
+ pricing=("second", 0.08, "768P; 480P $0.05, 1080P $0.16; at least 5 s a shot; + $0.50 processing a request",
+ {"byResolution": {"480P": 0.05, "768P": 0.08, "1080P": 0.16}, "minSeconds": 5, "perRequest": 0.5}))
model("hailuo-2-3", "MiniMax Hailuo 2.3", "MiniMax", "hailuo", "video", "Expressive characters and dynamic action",
[("t2v", "fal-ai/minimax/hailuo-2.3/pro/text-to-video"), ("i2v", "fal-ai/minimax/hailuo-2.3/pro/image-to-video")],
pricing=("video", 0.49), defaults={"duration": 6}, fixed={"prompt_optimizer": True})
diff --git a/src/lib/blockout.ts b/src/lib/blockout.ts
new file mode 100644
index 00000000..ae733c53
--- /dev/null
+++ b/src/lib/blockout.ts
@@ -0,0 +1,614 @@
+/**
+ * Blockout to film (package blockout-film): a grey-box 3D blockout (uploaded from Blender, Unreal, Cinema 4D… or built in
+ * Cinema's browser builder) sets the camera, the blocking and the timing; reference stills and a timecoded beat prompt say
+ * what the finished shot looks like. This module is the pure part: the builder's scene (primitives, a mannequin, camera
+ * keyframes with handheld shake, timing markers), the built-in example (a corridor and a door, made by Fuobe), beats from
+ * markers, the reference roles, the prompt compiler in the structure Comfy's "Horror scene" workflow uses (Subject with
+ * each @ reference's role, Action as "a–b s — beat: …", Camera, Style, Constraints, Audio, "No …"), the cut of a long
+ * blockout into shots at its markers, and the open engine's 81-frame depth windows. No DOM, no three.js, no catalog.
+ */
+
+export type Vec3 = [number, number, number];
+
+// ---------------------------------------------------------------------------
+// The scene
+
+/** What the builder places: grey boxes and planes, a doorway, stairs, a door that swings, a mannequin, a mesh (GLB). */
+export type PrimKind = "box" | "wall" | "floor" | "doorway" | "stairs" | "door" | "mannequin" | "mesh";
+
+export interface PrimKey {
+ /** Seconds. */
+ t: number;
+ position: Vec3;
+ /** Degrees about the vertical; a door turns about its hinge (its left edge). */
+ rotation: number;
+}
+
+export interface BlockoutPrim {
+ id: string;
+ kind: PrimKind;
+ name: string;
+ /** Metres, y up; a primitive stands on its position (the bottom centre). */
+ position: Vec3;
+ /** Degrees about the vertical. */
+ rotation: number;
+ /** Width (x), height (y), depth (z) in metres. */
+ size: Vec3;
+ /** Where it is over time: between keys it moves in a line (a mannequin walks, a door swings). None: it stays put. */
+ keys?: PrimKey[];
+ /** A mesh's GLB (Image to 3D, or the Library). */
+ url?: string;
+}
+
+export interface BlockoutCameraKey {
+ /** Seconds. */
+ t: number;
+ position: Vec3;
+ /** The point the camera looks at. */
+ target: Vec3;
+ /** Focal length in mm on a full-frame body. */
+ lens: number;
+ /** Handheld shake: 0 = locked off, 1 = a nervous handheld. */
+ shake: number;
+}
+
+export interface BlockoutMarker {
+ id: string;
+ /** Seconds. */
+ t: number;
+ /** "Lights out", "Door kicked": the beat that starts here. */
+ label: string;
+}
+
+export interface BlockoutScene {
+ version: 1;
+ name: string;
+ /** Seconds. */
+ duration: number;
+ /** "16:9", "9:16", "2.39:1"… */
+ aspect: string;
+ prims: BlockoutPrim[];
+ camera: BlockoutCameraKey[];
+ markers: BlockoutMarker[];
+}
+
+/** What a blockout may hold, and how it is rendered in the browser. */
+export const BLOCKOUT = {
+ /** The shortest and longest blockout (seconds). */
+ minSeconds: 2,
+ maxSeconds: 60,
+ /** The browser renders the grey box (and its depth) at this rate: what Seedance and H3 Max read (24–60 fps). */
+ fps: 24,
+ maxPrims: 80,
+ maxCameraKeys: 32,
+ maxMarkers: 24,
+ maxBeatWords: 600,
+ /** Reference stills a blockout carries (Seedance takes 4 with the clip, H3 Max 3D 8, the open engine's first frame 3). */
+ maxRefs: 8,
+ lens: { min: 12, max: 200, default: 28 },
+} as const;
+
+const clamp = (n: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, n));
+const r3 = (n: number) => Math.round(n * 1000) / 1000 + 0;
+const finite = (n: unknown, fallback: number) => (typeof n === "number" && Number.isFinite(n) ? n : fallback);
+const vec = (v: unknown, fallback: Vec3, lim = 500): Vec3 =>
+ Array.isArray(v) && v.length === 3 ? [clamp(finite(v[0], fallback[0]), -lim, lim), clamp(finite(v[1], fallback[1]), -lim, lim), clamp(finite(v[2], fallback[2]), -lim, lim)] : [...fallback];
+
+/** The default size of each primitive (metres) and its name in the builder's menu. */
+export const PRIMS: Record<PrimKind, { name: string; size: Vec3; hint: string }> = {
+ box: { name: "Box", size: [1, 1, 1], hint: "Furniture, crates, a car: any solid" },
+ wall: { name: "Wall", size: [4, 2.8, 0.2], hint: "A flat wall, 20 cm thick" },
+ floor: { name: "Floor", size: [6, 0.05, 6], hint: "Ground, a floor or a ceiling" },
+ doorway: { name: "Doorway", size: [3, 2.8, 0.2], hint: "A wall with a door-sized gap in the middle" },
+ stairs: { name: "Stairs", size: [1.2, 1.5, 2.4], hint: "A flight of 8 steps, rising away from you" },
+ door: { name: "Door", size: [0.9, 2.1, 0.06], hint: "Swings on its left edge: key its angle to open it" },
+ mannequin: { name: "Mannequin", size: [0.5, 1.75, 0.3], hint: "A person: key positions and it walks between them" },
+ mesh: { name: "Mesh", size: [1, 1, 1], hint: "A GLB from Image to 3D or your Library, scaled to fit" },
+};
+
+/** A doorway's gap (metres), centred at the bottom of the wall. */
+export const DOOR_GAP = { width: 1, height: 2.1 } as const;
+export const STAIR_STEPS = 8;
+
+/** Where a primitive is at time t (its keys in a line between them; before the first and after the last it holds). */
+export function primAt(p: Pick<BlockoutPrim, "position" | "rotation" | "keys">, t: number): { position: Vec3; rotation: number } {
+ const keys = p.keys?.length ? [...p.keys].sort((a, b) => a.t - b.t) : null;
+ if (!keys) return { position: [...p.position], rotation: p.rotation };
+ if (t <= keys[0].t) return { position: [...keys[0].position], rotation: keys[0].rotation };
+ const last = keys[keys.length - 1];
+ if (t >= last.t) return { position: [...last.position], rotation: last.rotation };
+ let i = 0;
+ while (i < keys.length - 2 && keys[i + 1].t < t) i++;
+ const a = keys[i];
+ const b = keys[i + 1];
+ const f = b.t > a.t ? (t - a.t) / (b.t - a.t) : 1;
+ const lerp = (x: number, y: number) => x + (y - x) * f;
+ return { position: [lerp(a.position[0], b.position[0]), lerp(a.position[1], b.position[1]), lerp(a.position[2], b.position[2])], rotation: lerp(a.rotation, b.rotation) };
+}
+
+/** How fast a primitive moves at time t (metres a second): a mannequin swings its limbs in step with it. */
+export function primSpeed(p: Pick<BlockoutPrim, "position" | "rotation" | "keys">, t: number, dt = 1 / 24): number {
+ const a = primAt(p, t - dt / 2).position;
+ const b = primAt(p, t + dt / 2).position;
+ return Math.hypot(b[0] - a[0], b[2] - a[2]) / dt;
+}
+
+/** Ease in and out between camera keys, so a move starts and lands softly (a dolly, not a jump). */
+const ease = (f: number) => f * f * (3 - 2 * f);
+
+/**
+ * Handheld shake at time t for `amount` (0–1): a sum of slow sines at unrelated rates (no randomness, so a re-render is
+ * the same shot), up to about 4 cm of drift and 1.5° of wobble at 1.
+ */
+export function shakeAt(t: number, amount: number): { offset: Vec3; aim: Vec3 } {
+ const k = clamp(amount, 0, 1);
+ if (!k) return { offset: [0, 0, 0], aim: [0, 0, 0] };
+ const s = (f: number, p: number) => Math.sin(2 * Math.PI * f * t + p);
+ const offset: Vec3 = [0.025 * (s(0.53, 0.3) + 0.6 * s(1.31, 2.1)) * k, 0.02 * (s(0.71, 1.7) + 0.5 * s(1.93, 0.4)) * k, 0.012 * s(0.37, 2.9) * k];
+ const aim: Vec3 = [0.02 * (s(0.89, 0.9) + 0.4 * s(2.27, 1.3)) * k, 0.016 * (s(0.61, 2.4) + 0.4 * s(1.73, 0.2)) * k, 0];
+ return { offset, aim };
+}
+
+/** The camera at time t: keys eased between, plus its shake (the aim's shake is in radians-ish units of the distance). */
+export function cameraAt(keys: readonly BlockoutCameraKey[], t: number): { position: Vec3; target: Vec3; lens: number; shake: number } {
+ const list = keys.length ? [...keys].sort((a, b) => a.t - b.t) : [DEFAULT_CAMERA];
+ let pos: Vec3;
+ let tgt: Vec3;
+ let lens: number;
+ let shake: number;
+ if (t <= list[0].t || list.length === 1) ({ position: pos, target: tgt, lens, shake } = list[0]);
+ else if (t >= list[list.length - 1].t) ({ position: pos, target: tgt, lens, shake } = list[list.length - 1]);
+ else {
+ let i = 0;
+ while (i < list.length - 2 && list[i + 1].t < t) i++;
+ const a = list[i];
+ const b = list[i + 1];
+ const f = ease(b.t > a.t ? (t - a.t) / (b.t - a.t) : 1);
+ const lerp = (x: number, y: number) => x + (y - x) * f;
+ pos = [lerp(a.position[0], b.position[0]), lerp(a.position[1], b.position[1]), lerp(a.position[2], b.position[2])];
+ tgt = [lerp(a.target[0], b.target[0]), lerp(a.target[1], b.target[1]), lerp(a.target[2], b.target[2])];
+ // A zoom is even in its ratio (24 → 48 mm takes as long as 48 → 96).
+ lens = Math.exp(lerp(Math.log(a.lens), Math.log(b.lens)));
+ shake = lerp(a.shake, b.shake);
+ }
+ const sh = shakeAt(t, shake);
+ const dist = Math.hypot(tgt[0] - pos[0], tgt[1] - pos[1], tgt[2] - pos[2]) || 1;
+ return {
+ position: [pos[0] + sh.offset[0], pos[1] + sh.offset[1], pos[2] + sh.offset[2]],
+ target: [tgt[0] + sh.aim[0] * dist, tgt[1] + sh.aim[1] * dist, tgt[2]],
+ lens,
+ shake,
+ };
+}
+
+/** Vertical field of view (degrees) of a lens on a full-frame sensor cropped to `aspect` (width ÷ height). */
+export function lensVFov(lensMm: number, aspect: number): number {
+ const h = 24;
+ const w = 36;
+ // The frame is the largest `aspect` rectangle inside 36 × 24.
+ const fh = aspect >= w / h ? w / aspect : h;
+ return (2 * Math.atan(fh / 2 / clamp(lensMm, 1, 2000)) * 180) / Math.PI;
+}
+
+/** "16:9" → 1.778; "2.39:1" → 2.39; anything else 16:9. */
+export function aspectOf(aspect: string): number {
+ const m = /^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?)$/.exec(aspect.trim());
+ const r = m ? Number(m[1]) / Number(m[2]) : NaN;
+ return Number.isFinite(r) && r > 0.2 && r < 5 ? r : 16 / 9;
+}
+
+/** The render size of a blockout frame: the long side `long` px, both sides even multiples of 16. */
+export function blockoutSize(aspect: string, long = 1280): { width: number; height: number } {
+ const r = aspectOf(aspect);
+ const m16 = (n: number) => Math.max(16, Math.round(n / 16) * 16);
+ return r >= 1 ? { width: m16(long), height: m16(long / r) } : { width: m16(long * r), height: m16(long) };
+}
+
+export const DEFAULT_CAMERA: BlockoutCameraKey = { t: 0, position: [0, 1.6, 4], target: [0, 1.2, 0], lens: BLOCKOUT.lens.default, shake: 0 };
+
+let seq = 0;
+/** A short id for a new primitive, key or marker (the builder's; the server never needs them unique). */
+export const newId = (prefix = "p") => `${prefix}${Date.now().toString(36).slice(-4)}${(seq++).toString(36)}`;
+
+/** A new primitive of `kind` in front of the camera (at the origin). */
+export function newPrim(kind: PrimKind, at: Vec3 = [0, 0, 0], name?: string): BlockoutPrim {
+ const d = PRIMS[kind];
+ return { id: newId(kind[0]), kind, name: name ?? d.name, position: [...at], rotation: 0, size: [...d.size] };
+}
+
+/** An empty set: a floor and the camera looking at it. */
+export function emptyScene(): BlockoutScene {
+ return {
+ version: 1,
+ name: "My blockout",
+ duration: 6,
+ aspect: "16:9",
+ prims: [{ ...newPrim("floor"), id: "floor", size: [12, 0.05, 12] }],
+ camera: [{ ...DEFAULT_CAMERA }],
+ markers: [{ id: "m0", t: 0, label: "Opening" }],
+ };
+}
+
+/**
+ * The built-in example (Fuobe's own, not the horror workflow's assets): a corridor with a door at its end. A figure walks
+ * down it, the door swings open by itself, she steps through; the handheld camera follows. Eight seconds, three beats.
+ */
+export const EXAMPLE_SCENE: BlockoutScene = {
+ version: 1,
+ name: "Corridor and door",
+ duration: 8,
+ aspect: "16:9",
+ prims: [
+ { id: "floor", kind: "floor", name: "Floor", position: [0, 0, -6], rotation: 0, size: [2.6, 0.05, 14] },
+ { id: "ceiling", kind: "floor", name: "Ceiling", position: [0, 2.8, -6], rotation: 0, size: [2.6, 0.05, 14] },
+ { id: "wall-l", kind: "wall", name: "Left wall", position: [-1.4, 0, -6], rotation: 90, size: [14, 2.8, 0.2] },
+ { id: "wall-r", kind: "wall", name: "Right wall", position: [1.4, 0, -6], rotation: 90, size: [14, 2.8, 0.2] },
+ { id: "end", kind: "doorway", name: "End wall", position: [0, 0, -12], rotation: 0, size: [2.6, 2.8, 0.2] },
+ {
+ id: "door",
+ kind: "door",
+ name: "Door",
+ position: [-0.5, 0, -12],
+ rotation: 0,
+ size: [1, 2.1, 0.06],
+ keys: [
+ { t: 4.5, position: [-0.5, 0, -12], rotation: 0 },
+ { t: 5.6, position: [-0.5, 0, -12], rotation: 100 },
+ ],
+ },
+ { id: "cabinet", kind: "box", name: "Cabinet", position: [1.05, 0, -4.5], rotation: 0, size: [0.5, 1.2, 1.2] },
+ {
+ id: "walker",
+ kind: "mannequin",
+ name: "Woman",
+ position: [0, 0, -1],
+ rotation: 180,
+ size: [0.5, 1.7, 0.3],
+ keys: [
+ { t: 0, position: [0, 0, -1], rotation: 180 },
+ { t: 4.4, position: [0, 0, -9.6], rotation: 180 },
+ { t: 6, position: [0, 0, -9.8], rotation: 180 },
+ { t: 8, position: [0, 0, -13.2], rotation: 180 },
+ ],
+ },
+ ],
+ camera: [
+ { t: 0, position: [0.35, 1.55, 1.8], target: [0, 1.3, -6], lens: 28, shake: 0.45 },
+ { t: 4.4, position: [0.3, 1.55, -6.6], target: [0, 1.2, -12], lens: 32, shake: 0.35 },
+ { t: 8, position: [0.15, 1.5, -9.4], target: [0, 1.2, -14], lens: 35, shake: 0.6 },
+ ],
+ markers: [
+ { id: "arrival", t: 0, label: "Arrival" },
+ { id: "door", t: 4.5, label: "The door opens" },
+ { id: "dark", t: 6, label: "Into the dark" },
+ ],
+};
+
+/** The example's beat words (the builder fills them in when the example opens). */
+export const EXAMPLE_WORDS: Record<string, string> = {
+ arrival: "A woman walks slowly down the narrow corridor, holding a torch, glancing at the cabinet as she passes.",
+ door: "She stops. The door at the end swings open by itself with a long creak.",
+ dark: "She hesitates, then steps through the doorway into the dark room.",
+};
+
+/**
+ * A scene as an API or MCP caller (or an old draft) sent it, made safe: numbers finite and in range, lists capped,
+ * times inside the length, at least one camera key.
+ */
+export function normalizeScene(raw: unknown): BlockoutScene {
+ const s = (raw && typeof raw === "object" ? raw : {}) as Partial<BlockoutScene>;
+ const duration = clamp(finite(s.duration, 6), BLOCKOUT.minSeconds, BLOCKOUT.maxSeconds);
+ const time = (t: unknown) => r3(clamp(finite(t, 0), 0, duration));
+ const kinds = new Set(Object.keys(PRIMS));
+ const prims = (Array.isArray(s.prims) ? s.prims : [])
+ .filter((p): p is BlockoutPrim => !!p && kinds.has((p as BlockoutPrim).kind))
+ .slice(0, BLOCKOUT.maxPrims)
+ .map((p, i) => ({
+ id: String(p.id || `p${i}`).slice(0, 40),
+ kind: p.kind,
+ name: String(p.name || PRIMS[p.kind].name).slice(0, 60),
+ position: vec(p.position, [0, 0, 0]),
+ rotation: clamp(finite(p.rotation, 0), -3600, 3600),
+ size: vec(p.size, PRIMS[p.kind].size, 200).map((n) => Math.max(0.01, Math.abs(n))) as Vec3,
+ ...(Array.isArray(p.keys) && p.keys.length
+ ? { keys: p.keys.slice(0, BLOCKOUT.maxCameraKeys).map((k) => ({ t: time(k?.t), position: vec(k?.position, vec(p.position, [0, 0, 0])), rotation: clamp(finite(k?.rotation, 0), -3600, 3600) })).sort((a, b) => a.t - b.t) }
+ : {}),
+ ...(p.kind === "mesh" && typeof p.url === "string" && p.url.startsWith("/api/files/") ? { url: p.url.slice(0, 500) } : {}),
+ }));
+ const camera = (Array.isArray(s.camera) ? s.camera : [])
+ .slice(0, BLOCKOUT.maxCameraKeys)
+ .map((k) => ({
+ t: time(k?.t),
+ position: vec(k?.position, DEFAULT_CAMERA.position),
+ target: vec(k?.target, DEFAULT_CAMERA.target),
+ lens: clamp(finite(k?.lens, BLOCKOUT.lens.default), BLOCKOUT.lens.min, BLOCKOUT.lens.max),
+ shake: clamp(finite(k?.shake, 0), 0, 1),
+ }))
+ .sort((a, b) => a.t - b.t);
+ const markers = (Array.isArray(s.markers) ? s.markers : [])
+ .slice(0, BLOCKOUT.maxMarkers)
+ .map((m, i) => ({ id: String(m?.id || `m${i}`).slice(0, 40), t: time(m?.t), label: String(m?.label ?? "").trim().slice(0, 80) || `Beat ${i + 1}` }))
+ .sort((a, b) => a.t - b.t);
+ return {
+ version: 1,
+ name: String(s.name || "My blockout").slice(0, 80),
+ duration,
+ aspect: typeof s.aspect === "string" && /^\d+(\.\d+)?:\d+(\.\d+)?$/.test(s.aspect) ? s.aspect : "16:9",
+ prims,
+ camera: camera.length ? camera : [{ ...DEFAULT_CAMERA }],
+ markers,
+ };
+}
+
+// ---------------------------------------------------------------------------
+// Beats
+
+export interface Beat {
+ /** The marker it starts at ("start" when the blockout's first marker is later than 0 s). */
+ id: string;
+ /** Seconds. */
+ start: number;
+ end: number;
+ label: string;
+ /** What happens, in the user's words. */
+ words: string;
+}
+
+/**
+ * The beats of a blockout `duration` seconds long: one per marker, from it to the next (the last to the end); a stretch
+ * before the first marker is its own "Opening" beat. Markers at the same time count once; `words` by marker id.
+ */
+export function beatsFrom(markers: readonly Pick<BlockoutMarker, "id" | "t" | "label">[], duration: number, words: Record<string, string> = {}): Beat[] {
+ const end = Math.max(0, duration);
+ const list = [...markers].filter((m) => Number.isFinite(m.t) && m.t >= 0 && m.t < end - 0.05).sort((a, b) => a.t - b.t);
+ const unique = list.filter((m, i) => i === 0 || m.t - list[i - 1].t > 0.05);
+ const starts = unique.length && unique[0].t <= 0.05 ? unique : [{ id: "start", t: 0, label: "Opening" }, ...unique];
+ return starts.map((m, i) => ({
+ id: m.id,
+ start: r3(i === 0 ? 0 : m.t),
+ end: r3(i + 1 < starts.length ? starts[i + 1].t : end),
+ label: m.label.trim() || `Beat ${i + 1}`,
+ words: (words[m.id] ?? "").trim().slice(0, BLOCKOUT.maxBeatWords),
+ }));
+}
+
+/** Beats as an API or MCP caller sent them: in order, inside the blockout, no overlaps, the last one running to its end. */
+export function normalizeBeats(beats: readonly Partial<Beat>[], duration: number): Beat[] {
+ const list = beats
+ .filter((b) => b && Number.isFinite(b.start))
+ .map((b, i) => ({ id: String(b.id || `b${i}`).slice(0, 40), start: clamp(b.start!, 0, duration), label: String(b.label ?? "").trim().slice(0, 80), words: String(b.words ?? "").trim().slice(0, BLOCKOUT.maxBeatWords) }))
+ .sort((a, b) => a.start - b.start);
+ return beatsFrom(
+ list.map((b) => ({ id: b.id, t: b.start, label: b.label })),
+ duration,
+ Object.fromEntries(list.map((b) => [b.id, b.words])),
+ );
+}
+
+// ---------------------------------------------------------------------------
+// References
+
+export type RefRole = "interior" | "exterior" | "location" | "character" | "prop" | "style";
+
+export const REF_ROLES: { id: RefRole; name: string; hint: string }[] = [
+ { id: "character", name: "Character", hint: "Who the mannequin becomes" },
+ { id: "interior", name: "Interior", hint: "The room or corridor the grey boxes stand for" },
+ { id: "exterior", name: "Exterior", hint: "The outside the blockout shows" },
+ { id: "location", name: "Location", hint: "The place, inside or out" },
+ { id: "prop", name: "Prop", hint: "An object one of the boxes stands for" },
+ { id: "style", name: "Look", hint: "Only the colour, light and texture" },
+];
+
+export interface BlockoutRef {
+ url: string;
+ role: RefRole;
+ /** What it is ("Mara", "the red door"): from its element's name when it came from Elements. */
+ name?: string;
+}
+
+/** A reference's role from where it came from: Soul Cast and character elements are characters, Soul Location places. */
+export function roleFor(source: { category?: string; kind?: string } | undefined): RefRole {
+ const c = `${source?.category ?? ""} ${source?.kind ?? ""}`.toLowerCase();
+ if (/character|cast|person|face|soul-?id/.test(c)) return "character";
+ if (/location|place|set/.test(c)) return "location";
+ if (/interior|room/.test(c)) return "interior";
+ if (/exterior|outside/.test(c)) return "exterior";
+ if (/prop|object|product/.test(c)) return "prop";
+ if (/style|look|mood/.test(c)) return "style";
+ return "location";
+}
+
+const named = (r: Pick<BlockoutRef, "name">, fallback: string) => (r.name?.trim() ? `${r.name.trim()}, ${fallback}` : fallback);
+
+/** One reference's role, written for the prompt ("@Image2 is the main character: …"). `tag` is how the model names it. */
+export function roleSentence(r: Pick<BlockoutRef, "role" | "name">, tag: string): string {
+ switch (r.role) {
+ case "character":
+ return `${tag} is ${named(r, "the main character")}: the mannequin becomes this person, with this face, hair, build and wardrobe in every shot.`;
+ case "interior":
+ return `${tag} is ${named(r, "the interior")}: the grey boxes become this room, with its architecture, materials, set dressing and light.`;
+ case "exterior":
+ return `${tag} is ${named(r, "the exterior")}: what is seen outside, with its buildings, weather and light.`;
+ case "location":
+ return `${tag} is ${named(r, "the location")}: the grey boxes become this place, with its surfaces, set dressing and light.`;
+ case "prop":
+ return `${tag} is ${named(r, "a prop")}: the box that stands for it becomes this object, at the same size and place.`;
+ case "style":
+ return `${tag} is the look: match its colour, contrast, light and texture, not its content.`;
+ }
+}
+
+// ---------------------------------------------------------------------------
+// The prompt
+
+export type PromptTarget = "seedance" | "h3" | "open";
+
+export interface BlockoutPromptInput {
+ beats: readonly Beat[];
+ refs: readonly Pick<BlockoutRef, "role" | "name">[];
+ style?: string;
+ /** Extra rules ("She never looks at the camera"). */
+ constraints?: string;
+ /** What is heard: one sound per item ("Footsteps on concrete", "A distant siren"). */
+ audio?: readonly string[];
+ /** What must not happen or be seen. */
+ avoid?: readonly string[];
+ /** Seedance: @Video1 and @Image1…; H3 Max 3D: a plain scene intent of at most 2000 characters; open: Wan's short prompt. */
+ target: PromptTarget;
+ /** The tag of the last frame of the shot before (a later shot of a long blockout), when it rides along as an image. */
+ previousFrame?: number;
+ /** Sound is made (Seedance's audio on): the Audio section is written. */
+ sound?: boolean;
+}
+
+/** fal's reference syntax for Seedance 2.5: "@Image1", "@Video1". */
+export const imageTag = (i: number) => `@Image${i}`;
+export const VIDEO_TAG = "@Video1";
+/** The most H3 Max 3D to video's scene intent holds (its schema's maxLength). */
+export const H3_INTENT_MAX = 2000;
+/** Wan's text encoder reads about 512 tokens: the open engine's prompt is kept short. */
+export const OPEN_PROMPT_MAX = 1200;
+
+const sentence = (s: string) => {
+ const t = s.trim().replace(/\s+/g, " ");
+ return !t ? "" : /[.!?…]$/.test(t) ? t : `${t}.`;
+};
+const secs = (n: number) => (Math.round(n * 10) / 10).toFixed(1);
+const beatLine = (b: Beat) => `${secs(b.start)}–${secs(b.end)}s — ${b.label}${b.words ? `: ${sentence(b.words)}` : ""}`;
+
+/** The structured prompt (Subject, Action, Camera, Style, Constraints, Audio, No) for a blockout or one shot of it. */
+export function compileBlockoutPrompt(i: BlockoutPromptInput): string {
+ const beats = i.beats.filter((b) => b.end > b.start);
+ const style = sentence(i.style ?? "");
+ const order = beats.map((b) => b.label).filter(Boolean);
+ const avoid = (i.avoid ?? []).map((a) => a.trim().replace(/[.]+$/, "")).filter(Boolean);
+ const audio = (i.audio ?? []).map((a) => a.trim().replace(/[.]+$/, "")).filter(Boolean);
+ if (i.target === "open") {
+ // Wan follows the depth for camera and blocking: the words say what it looks like and what happens, briefly.
+ const who = i.refs.filter((r) => r.role === "character" && r.name?.trim()).map((r) => r.name!.trim());
+ const parts = [style, who.length ? `${who.join(" and ")} in the scene.` : "", ...beats.map((b) => sentence(b.words || b.label)), "Cinematic, photographic, natural motion, consistent identity and set."];
+ return cap(parts.filter(Boolean).join(" "), OPEN_PROMPT_MAX);
+ }
+ const seedance = i.target === "seedance";
+ const tag = (n: number) => (seedance ? imageTag(n) : `Reference ${n}`);
+ const subject = [
+ seedance
+ ? `${VIDEO_TAG} is a grey-box 3D blockout: it sets the camera path, framing, blocking, environment geometry and timing. Its grey boxes, planes and mannequins are stand-ins.`
+ : "The video is a grey-box 3D blockout: its grey boxes, planes and mannequins are stand-ins for the real set and people.",
+ ...i.refs.map((r, k) => roleSentence(r, tag(k + 1))),
+ ...(i.previousFrame ? [`${tag(i.previousFrame)} is the last frame of the shot before this one: start exactly from it, with the same people, set and light.`] : []),
+ ];
+ const camera = seedance
+ ? `Follow ${VIDEO_TAG} exactly: preserve the blockout's shot sizes, angles, camera positions, lens, handheld movement and cuts; nothing moves the camera that the blockout doesn't.`
+ : "Camera, movement and timing come from the video: keep them exactly.";
+ const rules = [
+ order.length > 1 ? `Events happen in this order: ${order.join(", then ")}.` : "",
+ "Every person, place and object stays consistent with its reference in every shot.",
+ "Replace every grey box with the real surface it stands for; never show grey geometry, a mannequin or a wireframe.",
+ sentence(i.constraints ?? ""),
+ ].filter(Boolean);
+ const sections: [string, string][] = [
+ ["Subject", subject.join(" ")],
+ ["Action", beats.map(beatLine).join("\n")],
+ ["Camera", camera],
+ ["Style", style],
+ ["Constraints", rules.join(" ")],
+ ["Audio", i.sound && audio.length ? `${audio.join("; ")}.` : ""],
+ ["No", avoid.length ? `${avoid.join(", ")}.` : ""],
+ ];
+ const text = sections
+ .filter(([, body]) => body)
+ .map(([h, body]) => (h === "Action" ? `${h}:\n${body}` : `${h}: ${body}`))
+ .join("\n\n");
+ return seedance ? text : cap(text, H3_INTENT_MAX);
+}
+
+/** At most `max` characters, cut at a sentence or a line where it can be. */
+function cap(text: string, max: number): string {
+ if (text.length <= max) return text;
+ const cut = text.slice(0, max);
+ const at = Math.max(cut.lastIndexOf(". "), cut.lastIndexOf("\n"));
+ return (at > max * 0.6 ? cut.slice(0, at + 1) : cut.slice(0, max - 1) + "…").trim();
+}
+
+/** The beats inside a stretch of the blockout, clipped to it and timed from its start (a shot's own clock). */
+export function beatsIn(beats: readonly Beat[], start: number, end: number): Beat[] {
+ return beats
+ .filter((b) => b.end > start + 0.01 && b.start < end - 0.01)
+ .map((b) => ({ ...b, start: r3(Math.max(b.start, start) - start), end: r3(Math.min(b.end, end) - start) }));
+}
+
+// ---------------------------------------------------------------------------
+// Shots (a blockout longer than one call) and the open engine's windows
+
+export interface Shot {
+ index: number;
+ /** Seconds of the blockout. */
+ start: number;
+ end: number;
+}
+
+/**
+ * Cut a blockout `duration` seconds long into shots of at most `max` seconds, at the markers (`cuts`, seconds) where it
+ * can: each shot ends at the latest marker that keeps it within `max` (and leaves at least `min` for what follows), else
+ * at `max` exactly. A blockout within `max` is one shot.
+ */
+export function splitShots(duration: number, cuts: readonly number[], max: number, min = 2): Shot[] {
+ const total = Math.max(0, duration);
+ const marks = [...new Set(cuts.filter((c) => c > 0 && c < total).map(r3))].sort((a, b) => a - b);
+ const shots: Shot[] = [];
+ let start = 0;
+ while (total - start > 1e-6) {
+ if (total - start <= max + 1e-6) {
+ shots.push({ index: shots.length, start: r3(start), end: r3(total) });
+ break;
+ }
+ const fits = marks.filter((c) => c - start >= min - 1e-6 && c - start <= max + 1e-6 && total - c >= min - 1e-6);
+ let end = fits.length ? fits[fits.length - 1] : start + max;
+ if (total - end < min) end = total - min;
+ shots.push({ index: shots.length, start: r3(start), end: r3(end) });
+ start = end;
+ }
+ return shots;
+}
+
+/** The open engine works at 16 fps in windows of 81 frames (Wan 2.2 Fun VACE). */
+export const OPEN_FPS = 16;
+export const OPEN_WINDOW = 81;
+/** The most windows one blockout makes on the open engine (12 ≈ 60 s). */
+export const OPEN_MAX_WINDOWS = 12;
+
+export interface DepthWindow {
+ index: number;
+ /** Frames of the 16 fps depth video. */
+ startFrame: number;
+ frames: number;
+ /** Seconds (what the segment cut is given): exact, so the cut keeps exactly `frames` frames. */
+ start: number;
+ end: number;
+}
+
+/**
+ * The 81-frame windows over a blockout `seconds` long at `fps`: each starts on the last frame of the one before (that
+ * frame, as the window rendered it, is the next window's first frame, so they chain without a jump), and each holds 4n+1
+ * frames (Wan's grid). A tail shorter than 9 frames is folded into nothing: the film ends with the last full window's
+ * frame, at most half a second early.
+ */
+export function depthWindows(seconds: number, fps = OPEN_FPS, size = OPEN_WINDOW): DepthWindow[] {
+ const total = Math.floor(Math.max(0, seconds) * fps + 1e-6);
+ const out: DepthWindow[] = [];
+ let at = 0;
+ while (out.length < OPEN_MAX_WINDOWS) {
+ const left = total - at;
+ const frames = Math.min(size, Math.floor((left - 1) / 4) * 4 + 1);
+ if (frames < 9 && out.length) break;
+ if (frames < 5) break;
+ out.push({ index: out.length, startFrame: at, frames, start: at / fps, end: (at + frames) / fps });
+ if (frames < size) break;
+ at += frames - 1;
+ }
+ return out;
+}
+
+/** How many seconds the windows render (the joined film repeats one frame at each seam: the chain's hand-over). */
+export const windowsSeconds = (w: readonly DepthWindow[]) => (w.length ? r3((w[w.length - 1].startFrame + w[w.length - 1].frames) / OPEN_FPS) : 0);
diff --git a/src/lib/catalog/cinema.ts b/src/lib/catalog/cinema.ts
index e862604b..533b38a5 100644
--- a/src/lib/catalog/cinema.ts
+++ b/src/lib/catalog/cinema.ts
@@ -1,3 +1,4 @@
+import { BLOCKOUT, OPEN_FPS, beatsIn, compileBlockoutPrompt, depthWindows, normalizeBeats, splitShots, windowsSeconds, type Beat, type BlockoutRef } from "@/lib/blockout";
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";
@@ -166,6 +167,8 @@ export interface CinemaTakeInfo {
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 filmed blockout: its length, how many shots or windows it was filmed in, and its beats. */
+ blockout?: { seconds: number; parts: number; beats: string[] };
}
/** A generation's membership in a project (and its folder = scene). */
@@ -200,7 +203,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" | "path" | "turnaround";
+export type CinemaAction = "generate" | "extend-forward" | "extend-backward" | "edit" | "grid" | "cast" | "location" | "location-view" | "scene" | "recompose" | "path" | "turnaround" | "blockout";
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>;
@@ -238,6 +241,29 @@ export interface CinemaGenerateInput {
path?: ScenePath;
/** "turnaround": a 360° turnaround of a Soul Cast result (build plan N7-6: src/lib/catalog/turnaround.ts). */
turnaround?: Omit<TurnaroundInput, "engine" | "feature" | "stepFeature">;
+ /** "blockout": a grey-box blockout filmed with references and beats (package blockout-film: src/lib/blockout.ts). */
+ blockout?: BlockoutRun;
+}
+
+/** A blockout to film: the grey box (and its depth), its beats and references, and the words around them. */
+export interface BlockoutRun {
+ /** The grey-box render (uploaded from any 3D app, or rendered by Cinema's builder). */
+ video: string;
+ /** Its depth pass, near = bright (the builder renders one at 16 fps; Blender's mist / Z pass works too). */
+ depth?: string;
+ /** Its first frame as a picture (the builder saves one): the open engine draws the film's first frame from it. */
+ firstFrame?: string;
+ /** Seconds. */
+ seconds: number;
+ /** Each beat's start (seconds), name and words; it runs to the next one (normalizeBeats). */
+ beats: (Pick<Beat, "start" | "label"> & Partial<Beat>)[];
+ refs: BlockoutRef[];
+ style?: string;
+ constraints?: string;
+ /** What is heard, one sound per item. */
+ sounds?: string[];
+ /** What must not happen or be seen. */
+ avoid?: string[];
}
export interface ScenePath {
@@ -1411,6 +1437,7 @@ const FEATURES: Partial<Record<CinemaAction, string>> = {
recompose: "cinema-recompose",
path: "cinema-path",
turnaround: "cinema-turnaround",
+ blockout: "cinema-blockout",
};
const feature = (action: CinemaAction, mode: CinemaMode) => FEATURES[action] ?? (mode === "image" ? "cinema-image" : "cinema");
@@ -2105,6 +2132,244 @@ function planTurnaroundTake(input: CinemaGenerateInput, ctx: CinemaContext): Cin
return finish(plan.model, plan.steps, plan.notes, plan.blocker);
}
+// ---------------------------------------------------------------------------
+// Blockout to film (package blockout-film; new-models-10.md §5): a grey-box blockout sets the camera, blocking and timing,
+// references and a timecoded beat prompt say what it becomes
+
+/**
+ * What films a blockout. Cloud: Seedance 2.5 reference mode (the blockout as @Video1, the stills as @Image1…, sound on)
+ * or MiniMax H3 Max 3D to video (fal's own blockout model, under its name: up to 8 stills, no sound). Open: Wan 2.2 Fun
+ * VACE driven by the blockout's depth from a first frame drawn from the references; an upload with no depth pass runs the
+ * restyle graph, which reads the depth from the grey box with Depth Anything 3.
+ */
+export const BLOCKOUT_MODELS = {
+ cloud: ["seedance-2-5", "minimax-h3-max-3d"],
+ open: "oss-wan22-vace-blockout",
+ openNoDepth: "oss-wan22-vace-restyle",
+ /** The open engine's first frame: Qwen-Image-Edit 2511 (the grey box's first frame + up to 2 references). */
+ firstFrame: "oss-qwen-edit",
+} as const;
+
+/**
+ * Each cloud model's shot: the longest and shortest (seconds) and the stills it takes. Seedance 2.5 reads reference
+ * clips of 1.8–30.2 s and makes 4–30 s (fal, read 2026-11-01; Cinema sends it 4 stills with clips); H3 Max 3D to video
+ * reads up to 15 s and 8 stills and bills at least 5 s a shot.
+ */
+export const BLOCKOUT_SHOTS: Record<string, { max: number; min: number; refs: number; tag: "seedance" | "h3" }> = {
+ "seedance-2-5": { max: 30, min: 4, refs: 4, tag: "seedance" },
+ "minimax-h3-max-3d": { max: 15, min: 2, refs: 8, tag: "h3" },
+};
+
+/** The utilities a blockout's steps use, per engine. */
+const BLOCKOUT_TOOLS = {
+ cloud: { cut: "trim-video", frame: "extract-frame", join: "join-clips" },
+ open: { cut: "oss-segment", frame: "oss-extract-frame", join: "oss-join-encoded" },
+} as const;
+
+export const BLOCKOUT_FIRST = "Add a blockout first: upload a grey-box render or build one";
+
+const secs1 = (n: number) => `${Math.round(n * 10) / 10}`;
+
+/** The words that turn the grey box's first frame into the film's (Qwen-Image-Edit: picture 1 is the grey box). */
+export function blockoutFramePrompt(refs: readonly BlockoutRef[], style?: string): string {
+ const roles = refs.map((r, k) => `picture ${k + 2} is ${r.role === "character" ? "the person the mannequin becomes" : r.role === "style" ? "the look (its colour and light only)" : r.role === "prop" ? "a prop a box stands for" : `the ${r.role === "location" ? "place" : r.role}`}${r.name?.trim() ? ` (${r.name.trim()})` : ""}`);
+ return [
+ "Turn picture 1, a grey-box 3D blockout frame, into a finished photographic film frame.",
+ "Keep its exact camera, framing, perspective, layout and the figure's pose; the grey boxes become the real set and the mannequin becomes a real person.",
+ roles.length ? `${roles.join("; ")}.`.replace(/^p/, "P") : "",
+ tidy(style) ? `${tidy(style)}.` : "",
+ "No grey geometry, no mannequin, no text.",
+ ]
+ .filter(Boolean)
+ .join(" ");
+}
+
+/**
+ * Film a blockout. Cloud: one call when it fits the model (Seedance 2.5: 30 s, H3 Max 3D: 15 s), else shots cut at the
+ * beat markers, each with its own stretch of the blockout (a trim), its beats timed from its start and the last frame of
+ * the shot before as one more still (continuity), then joined. Open: the first frame drawn from the references, then
+ * 81-frame windows of the depth at 16 fps, each starting from the last frame of the one before, then joined.
+ */
+function planBlockout(input: CinemaGenerateInput, ctx: CinemaContext): CinemaPlan {
+ const b = input.blockout;
+ const notes: string[] = [];
+ const open = input.engine === "open";
+ const seconds = Math.max(0, Math.min(BLOCKOUT.maxSeconds, b?.seconds ?? 0));
+ const beats = normalizeBeats(b?.beats ?? [], seconds);
+ const refs = (b?.refs ?? []).slice(0, BLOCKOUT.maxRefs);
+ const words = { style: b?.style, constraints: b?.constraints, audio: b?.sounds, avoid: b?.avoid };
+ let blocker = !b?.video ? BLOCKOUT_FIRST : seconds < BLOCKOUT.minSeconds ? `A blockout needs at least ${BLOCKOUT.minSeconds} s` : undefined;
+ const feature = "cinema-blockout";
+ const video = b?.video ?? PLACEHOLDER.video;
+ const steps: CinemaStep[] = [];
+ const labels: Record<string, string> = {};
+
+ if (open) {
+ const has = ctx.has ?? ((id: string) => !!getModel(id));
+ const depth = !!b?.depth;
+ const modelId = depth ? BLOCKOUT_MODELS.open : BLOCKOUT_MODELS.openNoDepth;
+ const model = getModel(modelId);
+ if (!model || !has(modelId)) return finish(getModel(BLOCKOUT_MODELS.open) ?? getModel(BLOCKOUT_MODELS.openNoDepth)!, [], notes, blocker ?? "Blockout on your GPU needs the Wan 2.2 Fun VACE workflows — switch to Cloud for this one");
+ const t = BLOCKOUT_TOOLS.open;
+ const windows = depthWindows(seconds);
+ const made = windowsSeconds(windows);
+ const aspectRatio = input.aspectRatio && model.options.aspectRatios?.includes(input.aspectRatio) ? input.aspectRatio : "16:9";
+ const resolution = input.resolution === "720p" ? "720p" : "480p";
+ notes.push(
+ `On your GPU: the blockout's ${depth ? "depth" : "grey box (Depth Anything 3 reads its depth)"} drives Wan 2.2 Fun VACE from a first frame drawn from your references, in ${windows.length} window${windows.length === 1 ? "" : "s"} of up to ${OPEN_FPS * 5 + 1} frames at ${OPEN_FPS} fps${windows.length > 1 ? ", each starting from the last frame of the one before, then joined" : ""} — about 24 GB of VRAM`,
+ "It follows the blockout's depth and timing, not the dialogue or sound: add sound afterwards with Sound for video",
+ );
+ if (seconds - made > 0.6) notes.push(`The open engine renders up to ${Math.round(made)} s of this blockout (${Math.round(seconds)} s)`);
+ if (input.prompt.trim()) notes.push("Your edited prompt is for the cloud models: on your GPU each window gets its own beats as words");
+ // The first frame: the builder's still of the grey box, or the upload's first frame cut out.
+ const frameRefs = refs.slice(0, 2);
+ if (refs.length > frameRefs.length) notes.push(`Qwen-Image-Edit draws the first frame from the grey box and your first ${frameRefs.length} references`);
+ if (!b?.firstFrame) {
+ steps.push({ key: "grab", request: { feature, modelId: t.frame, op: "frame", inputs: { video }, params: { startTime: 0, endTime: 0.5, extra: { frameIndex: 0 } } } });
+ labels.grab = "Blockout's first frame";
+ }
+ steps.push({
+ key: "look",
+ ...(b?.firstFrame ? {} : { after: ["grab"] }),
+ request: {
+ feature,
+ modelId: BLOCKOUT_MODELS.firstFrame,
+ op: "edit",
+ prompt: blockoutFramePrompt(frameRefs, b?.style),
+ inputs: { images: [...(b?.firstFrame ? [b.firstFrame] : []), ...frameRefs.map((r) => r.url)] },
+ params: { numOutputs: 1 },
+ ...(b?.firstFrame ? {} : { chain: [{ slot: "images" as const, position: "first" as const }] }),
+ },
+ });
+ labels.look = "First frame from your references";
+ windows.forEach((w, k) => {
+ const part = windows.length > 1 ? ` ${k + 1}/${windows.length}` : "";
+ steps.push({
+ key: `seg${k}`,
+ request: { feature, modelId: t.cut, op: "trim", inputs: { video: b?.depth ?? video }, params: { startTime: w.start, endTime: w.end, fps: OPEN_FPS, aspectRatio, resolution } },
+ });
+ labels[`seg${k}`] = `Blockout${part}`;
+ steps.push({
+ key: `win${k}`,
+ after: [`seg${k}`, k === 0 ? "look" : `last${k - 1}`],
+ request: {
+ feature,
+ modelId,
+ op: "v2v",
+ prompt: compileBlockoutPrompt({ beats: beatsIn(beats, w.start, w.end), refs, target: "open", ...words }),
+ params: { aspectRatio, resolution, duration: w.frames / OPEN_FPS, numOutputs: 1 },
+ chain: [{ slot: "video" }, { slot: "images", position: "first" }],
+ },
+ });
+ labels[`win${k}`] = windows.length > 1 ? `Film${part}` : "Film";
+ if (k < windows.length - 1) {
+ steps.push({ key: `last${k}`, after: [`win${k}`], request: { feature, modelId: t.frame, op: "frame", chain: [{ slot: "video" }] } });
+ labels[`last${k}`] = `Hand-over frame${part}`;
+ }
+ });
+ if (windows.length > 1) {
+ steps.push({ key: "join", after: windows.map((_, k) => `win${k}`), request: { feature, modelId: t.join, op: "concat", prompt: "Blockout film", chain: windows.map(() => ({ slot: "videos" as const })) } });
+ labels.join = "Blockout film";
+ }
+ if (!windows.length) blocker ??= `A blockout needs at least ${BLOCKOUT.minSeconds} s`;
+ return { ...finish(model, label(steps, labels), notes, undefined, windows.length > 1 ? "join" : "win0"), ...(blocker ? { blocker } : {}) };
+ }
+
+ const modelId = input.modelId && BLOCKOUT_MODELS.cloud.includes(input.modelId as (typeof BLOCKOUT_MODELS.cloud)[number]) ? input.modelId : BLOCKOUT_MODELS.cloud[0];
+ const model = modelOn(modelId, "cloud") ?? getModel(modelId)!;
+ const lim = BLOCKOUT_SHOTS[model.id];
+ const t = BLOCKOUT_TOOLS.cloud;
+ const shots = splitShots(seconds, beats.map((x) => x.start), lim.max, lim.min);
+ const many = shots.length > 1;
+ const seedance = lim.tag === "seedance";
+ const offered = model.options.resolutions ?? [];
+ const resolution = offered.find((r) => r.toLowerCase() === input.resolution?.toLowerCase()) ?? model.defaults?.resolution;
+ const aspectRatio = seedance ? (input.aspectRatio && model.options.aspectRatios?.includes(input.aspectRatio) ? input.aspectRatio : "auto") : undefined;
+ const sound = seedance && input.audio !== false;
+ // A later shot carries the last frame of the one before as one more still.
+ const keep = many ? lim.refs - 1 : lim.refs;
+ const used = refs.slice(0, keep);
+ if (refs.length > used.length) notes.push(`${model.name} takes ${keep} reference still${keep === 1 ? "" : "s"}${many ? " beside the hand-over frame" : ""}: the first ${keep} go`);
+ notes.push(
+ seedance
+ ? `${model.name} follows the blockout as its reference video (@Video1) with your stills as @Image1–${Math.max(1, used.length)}${sound ? ", sound on" : ""}`
+ : `${model.name} renders the blockout from your stills; camera, blocking and timing come from the video. It makes no sound: add it afterwards with Sound for video`,
+ );
+ if (many) {
+ notes.push(
+ `The blockout is ${secs1(seconds)} s, longer than ${model.name}'s ${lim.max} s, so it is filmed as ${shots.length} shots cut at your markers (${shots.map((s) => `${secs1(s.start)}–${secs1(s.end)} s`).join(", ")}); each starts from the last frame of the one before, then they're joined`,
+ );
+ if (input.prompt.trim()) notes.push("Your edited prompt is for a one-shot film: each shot gets its own beats, timed from its start");
+ }
+ shots.forEach((shot, k) => {
+ const part = many ? ` ${k + 1}/${shots.length}` : "";
+ const len = shot.end - shot.start;
+ const duration = seedance ? Math.max(lim.min, Math.min(lim.max, Math.ceil(len - 1e-6))) : Math.round(len * 100) / 100;
+ if (seedance && duration - len > 0.6) notes.push(`${model.name} makes at least ${lim.min} s, so shot${part || " 1"} runs ${secs1(duration - len)} s past the blockout`);
+ const prev = k > 0 ? used.length + 1 : undefined;
+ const compiled = compileBlockoutPrompt({ beats: beatsIn(beats, shot.start, shot.end), refs: used, target: lim.tag, previousFrame: prev, sound, ...words });
+ const prompt = !many && input.prompt.trim() ? input.prompt.trim() : compiled;
+ const after: string[] = [];
+ const chain: GenerationRequest["chain"] = [];
+ let inputs: GenerationRequest["inputs"] = used.length ? { images: used.map((r) => r.url) } : undefined;
+ if (many) {
+ steps.push({ key: `cut${k}`, request: { feature, modelId: t.cut, engine: "cloud", op: "trim", inputs: { video }, params: { startTime: shot.start, endTime: shot.end } } });
+ labels[`cut${k}`] = `Blockout${part}`;
+ after.push(`cut${k}`);
+ chain.push({ slot: seedance ? "videos" : "video", position: "first" });
+ if (k > 0) {
+ after.push(`last${k - 1}`);
+ chain.push({ slot: "images", position: "last" });
+ }
+ } else inputs = { ...inputs, ...(seedance ? { videos: [video] } : { video }) };
+ const params: GenParams = {
+ numOutputs: 1,
+ duration,
+ ...(resolution ? { resolution } : {}),
+ ...(aspectRatio ? { aspectRatio } : {}),
+ ...(seedance ? { generateAudio: sound } : {}),
+ };
+ steps.push({
+ key: `shot${k}`,
+ ...(after.length ? { after } : {}),
+ request: { feature, modelId: model.id, engine: "cloud", op: seedance ? "ref2v" : "v2v", prompt, inputs, params, ...(chain.length ? { chain } : {}) },
+ });
+ labels[`shot${k}`] = many ? `Shot${part}` : "Film";
+ if (many && k < shots.length - 1) {
+ steps.push({ key: `last${k}`, after: [`shot${k}`], request: { feature, modelId: t.frame, engine: "cloud", op: "frame", chain: [{ slot: "video" }] } });
+ labels[`last${k}`] = `Hand-over frame${part}`;
+ }
+ });
+ if (many) {
+ steps.push({ key: "join", after: shots.map((_, k) => `shot${k}`), request: { feature, modelId: t.join, engine: "cloud", op: "concat", prompt: "Blockout film", chain: shots.map(() => ({ slot: "videos" as const })) } });
+ labels.join = "Blockout film";
+ }
+ if (!shots.length) blocker ??= `A blockout needs at least ${BLOCKOUT.minSeconds} s`;
+ // Priced before it can run (with a stand-in for the blockout while there is none), so the button shows the cost early.
+ return { ...finish(model, label(steps, labels), notes, undefined, many ? "join" : "shot0"), ...(blocker ? { blocker } : {}) };
+}
+
+/** The prompt a blockout's one-shot cloud film starts from (the composer shows it, editable), or the open engine's first window's. */
+export function blockoutPrompt(input: Pick<CinemaGenerateInput, "engine" | "modelId" | "audio" | "blockout">): string {
+ const b = input.blockout;
+ if (!b) return "";
+ const seconds = Math.max(0, Math.min(BLOCKOUT.maxSeconds, b.seconds));
+ const beats = normalizeBeats(b.beats, seconds);
+ const words = { style: b.style, constraints: b.constraints, audio: b.sounds, avoid: b.avoid };
+ if (input.engine === "open") return compileBlockoutPrompt({ beats: beatsIn(beats, 0, depthWindows(seconds)[0]?.end ?? seconds), refs: b.refs, target: "open", ...words });
+ const lim = BLOCKOUT_SHOTS[input.modelId ?? ""] ?? BLOCKOUT_SHOTS[BLOCKOUT_MODELS.cloud[0]];
+ const refs = b.refs.slice(0, lim.refs);
+ return compileBlockoutPrompt({ beats, refs, target: lim.tag, sound: lim.tag === "seedance" && input.audio !== false, ...words });
+}
+
+/** What a filmed blockout's take remembers. */
+export function blockoutTake(input: Pick<CinemaGenerateInput, "blockout">, plan: CinemaPlan): CinemaTakeInfo["blockout"] {
+ const b = input.blockout;
+ if (!b) return undefined;
+ const parts = plan.steps.filter((s) => /^(shot|win)\d+$/.test(s.key)).length;
+ return { seconds: Math.round(b.seconds * 100) / 100, parts, beats: normalizeBeats(b.beats, b.seconds).map((x) => x.label).slice(0, BLOCKOUT.maxMarkers) };
+}
+
/** 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 ?? "" };
@@ -2129,6 +2394,8 @@ export function planCinema(input: CinemaGenerateInput, ctx: CinemaContext): Cine
return planPath(i);
case "turnaround":
return planTurnaroundTake(i, ctx);
+ case "blockout":
+ return planBlockout(i, ctx);
default:
return i.mode === "image" ? planStill(i) : planVideo(i, ctx);
}
diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.ts
index 18053da0..5a6584b7 100644
--- a/src/lib/catalog/cloud-models.generated.ts
+++ b/src/lib/catalog/cloud-models.generated.ts
@@ -6896,6 +6896,51 @@ export const CLOUD_MODELS: ModelDef[] = [
},
"hidden": true
},
+ {
+ "id": "minimax-h3-max-3d",
+ "name": "MiniMax H3 Max 3D to video",
+ "vendor": "MiniMax",
+ "family": "hailuo",
+ "engine": "cloud",
+ "kind": "video",
+ "tagline": "A grey-box blockout from Blender or the browser, rendered as a finished shot from your reference stills",
+ "routes": [
+ {
+ "op": "v2v",
+ "provider": "fal",
+ "endpoint": "minimax/h3-max/3d-to-video",
+ "map": {
+ "images": "reference_image_urls",
+ "video": "video_url",
+ "resolution": "resolution"
+ }
+ }
+ ],
+ "options": {
+ "resolutions": [
+ "480P",
+ "768P",
+ "1080P"
+ ],
+ "maxImages": 8
+ },
+ "defaults": {
+ "resolution": "768P"
+ },
+ "pricing": {
+ "unit": "second",
+ "usd": 0.08,
+ "note": "768P; 480P $0.05, 1080P $0.16; at least 5 s a shot; + $0.50 processing a request",
+ "byResolution": {
+ "480P": 0.05,
+ "768P": 0.08,
+ "1080P": 0.16
+ },
+ "minSeconds": 5,
+ "perRequest": 0.5
+ },
+ "hidden": true
+ },
{
"id": "hailuo-2-3",
"name": "MiniMax Hailuo 2.3",
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index 025ac686..ba5c6f32 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -1308,6 +1308,25 @@ const open: ModelDef[] = [
defaults: { aspectRatio: "16:9", resolution: "480p", duration: 5 },
hidden: true,
}),
+ // Blockout to film (package blockout-film): the grey box's own depth drives Wan 2.2 Fun VACE from a first frame drawn
+ // from the references, one 81-frame window per job (Cinema's Blockout chains the windows). Ref2v: Canvas's "Blockout →
+ // film" template hands it the depth clip and the first frame as references.
+ o({
+ id: "oss-wan22-vace-blockout",
+ name: "Wan 2.2 Fun VACE Blockout",
+ vendor: "Alibaba Wan",
+ family: "wan",
+ kind: "video",
+ tagline: "Renders a grey-box blockout from its depth and a first frame: camera, blocking and timing kept · 24 GB GPU · Apache-2.0",
+ badges: ["new"],
+ routes: [
+ comfy("v2v", "video-blockout-wan22-fun-vace", "video = the blockout's depth (near = bright); image = the first frame; Lightx2v 4-step"),
+ comfy("ref2v", "video-blockout-wan22-fun-vace", "the depth clip and the first frame as references"),
+ ],
+ options: { aspectRatios: VID_AR, resolutions: ["480p", "720p"], durations: [3, 4, 5], seed: true, negativePrompt: true, maxImages: 1, maxVideos: 1 },
+ defaults: { aspectRatio: "16:9", resolution: "480p", duration: 5 },
+ hidden: true,
+ }),
o({
id: "oss-mixed-media",
name: "Z-Image Mixed Media",
diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.ts
index b18bc382..d64e3275 100644
--- a/src/lib/catalog/plan.ts
+++ b/src/lib/catalog/plan.ts
@@ -1022,7 +1022,8 @@ export function estimateCost(model: ModelDef, params: GenParams, jobs = 1, op?:
if (clipped) per = clipped.rate * clipped.billed;
else if (p.unit === "second") {
// A length the caller set wins (Shorts, Mixed Media and Genjutsu say the seconds they bill); then a clip edit's clip.
- const seconds = clip ?? voice ?? params.duration ?? clipEditSeconds(model, params, op) ?? model.defaults?.duration ?? 5;
+ const asked = clip ?? voice ?? params.duration ?? clipEditSeconds(model, params, op) ?? model.defaults?.duration ?? 5;
+ const seconds = p.minSeconds ? Math.max(p.minSeconds, Math.ceil(asked - 1e-9)) : asked;
const mp = p.videoMegapixel ? videoMegapixels(model, params, seconds) : undefined;
const rate = p.videoMegapixel && (withLoras && p.videoMegapixel.withLoras !== undefined ? p.videoMegapixel.withLoras : p.videoMegapixel.usd);
per = mp !== undefined && rate ? Math.ceil(mp - 1e-9) * rate : usd * seconds;
@@ -1036,5 +1037,6 @@ export function estimateCost(model: ModelDef, params: GenParams, jobs = 1, op?:
}
if (params.generateAudio === false && model.options.audio === true && p.note?.includes("audio-off-half")) per /= 2;
if (p.animationUsd && params.animation !== undefined && params.animation !== "") per += p.animationUsd;
+ if (p.perRequest) per += p.perRequest;
return Math.round(per * jobs * 1000) / 1000;
}
diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.ts
index c7f900a7..11dda862 100644
--- a/src/lib/catalog/types.ts
+++ b/src/lib/catalog/types.ts
@@ -706,6 +706,10 @@ export interface Pricing {
* otherwise input + output"), in place of `usd` / `byResolution`.
*/
clipInput?: { usd: number; byResolution?: Record<string, number> };
+ /** A fixed fee each request adds on top of its seconds (fal's H3 Max 3D to video: $0.50 processing). */
+ perRequest?: number;
+ /** The fewest seconds a per-second request bills (fal's H3 Max 3D to video: 5 s a shot). */
+ minSeconds?: number;
}
/** A model's weights licence, as read in the research: information, never a gate (the owner's decision of 2026-10-27). */
diff --git a/src/server/cinema-generate.ts b/src/server/cinema-generate.ts
index 2abeec4e..c76c6872 100644
--- a/src/server/cinema-generate.ts
+++ b/src/server/cinema-generate.ts
@@ -3,6 +3,7 @@ import { nanoid } from "nanoid";
import { getModel } from "@/lib/catalog";
import {
SWATCH_PLACEHOLDER,
+ blockoutTake,
pathTake,
planCinema,
withPlaceholders,
@@ -143,6 +144,7 @@ export function generateInProject(projectId: string, input: CinemaRequest, folde
...(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: pathTake(input, plan) } : {}),
+ ...(input.action === "blockout" && input.blockout ? { blockout: blockoutTake(input, plan) } : {}),
};
const batchId = nanoid(10);
const made: Record<string, Generation[]> = {};
diff --git a/src/server/cinema-schemas.ts b/src/server/cinema-schemas.ts
index 6fc163ae..28b86418 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 { BLOCKOUT } from "@/lib/blockout";
import { DISTANCE, MAX_KEYS } from "@/lib/camera-path";
import { APERTURE, LENS } from "@/lib/scene3d";
import { CinemaError } from "./cinema";
@@ -78,12 +79,34 @@ export const TilesPut = z.object({ tiles: z.array(z.object({ url: FileRef, row:
const Shot = z.object({ prompt: z.string().max(2000), duration: z.number().min(1).max(30) });
+const Words = z.string().trim().max(BLOCKOUT.maxBeatWords);
+
+/** A blockout to film (src/lib/catalog/cinema.ts BlockoutRun; Assist's blockout_film takes the same). */
+export const BlockoutSchema = z.object({
+ video: FileRef,
+ depth: FileRef.optional(),
+ firstFrame: FileRef.optional(),
+ seconds: z.number().min(BLOCKOUT.minSeconds).max(BLOCKOUT.maxSeconds),
+ beats: z
+ .array(z.object({ id: z.string().max(40).optional(), start: z.number().min(0).max(BLOCKOUT.maxSeconds), end: z.number().min(0).max(BLOCKOUT.maxSeconds).optional(), label: z.string().trim().max(80), words: Words.default("") }))
+ .max(BLOCKOUT.maxMarkers)
+ .default([]),
+ refs: z
+ .array(z.object({ url: FileRef, role: z.enum(["interior", "exterior", "location", "character", "prop", "style"]), name: z.string().trim().max(60).optional() }))
+ .max(BLOCKOUT.maxRefs)
+ .default([]),
+ style: Words.optional(),
+ constraints: Words.optional(),
+ sounds: z.array(z.string().trim().max(120)).max(12).optional(),
+ avoid: z.array(z.string().trim().max(120)).max(16).optional(),
+});
+
export const GenerateBody = z.object({
folderId: z.string().max(40).nullable().optional(),
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", "path", "turnaround"]).default("generate"),
+ action: z.enum(["generate", "extend-forward", "extend-backward", "edit", "grid", "cast", "location", "location-view", "scene", "recompose", "path", "turnaround", "blockout"]).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(),
@@ -143,6 +166,8 @@ export const GenerateBody = z.object({
.optional(),
// Turnaround (N7-6): the Soul Cast result's pictures by side, the route and length (the engine is the run's).
turnaround: TurnaroundSchema.omit({ engine: true, realPerson: true, consent: true }).optional(),
+ // Blockout to film: the grey box (its depth and first frame when the builder made them), beats, references, words.
+ blockout: BlockoutSchema.optional(),
}),
});
diff --git a/tests/blockout.test.ts b/tests/blockout.test.ts
new file mode 100644
index 00000000..e8797193
--- /dev/null
+++ b/tests/blockout.test.ts
@@ -0,0 +1,384 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, beforeAll, describe, expect, it } from "vitest";
+import type { CinemaGenerateInput } from "@/lib/catalog/cinema";
+
+/** Blockout to film (package blockout-film): the scene maths, beats, prompts, shots, windows, plans, payloads and the API. */
+
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-blockout-"));
+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 { prepareWorkflow } = await import("@/server/providers/comfyui");
+const { BLOCKOUT_FIRST, BLOCKOUT_MODELS, blockoutFramePrompt, blockoutPrompt, planCinema } = await import("@/lib/catalog/cinema");
+const B = await import("@/lib/blockout");
+
+beforeAll(() => {
+ setSetting("demoMode", "auto");
+ setSetting("enhanceProvider", "none");
+});
+afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));
+
+const VIDEO = "/api/files/uploads/blockout.webm";
+const DEPTH = "/api/files/uploads/blockout-depth.webm";
+const FRAME = "/api/files/uploads/blockout-first.png";
+const REFS: import("@/lib/blockout").BlockoutRef[] = [
+ { url: "/api/files/uploads/interior.png", role: "interior" },
+ { url: "/api/files/uploads/mara.png", role: "character", name: "Mara" },
+ { url: "/api/files/uploads/exterior.png", role: "exterior" },
+];
+const exampleBeats = () => B.beatsFrom(B.EXAMPLE_SCENE.markers, B.EXAMPLE_SCENE.duration, B.EXAMPLE_WORDS);
+const ctx = { cloudAllowed: true };
+const film = (engine: "cloud" | "open", over: Partial<NonNullable<CinemaGenerateInput["blockout"]>> = {}, more: Partial<CinemaGenerateInput> = {}): CinemaGenerateInput => ({
+ engine,
+ mode: "video",
+ action: "blockout",
+ prompt: "",
+ settings: {},
+ blockout: { video: VIDEO, seconds: 8, beats: exampleBeats(), refs: REFS, style: "Low-key horror, cold torchlight, 35 mm film grain", sounds: ["Footsteps on concrete", "A long door creak"], avoid: ["jump cuts", "text on screen"], ...over },
+ ...more,
+});
+
+describe("the scene", () => {
+ it("moves a primitive in a line between its keys and holds before and after them", () => {
+ const walker = B.EXAMPLE_SCENE.prims.find((p) => p.id === "walker")!;
+ expect(B.primAt(walker, -1).position).toEqual([0, 0, -1]);
+ expect(B.primAt(walker, 2.2).position[2]).toBeCloseTo(-5.3, 5);
+ expect(B.primAt(walker, 99).position).toEqual([0, 0, -13.2]);
+ expect(B.primSpeed(walker, 2)).toBeCloseTo(8.6 / 4.4, 2);
+ expect(B.primSpeed(walker, 5)).toBeLessThan(0.2);
+ const box = B.newPrim("box");
+ expect(B.primAt(box, 3)).toEqual({ position: [0, 0, 0], rotation: 0 });
+ });
+
+ it("eases the camera between keys, zooms evenly in ratio and shakes the same way every render", () => {
+ const keys: import("@/lib/blockout").BlockoutCameraKey[] = [
+ { t: 0, position: [0, 1.6, 0], target: [0, 1.6, -5], lens: 24, shake: 0 },
+ { t: 4, position: [0, 1.6, -4], target: [0, 1.6, -9], lens: 96, shake: 0 },
+ ];
+ const mid = B.cameraAt(keys, 2);
+ expect(mid.position[2]).toBeCloseTo(-2, 6);
+ expect(mid.lens).toBeCloseTo(48, 6);
+ // Eased: a quarter of the time covers less than a quarter of the way.
+ expect(-B.cameraAt(keys, 1).position[2]).toBeLessThan(1);
+ const shaky = keys.map((k) => ({ ...k, shake: 1 }));
+ const a = B.cameraAt(shaky, 1.3);
+ expect(a).toEqual(B.cameraAt(shaky, 1.3));
+ expect(Math.hypot(a.position[0], a.position[1] - 1.6)).toBeGreaterThan(0.001);
+ expect(Math.abs(a.position[0])).toBeLessThan(0.05);
+ expect(B.shakeAt(2, 0)).toEqual({ offset: [0, 0, 0], aim: [0, 0, 0] });
+ });
+
+ it("frames the lens like a full-frame camera and renders in even multiples of 16", () => {
+ expect(B.lensVFov(24, 1.5)).toBeCloseTo(53.13, 1);
+ expect(B.lensVFov(24, 16 / 9)).toBeLessThan(B.lensVFov(24, 1.5));
+ expect(B.blockoutSize("16:9")).toEqual({ width: 1280, height: 720 });
+ expect(B.blockoutSize("9:16", 832)).toEqual({ width: 464, height: 832 });
+ expect(B.aspectOf("2.39:1")).toBeCloseTo(2.39);
+ expect(B.aspectOf("nonsense")).toBeCloseTo(16 / 9);
+ });
+
+ it("makes a caller's scene safe: numbers in range, lists capped, a camera always there", () => {
+ const s = B.normalizeScene({ duration: 999, prims: [{ kind: "box", position: [1e9, NaN, 2], size: [-2, 1, 1] }, { kind: "rocket" }], markers: [{ t: 80, label: "" }], camera: [] });
+ expect(s.duration).toBe(B.BLOCKOUT.maxSeconds);
+ expect(s.prims).toHaveLength(1);
+ expect(s.prims[0].position).toEqual([500, 0, 2]);
+ expect(s.prims[0].size).toEqual([2, 1, 1]);
+ expect(s.camera).toEqual([B.DEFAULT_CAMERA]);
+ expect(s.markers[0]).toMatchObject({ t: 60, label: "Beat 1" });
+ expect(B.normalizeScene(B.EXAMPLE_SCENE)).toEqual(B.EXAMPLE_SCENE);
+ });
+});
+
+describe("beats and the prompt", () => {
+ it("turns markers into beats that run to the next marker, with an opening when the first is late", () => {
+ expect(exampleBeats().map((b) => [b.label, b.start, b.end])).toEqual([
+ ["Arrival", 0, 4.5],
+ ["The door opens", 4.5, 6],
+ ["Into the dark", 6, 8],
+ ]);
+ const late = B.beatsFrom([{ id: "x", t: 3, label: "Lights out" }], 10);
+ expect(late.map((b) => [b.id, b.label, b.start, b.end])).toEqual([
+ ["start", "Opening", 0, 3],
+ ["x", "Lights out", 3, 10],
+ ]);
+ // A caller's beats: sorted, inside the blockout, each running to the next.
+ expect(B.normalizeBeats([{ start: 5, label: "B" }, { start: 0, label: "A", words: "Hi" }], 8).map((b) => [b.label, b.start, b.end, b.words])).toEqual([
+ ["A", 0, 5, "Hi"],
+ ["B", 5, 8, ""],
+ ]);
+ });
+
+ it("compiles Seedance's prompt in the workflow's structure, with @ tags matching the attached references", () => {
+ const p = B.compileBlockoutPrompt({ beats: exampleBeats(), refs: REFS, target: "seedance", style: "Low-key horror", sound: true, audio: ["Footsteps"], avoid: ["text on screen"] });
+ expect(p.split("\n\n").map((s) => s.split(":")[0])).toEqual(["Subject", "Action", "Camera", "Style", "Constraints", "Audio", "No"]);
+ expect(p).toContain("@Video1 is a grey-box 3D blockout");
+ expect(p).toContain("@Image1 is the interior");
+ expect(p).toContain("@Image2 is Mara, the main character");
+ expect(p).toContain("@Image3 is the exterior");
+ expect(p).not.toContain("@Image4");
+ expect(p).toContain("0.0–4.5s — Arrival: A woman walks slowly down the narrow corridor");
+ expect(p).toContain("4.5–6.0s — The door opens: She stops.");
+ expect(p).toContain("Follow @Video1 exactly");
+ expect(p).toContain("Events happen in this order: Arrival, then The door opens, then Into the dark.");
+ expect(p).toMatch(/Audio: Footsteps\./);
+ expect(p).toMatch(/No: text on screen\./);
+ // Sound off: no audio list.
+ expect(B.compileBlockoutPrompt({ beats: exampleBeats(), refs: REFS, target: "seedance", audio: ["Footsteps"] })).not.toContain("Audio:");
+ // A later shot names the hand-over frame.
+ expect(B.compileBlockoutPrompt({ beats: exampleBeats(), refs: REFS, target: "seedance", previousFrame: 4 })).toContain("@Image4 is the last frame of the shot before");
+ });
+
+ it("writes H3 Max's scene intent without tags inside its 2000 characters, and a short prompt for Wan", () => {
+ const long = Array.from({ length: 20 }, (_, i) => ({ id: `b${i}`, start: i, end: i + 1, label: `Beat ${i}`, words: "x".repeat(300) }));
+ const h3 = B.compileBlockoutPrompt({ beats: long, refs: REFS, target: "h3" });
+ expect(h3.length).toBeLessThanOrEqual(B.H3_INTENT_MAX);
+ expect(h3).not.toContain("@");
+ expect(h3).toContain("Reference 2 is Mara");
+ const open = B.compileBlockoutPrompt({ beats: exampleBeats(), refs: REFS, target: "open", style: "Low-key horror" });
+ expect(open.length).toBeLessThanOrEqual(B.OPEN_PROMPT_MAX);
+ expect(open).toMatch(/^Low-key horror\. Mara in the scene\. A woman walks/);
+ });
+
+ it("writes each reference's role for you, from where it came", () => {
+ expect(B.roleFor({ category: "character" })).toBe("character");
+ expect(B.roleFor({ category: "location" })).toBe("location");
+ expect(B.roleFor({ category: "prop" })).toBe("prop");
+ expect(B.roleFor(undefined)).toBe("location");
+ for (const r of B.REF_ROLES) expect(B.roleSentence({ role: r.id }, "@Image1")).toMatch(/^@Image1 is /);
+ expect(blockoutFramePrompt(REFS.slice(0, 2), "Cold light")).toContain("Picture 2 is the interior; picture 3 is the person the mannequin becomes (Mara). Cold light.");
+ });
+
+ it("clips beats to a shot and times them from its start", () => {
+ expect(B.beatsIn(exampleBeats(), 4, 8).map((b) => [b.label, b.start, b.end])).toEqual([
+ ["Arrival", 0, 0.5],
+ ["The door opens", 0.5, 2],
+ ["Into the dark", 2, 4],
+ ]);
+ });
+});
+
+describe("shots and windows", () => {
+ it("cuts a long blockout at its markers, each shot within the model's limit", () => {
+ expect(B.splitShots(28, [0, 7.8, 15, 22], 30)).toEqual([{ index: 0, start: 0, end: 28 }]);
+ expect(B.splitShots(42, [0, 10, 24, 33], 30, 4)).toEqual([
+ { index: 0, start: 0, end: 24 },
+ { index: 1, start: 24, end: 42 },
+ ]);
+ // No marker in reach: cut at the limit, never leaving a sliver behind.
+ expect(B.splitShots(31, [], 15, 4)).toEqual([
+ { index: 0, start: 0, end: 15 },
+ { index: 1, start: 15, end: 27 },
+ { index: 2, start: 27, end: 31 },
+ ]);
+ expect(B.splitShots(16, [], 15, 4).map((s) => [s.start, s.end])).toEqual([
+ [0, 12],
+ [12, 16],
+ ]);
+ });
+
+ it("lays 81-frame windows at 16 fps that hand over on a shared frame, each 4n+1 frames", () => {
+ const w = B.depthWindows(8);
+ expect(w.map((x) => [x.startFrame, x.frames])).toEqual([
+ [0, 81],
+ [80, 45],
+ ]);
+ expect(w[1].start).toBe(5);
+ for (const x of B.depthWindows(37)) expect((x.frames - 1) % 4).toBe(0);
+ expect(B.depthWindows(5).map((x) => x.frames)).toEqual([77]);
+ expect(B.depthWindows(5.1).map((x) => x.frames)).toEqual([81]);
+ expect(B.depthWindows(999)).toHaveLength(B.OPEN_MAX_WINDOWS);
+ expect(B.windowsSeconds(B.depthWindows(8))).toBeCloseTo(125 / 16, 2);
+ });
+});
+
+describe("planning a blockout", () => {
+ it("cloud, Seedance 2.5: one reference-to-video call with the blockout as @Video1, the stills, sound on and the length", () => {
+ const plan = planCinema(film("cloud"), ctx);
+ expect(plan.blocker).toBeUndefined();
+ expect(plan.model.id).toBe("seedance-2-5");
+ expect(plan.steps).toHaveLength(1);
+ const r = plan.steps[0].request;
+ expect(r).toMatchObject({ feature: "cinema-blockout", modelId: "seedance-2-5", op: "ref2v", inputs: { videos: [VIDEO], images: REFS.map((x) => x.url) } });
+ expect(r.params).toMatchObject({ duration: 8, resolution: "720p", aspectRatio: "auto", generateAudio: true });
+ expect(r.prompt).toContain("@Image2 is Mara");
+ expect(r.prompt).toMatch(/Audio: Footsteps on concrete; A long door creak\./);
+ // Seedance 2.5 at 720p: 8 s × $0.473.
+ expect(plan.costUsd).toBeCloseTo(8 * 0.473, 3);
+ expect(plan.notes.join(" ")).toMatch(/reference video \(@Video1\).*sound on/);
+ });
+
+ it("cloud: an edited prompt is sent as written, and the prompt the composer shows is the one it would send", () => {
+ expect(planCinema(film("cloud", {}, { prompt: "My own words" }), ctx).steps[0].request.prompt).toBe("My own words");
+ expect(blockoutPrompt(film("cloud"))).toBe(planCinema(film("cloud"), ctx).steps[0].request.prompt);
+ expect(blockoutPrompt(film("cloud", {}, { modelId: "minimax-h3-max-3d" }))).toBe(planCinema(film("cloud", {}, { modelId: "minimax-h3-max-3d" }), ctx).steps[0].request.prompt);
+ });
+
+ it("cloud: longer than 30 s it is cut at the markers into shots that hand over a frame, then joined", () => {
+ const beats = [
+ { start: 0, label: "Arrival", words: "She arrives." },
+ { start: 14, label: "Lights out", words: "The lights die." },
+ { start: 26, label: "Door kicked", words: "The door bursts open." },
+ ];
+ const plan = planCinema(film("cloud", { seconds: 40, beats }, { prompt: "edited" }), ctx);
+ expect(plan.blocker).toBeUndefined();
+ expect(plan.steps.map((s) => s.key)).toEqual(["cut0", "shot0", "last0", "cut1", "shot1", "join"]);
+ const [cut0, shot0, , cut1, shot1, join] = plan.steps;
+ expect(cut0.request).toMatchObject({ modelId: "trim-video", op: "trim", inputs: { video: VIDEO }, params: { startTime: 0, endTime: 26 } });
+ expect(cut1.request.params).toMatchObject({ startTime: 26, endTime: 40 });
+ expect(shot0.after).toEqual(["cut0"]);
+ expect(shot0.request.chain).toEqual([{ slot: "videos", position: "first" }]);
+ expect(shot0.request.params?.duration).toBe(26);
+ expect(shot1.after).toEqual(["cut1", "last0"]);
+ expect(shot1.request.chain).toEqual([
+ { slot: "videos", position: "first" },
+ { slot: "images", position: "last" },
+ ]);
+ // Three stills plus the hand-over frame: Seedance takes four.
+ expect(shot1.request.inputs?.images).toEqual(REFS.map((x) => x.url));
+ expect(shot1.request.prompt).toContain("@Image4 is the last frame of the shot before");
+ expect(shot1.request.prompt).toContain("0.0–14.0s — Door kicked: The door bursts open.");
+ expect(shot0.request.prompt).not.toBe("edited");
+ expect(join.request).toMatchObject({ modelId: "join-clips", op: "concat" });
+ expect(join.after).toEqual(["shot0", "shot1"]);
+ expect(plan.notes.join(" ")).toMatch(/filmed as 2 shots cut at your markers \(0–26 s, 26–40 s\)/);
+ expect(plan.costUsd).toBeGreaterThan(40 * 0.473 - 0.01);
+ });
+
+ it("cloud, H3 Max 3D to video: its own model, 15 s shots, up to 8 stills, no sound, and its processing fee in the price", () => {
+ const plan = planCinema(film("cloud", { seconds: 12 }, { modelId: "minimax-h3-max-3d" }), ctx);
+ expect(plan.model.id).toBe("minimax-h3-max-3d");
+ const r = plan.steps[0].request;
+ expect(r).toMatchObject({ op: "v2v", inputs: { video: VIDEO, images: REFS.map((x) => x.url) }, params: { resolution: "768P", duration: 12 } });
+ expect(r.params?.generateAudio).toBeUndefined();
+ expect(r.prompt).not.toContain("@");
+ expect(plan.costUsd).toBeCloseTo(12 * 0.08 + 0.5, 3);
+ expect(plan.notes.join(" ")).toMatch(/makes no sound/);
+ // A 3 s shot bills 5 s.
+ expect(planCinema(film("cloud", { seconds: 3 }, { modelId: "minimax-h3-max-3d" }), ctx).costUsd).toBeCloseTo(5 * 0.08 + 0.5, 3);
+ const long = planCinema(film("cloud", { seconds: 20 }, { modelId: "minimax-h3-max-3d" }), ctx);
+ expect(long.steps.filter((s) => s.key.startsWith("shot")).map((s) => s.request.params?.duration)).toEqual([6, 14]);
+ expect(long.steps.find((s) => s.key === "shot1")!.request.chain).toEqual([
+ { slot: "video", position: "first" },
+ { slot: "images", position: "last" },
+ ]);
+ });
+
+ it("open: the first frame from the references, then depth windows chained by their last frame and joined, free", () => {
+ const plan = planCinema(film("open", { depth: DEPTH, firstFrame: FRAME }), ctx);
+ expect(plan.blocker).toBeUndefined();
+ expect(plan.model.id).toBe(BLOCKOUT_MODELS.open);
+ expect(plan.costUsd).toBe(0);
+ expect(plan.steps.map((s) => s.key)).toEqual(["look", "seg0", "win0", "last0", "seg1", "win1", "join"]);
+ const step = (k: string) => plan.steps.find((s) => s.key === k)!;
+ expect(step("look").request).toMatchObject({ modelId: "oss-qwen-edit", op: "edit", inputs: { images: [FRAME, REFS[0].url, REFS[1].url] } });
+ expect(step("seg1").request).toMatchObject({ modelId: "oss-segment", op: "trim", inputs: { video: DEPTH }, params: { startTime: 5, endTime: 7.8125, fps: 16, resolution: "480p", aspectRatio: "16:9" } });
+ expect(step("win0").after).toEqual(["seg0", "look"]);
+ expect(step("win1").after).toEqual(["seg1", "last0"]);
+ expect(step("win1").request).toMatchObject({ modelId: "oss-wan22-vace-blockout", op: "v2v", params: { duration: 45 / 16 }, chain: [{ slot: "video" }, { slot: "images", position: "first" }] });
+ expect(step("win1").request.prompt).toContain("She stops.");
+ expect(step("win1").request.prompt).not.toContain("walks slowly");
+ expect(step("last0").request).toMatchObject({ modelId: "oss-extract-frame", op: "frame", chain: [{ slot: "video" }] });
+ expect(step("join").request).toMatchObject({ modelId: "oss-join-encoded", op: "concat" });
+ expect(plan.notes.join(" ")).toMatch(/not the dialogue or sound: add sound afterwards with Sound for video/);
+ });
+
+ it("open: an upload without depth reads it with Depth Anything 3 and cuts its own first frame", () => {
+ const plan = planCinema(film("open", { seconds: 4 }), ctx);
+ expect(plan.model.id).toBe(BLOCKOUT_MODELS.openNoDepth);
+ expect(plan.steps.map((s) => s.key)).toEqual(["grab", "look", "seg0", "win0"]);
+ expect(plan.steps[0].request).toMatchObject({ modelId: "oss-extract-frame", inputs: { video: VIDEO }, params: { startTime: 0, endTime: 0.5, extra: { frameIndex: 0 } } });
+ expect(plan.steps[1]).toMatchObject({ after: ["grab"], request: { chain: [{ slot: "images", position: "first" }] } });
+ expect(plan.steps[2].request.inputs).toEqual({ video: VIDEO });
+ expect(plan.notes.join(" ")).toMatch(/Depth Anything 3/);
+ });
+
+ it("waits for a blockout, and prices the run before one is added", () => {
+ const none = planCinema({ ...film("cloud"), blockout: undefined }, ctx);
+ expect(none.blocker).toBe(BLOCKOUT_FIRST);
+ const blank = planCinema(film("cloud", { video: "" }), ctx);
+ expect(blank.blocker).toBe(BLOCKOUT_FIRST);
+ expect(blank.costUsd).toBeGreaterThan(0);
+ expect(planCinema(film("cloud", { seconds: 1 }), ctx).blocker).toMatch(/at least 2 s/);
+ });
+});
+
+describe("the hosted models and the graph", () => {
+ it("H3 Max 3D to video sends the blockout, the stills, the words and the quality, and nothing it doesn't take", () => {
+ const m = getModel("minimax-h3-max-3d")!;
+ expect(m.hidden).toBe(true);
+ const route = m.routes[0];
+ expect(route).toMatchObject({ op: "v2v", provider: "fal", endpoint: "minimax/h3-max/3d-to-video" });
+ const body = buildPayload(route.map!, { prompt: "Scene", video: "https://fal.test/b.webm", images: ["https://fal.test/a.png"], resolution: "1080P", duration: 12 });
+ expect(body).toEqual({ prompt: "Scene", video_url: "https://fal.test/b.webm", reference_image_urls: ["https://fal.test/a.png"], resolution: "1080P" });
+ expect(estimateCost(m, { resolution: "1080P", duration: 10 }, 1, "v2v")).toBeCloseTo(2.1, 3);
+ });
+
+ it("Seedance 2.5's reference route takes the blockout as video_urls and the stills as image_urls", () => {
+ const route = getModel("seedance-2-5")!.routes.find((r) => r.op === "ref2v")!;
+ const body = buildPayload(route.map!, { prompt: "p", videos: ["https://fal.test/b.webm"], images: ["https://fal.test/a.png"], duration: 8, generateAudio: true, resolution: "720p", aspectRatio: "auto" });
+ expect(body).toMatchObject({ video_urls: ["https://fal.test/b.webm"], image_urls: ["https://fal.test/a.png"], duration: "8", generate_audio: true });
+ });
+
+ it("the open graph is validated and binds the depth, the first frame, the words, the window's size and length", async () => {
+ const manifest = JSON.parse(fs.readFileSync("workflows/comfyui/manifest.json", "utf8")) as { workflows: { id: string; validated?: boolean; customNodes: unknown[]; license: string }[] };
+ const w = manifest.workflows.find((x) => x.id === "video-blockout-wan22-fun-vace")!;
+ expect(w.validated).toBe(true);
+ expect(w.customNodes).toEqual([]);
+ expect(w.license).toMatch(/Apache-2.0/);
+ const { workflow } = await prepareWorkflow(
+ "video-blockout-wan22-fun-vace",
+ { prompt: "She walks", images: ["first.png"], video: "depth.webm", aspectRatio: "16:9", resolution: "480p", duration: 81 / 16, seed: 3 },
+ { generationId: "gen-b", op: "v2v", upload: async (_d, _t, name) => name },
+ );
+ expect(workflow["1"].inputs.file).toBe("depth.webm");
+ expect(workflow["4"].inputs.image).toBe("first.png");
+ expect(workflow["12"].inputs.text).toBe("She walks");
+ expect([workflow["15"].inputs.width, workflow["15"].inputs.height]).toEqual([848, 480]);
+ expect(workflow["30"].inputs.value).toBe(81);
+ expect(workflow["32"].inputs.image).toEqual(["3", 0]);
+ expect(workflow["26"].inputs.audio).toBeUndefined();
+ expect(Object.values(workflow).some((n) => /^DA3/.test(n.class_type))).toBe(false);
+ });
+});
+
+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 }) });
+const upload = (name: string, type = "image/png") => saveFile({ data: encodePng({ width: 32, height: 18, data: Buffer.alloc(32 * 18 * 4, 128) }), contentType: type, name, source: "upload" }).url;
+
+describe("Cinema API: a blockout in demo mode", () => {
+ it("files the film as a take that remembers the blockout's length, parts and beats", async () => {
+ const p = cinema.createProject({ name: "Blockouts" });
+ const video = upload("blockout.png");
+ const still = upload("interior.png");
+ const input = film("cloud", { video, refs: [{ url: still, role: "interior" }] });
+ const res = await generateRoute.POST(json({ input }), params(p.id));
+ expect(res.status).toBe(201);
+ const out = (await res.json()) as { items: { id: string; feature: string }[]; plan: { modelId: string } };
+ expect(out.plan.modelId).toBe("seedance-2-5");
+ expect(out.items).toHaveLength(1);
+ expect(out.items[0].feature).toBe("cinema-blockout");
+ const items = cinema.listItems(p.id);
+ expect(items[0].take).toMatchObject({ action: "blockout", blockout: { seconds: 8, parts: 1, beats: ["Arrival", "The door opens", "Into the dark"] } });
+ expect(gens.getGeneration(out.items[0].id)!.provider).toBe("mock");
+ });
+
+ it("refuses a blockout from outside Fuobe's files, and one past 60 s", async () => {
+ const p = cinema.createProject({ name: "Bad" });
+ for (const bad of [{ video: "https://evil.test/x.mp4" }, { seconds: 61 }, { refs: [{ url: "/api/files/x.png", role: "villain" }] }]) {
+ const res = await generateRoute.POST(json({ input: film("cloud", bad as never) }), params(p.id));
+ expect(res.status, JSON.stringify(bad)).toBe(400);
+ }
+ });
+});
diff --git a/workflows/comfyui/manifest.json b/workflows/comfyui/manifest.json
index 4424f844..c07fa23a 100644
--- a/workflows/comfyui/manifest.json
+++ b/workflows/comfyui/manifest.json
@@ -12917,6 +12917,213 @@
"validated": true,
"notes": "Fuobe's Evolution on the GPU: video-segment-resample (<=81 frames @16 fps + first frame) -> qwen-image-edit-2511 takes the first frame toward the creative direction (images 2-3 = references) -> this graph -> video-concat-N -> the clip's sound. Any clip loads: VHS_LoadVideo resamples it to fps (16), keeps at most `frames` frames and cuts them to 4n+1 (Wan format), and every length in the graph is the loaded count, so a short or 30 fps clip is neither a shape error nor slow motion (Edit video sends whole clips). Unlike video-restyle-wan22-fun-vace the sampler starts from the segment itself: reference latent + VAE-encoded frames (LatentConcat on t, the shape WanVaceToVideo makes), noised to denoise = the noise level it starts from (flow matching: (1 - denoise) x clip + denoise x noise; low 0.45, medium 0.65, high 0.85). The simple scheduler with shift s reaches sigma = denoise N - steps steps into a schedule of N = round(steps x (s - (s - 1) x denoise) / denoise) steps, and the last `steps` run (Lightx2v 4-step), so the run starts within a few hundredths of any denoise from 0.02 to 1 (KSampler's floor(steps / denoise) could only make 1, 0.8, 0.67, 0.57 or 0.5 with 4 steps). Wan 2.2's high-noise expert takes only the steps at or above its switch point (sigma 0.875; ComfySwitchNode gives the first sampler the low-noise expert when the run starts below it, as all three intensities do). Control: Depth Anything 3 depth on every frame (no kept frame, no masks); the direction frame is the VACE reference. Same weights as the restyle graph."
},
+ {
+ "id": "video-blockout-wan22-fun-vace",
+ "title": "Blockout to film: Wan 2.2 Fun VACE driven by the blockout's own depth + a first frame drawn from the references",
+ "capability": "v2v",
+ "file": "video-blockout-wan22-fun-vace.json",
+ "source": "hand-built (scripts/comfy/hand-built/video-blockout-wan22-fun-vace.json)",
+ "bindings": {
+ "video": [
+ {
+ "node": "1",
+ "input": "file"
+ }
+ ],
+ "image": [
+ {
+ "node": "4",
+ "input": "image"
+ }
+ ],
+ "prompt": [
+ {
+ "node": "12",
+ "input": "text"
+ }
+ ],
+ "negativePrompt": [
+ {
+ "node": "13",
+ "input": "text"
+ }
+ ],
+ "width": [
+ {
+ "node": "3",
+ "input": "width"
+ },
+ {
+ "node": "5",
+ "input": "width"
+ },
+ {
+ "node": "34",
+ "input": "width"
+ },
+ {
+ "node": "35",
+ "input": "width"
+ },
+ {
+ "node": "15",
+ "input": "width"
+ }
+ ],
+ "height": [
+ {
+ "node": "3",
+ "input": "height"
+ },
+ {
+ "node": "5",
+ "input": "height"
+ },
+ {
+ "node": "34",
+ "input": "height"
+ },
+ {
+ "node": "35",
+ "input": "height"
+ },
+ {
+ "node": "15",
+ "input": "height"
+ }
+ ],
+ "frames": [
+ {
+ "node": "30",
+ "input": "value"
+ }
+ ],
+ "fps": [
+ {
+ "node": "26",
+ "input": "fps"
+ }
+ ],
+ "seed": [
+ {
+ "node": "22",
+ "input": "noise_seed"
+ },
+ {
+ "node": "23",
+ "input": "noise_seed"
+ }
+ ],
+ "steps": [
+ {
+ "node": "22",
+ "input": "steps"
+ },
+ {
+ "node": "23",
+ "input": "steps"
+ }
+ ],
+ "cfg": [
+ {
+ "node": "22",
+ "input": "cfg"
+ },
+ {
+ "node": "23",
+ "input": "cfg"
+ }
+ ],
+ "shift": [
+ {
+ "node": "20",
+ "input": "shift"
+ },
+ {
+ "node": "21",
+ "input": "shift"
+ }
+ ],
+ "controlStrength": [
+ {
+ "node": "15",
+ "input": "strength"
+ }
+ ],
+ "filenamePrefix": [
+ {
+ "node": "27",
+ "input": "filename_prefix"
+ }
+ ]
+ },
+ "outputs": [
+ {
+ "node": "27",
+ "kind": "video"
+ }
+ ],
+ "defaults": {
+ "width": 832,
+ "height": 480,
+ "frames": 81,
+ "fps": 16,
+ "steps": 4,
+ "cfg": 1,
+ "shift": 5,
+ "controlStrength": 1,
+ "frameStep": 4
+ },
+ "limits": {
+ "maxWidth": 1280,
+ "maxHeight": 1280,
+ "dimensionMultiple": 16,
+ "maxFrames": 81
+ },
+ "models": [
+ {
+ "file": "umt5_xxl_fp8_e4m3fn_scaled.safetensors",
+ "folder": "text_encoders",
+ "url": "https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/split_files/text_encoders/umt5_xxl_fp8_e4m3fn_scaled.safetensors",
+ "sizeGb": 6.74
+ },
+ {
+ "file": "wan_2.1_vae.safetensors",
+ "folder": "vae",
+ "url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/vae/wan_2.1_vae.safetensors",
+ "sizeGb": 0.25
+ },
+ {
+ "file": "wan2.2_fun_vace_high_noise_14B_fp8_scaled.safetensors",
+ "folder": "diffusion_models",
+ "url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_fun_vace_high_noise_14B_fp8_scaled.safetensors",
+ "sizeGb": 17.35
+ },
+ {
+ "file": "wan2.2_fun_vace_low_noise_14B_fp8_scaled.safetensors",
+ "folder": "diffusion_models",
+ "url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_fun_vace_low_noise_14B_fp8_scaled.safetensors",
+ "sizeGb": 17.35
+ },
+ {
+ "file": "wan2.2_t2v_lightx2v_4steps_lora_v1.1_high_noise.safetensors",
+ "folder": "loras",
+ "url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/loras/wan2.2_t2v_lightx2v_4steps_lora_v1.1_high_noise.safetensors",
+ "sizeGb": 1.23
+ },
+ {
+ "file": "wan2.2_t2v_lightx2v_4steps_lora_v1.1_low_noise.safetensors",
+ "folder": "loras",
+ "url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/loras/wan2.2_t2v_lightx2v_4steps_lora_v1.1_low_noise.safetensors",
+ "sizeGb": 1.23
+ }
+ ],
+ "customNodes": [],
+ "vramGb": 24,
+ "license": "Apache-2.0 (Wan 2.2 Fun VACE, lightx2v)",
+ "validated": true,
+ "notes": "Cinema's Blockout on your GPU: the browser renders the grey box and its depth (near = bright, as Depth Anything draws it) at 16 fps; video-segment-resample cuts the depth into 81-frame windows that overlap by one frame; qwen-image-edit-2511 draws the first frame from the grey box's first frame and up to two references; each window runs this graph with the first frame (window 1) or the last frame of the window before (frame-extract), then video-concat-encoded joins them. The same graph as video-restyle-wan22-fun-vace without Depth Anything 3: control frame 0 = the first frame (kept), frames 1..N-1 = the depth video as it is; the first frame is also the VACE reference. Lightx2v 4 steps. Silent (no audio input): sound comes afterwards (Sound for video). A blockout uploaded without a depth pass runs video-restyle-wan22-fun-vace instead (Depth Anything 3 on the grey box)."
+ },
{
"id": "mixed-media-zimage-frames",
"title": "Mixed Media: per-frame stylisation at 4-24 fps (Z-Image Turbo img2img + Fun Union ControlNet canny)",
diff --git a/workflows/comfyui/requirements.json b/workflows/comfyui/requirements.json
index b686f29f..db7f6db7 100644
--- a/workflows/comfyui/requirements.json
+++ b/workflows/comfyui/requirements.json
@@ -1,6 +1,6 @@
{
"v": 1,
- "hash": "aa51bd32f535494cf798ef492bef8b900fa620a543a32ab548880376cee412f1",
+ "hash": "90fb86ee3f4dd6d5434f06cbc6c0147b9072de8e1c01e7a5f0e1493d03011e78",
"comfyui": {"min":"0.42.0","testedCommit":"5841c187"},
"folders": ["audio_encoders","background_removal","checkpoints","clip_vision","dbs","diffusion_models","facerestore_models","foley","frame_interpolation","geometry_estimation","insightface","latent_upscale_models","loras","mmaudio","model_patches","optical_flow","text_encoders","thinksound","upscale_models","vae"],
"sentinels": ["AILab_Qwen3ASRSubtitle","AUSBOSS_NODES_CropForInpaint","AUSBOSS_NODES_ImageCropRotatePad","AUSBOSS_NODES_StitchInpaint","Add Subtitles To Frames","Apply Whisper","CFGOverride","ClothesSegment","ComfyMathExpression","DBSLoader","DBSSeparate","DownloadAndLoadWav2VecModel","DualModelGuider","FL_ChatterboxDialogTTS","FL_ChatterboxMultilingualTTS","FL_ChatterboxVC","GetImageRangeFromBatch","GetImageSizeAndCount","GrowMaskWithBlur","H3AdaLNLoRAFix","H3CharacterSwapAssemble","H3CharacterSwapController","H3CharacterSwapExpandMask","H3CharacterSwapModels","H3CharacterSwapPrepareVideo","H3CharacterSwapRecoverMasks","H3CharacterSwapSelectSubject","H3CharacterSwapSettings","H3CharacterSwapShot","H3CharacterSwapWindowPlan","H3RelayAppendWindow","H3RelayApplyEditMask","H3RelayApplyHistory","H3RelayExpandMask","H3RelayFinishWindows","H3RelayPrepareSource","H3RelayRecoverMasks","H3RelayReviewWindows","H3RelaySamplingMemory","H3RelaySelectMask","H3RelayTextMemory","H3RelayWindowInputs","H3RelayWindowPlan","H3SLAAttention","HunyuanDependenciesLoader","HunyuanFoleySampler","HunyuanModelLoader","INTConstant","Ideogram4Scheduler","ImageBatchExtendWithOverlap","ImageGridtoBatch","ImageResizeKJv2","IndexTTS2Simple","Krea2EditGroundedEncode","Krea2EditModelPatch","Krea2OstrisEditModelPatch","LTXAVTextEncoderLoader","LTXAddVideoICLoRAGuide","LTXICLoRALoaderModelOnly","LTXVAddGuide","LTXVAudioVAEDecode","LTXVAudioVAELoader","LTXVConcatAVLatent","LTXVConditioning","LTXVCropGuides","LTXVDualCFGGuider","LTXVEmptyLatentAudio","LTXVImgToVideoInplace","LTXVLatentUpsampler","LTXVPreprocess","LTXVScheduler","LTXVSeparateAVLatent","LTXVTiledFusionSampler","LatentSyncNode","LoadBackgroundRemovalModel","LoadVideoDepthAnythingModel","MMAudioFeatureUtilsLoader","MMAudioModelLoader","MMAudioSampler","MelBandRoFormerModelLoader","MelBandRoFormerSampler","MiniMaxH3TurboLoRA","MiniMaxH3TurboSampler","MultiTalkModelLoader","MultiTalkWav2VecEmbeds","QwenImage21Cache","RIFE VFI","RMBG","ReActorFaceSwap","RemoveBackground","SAM3_Detect","SAM3_TrackToMask","SAM3_VideoTrack","SeedVR2Conditioning","SeedVR2PostProcessing","SeedVR2Preprocess","TS_ImageToSVGStringColor_Vtracer","TS_SVGStringToSVGBytesIO","TextEncodeFibo2","TextEncodeKrea2OstrisEdit","TextEncodeQwenImage21","ThinkSoundFeatureUtilsLoader","ThinkSoundModelLoader","ThinkSoundSampler","Trellis2Conditioning","Trellis2ShapeStage","Trellis2TextureStage","Trellis2UpsampleStage","VHS_BatchManager","VHS_LoadAudioUpload","VHS_LoadVideo","VHS_SelectEveryNthImage","VHS_VideoCombine","VHS_VideoInfo","VHS_VideoInfoLoaded","VideoDepthAnythingOutput","VideoDepthAnythingProcess","VideoLengthAdjuster","WanVideoBlockSwap","WanVideoClipVisionEncode","WanVideoDecode","WanVideoEncode","WanVideoImageToVideoMultiTalk","WanVideoLoraSelect","WanVideoModelLoader","WanVideoPassImagesFromSamples","WanVideoSampler","WanVideoTextEncodeCached","WanVideoVAELoader"],
@@ -345,6 +345,7 @@
"video-append-endcard": {"core":["AudioConcat","ComfyMathExpression","ConcatenateVideo","CreateVideo","EmptyAudio","ImageScale","LoadAudio","LoadImage","LoadVideo","PrimitiveFloat","PrimitiveInt","RepeatImageBatch","SaveVideo"],"packs":{},"files":[],"optional":[],"vramGb":0,"isolated":false,"firstRun":[],"validated":true},
"video-bg-remove-birefnet": {"core":["CreateVideo","GetVideoComponents","InvertMask","JoinImageWithAlpha","LoadBackgroundRemovalModel","LoadVideo","MaskToImage","RemoveBackground","SaveVideo","SaveWEBM"],"packs":{},"files":["background_removal/birefnet.safetensors"],"optional":[],"vramGb":4,"isolated":false,"firstRun":[],"validated":true},
"video-bg-remove-sam3": {"core":["CLIPTextEncode","CheckpointLoaderSimple","CreateVideo","GetVideoComponents","InvertMask","JoinImageWithAlpha","LoadVideo","MaskToImage","SAM3_TrackToMask","SAM3_VideoTrack","SaveVideo","SaveWEBM"],"packs":{},"files":["checkpoints/sam3.1_multiplex_fp16.safetensors"],"optional":[],"vramGb":6,"isolated":false,"firstRun":[],"validated":true},
+ "video-blockout-wan22-fun-vace": {"core":["BatchImagesNode","CLIPLoader","CLIPTextEncode","ComfyMathExpression","CreateVideo","GetVideoComponents","ImageFromBatch","ImageScale","ImageToMask","KSamplerAdvanced","LoadImage","LoadVideo","LoraLoaderModelOnly","MaskToImage","ModelSamplingSD3","PrimitiveInt","RepeatImageBatch","SaveVideo","SolidMask","TrimVideoLatent","UNETLoader","VAEDecode","VAELoader","WanVaceToVideo"],"packs":{},"files":["diffusion_models/wan2.2_fun_vace_high_noise_14B_fp8_scaled.safetensors","diffusion_models/wan2.2_fun_vace_low_noise_14B_fp8_scaled.safetensors","loras/wan2.2_t2v_lightx2v_4steps_lora_v1.1_high_noise.safetensors","loras/wan2.2_t2v_lightx2v_4steps_lora_v1.1_low_noise.safetensors","text_encoders/umt5_xxl_fp8_e4m3fn_scaled.safetensors","vae/wan_2.1_vae.safetensors"],"optional":[],"vramGb":24,"isolated":false,"firstRun":[],"validated":true},
"video-character-swap-h3": {"core":["CLIPLoader","CLIPTextEncode","CheckpointLoaderSimple","CreateVideo","ImageFromBatch","ImageScale","LoadImage","LoadVideo","LoraLoaderModelOnly","MiniMaxH3SigmaShift","ModelAttentionBackend","SAM3_Detect","SAM3_TrackToMask","SAM3_VideoTrack","SaveVideo","SelectCLIPDevice","UNETLoader","VAELoader","Video Slice"],"packs":{"h3_character_swap":["H3CharacterSwapAssemble","H3CharacterSwapController","H3CharacterSwapExpandMask","H3CharacterSwapModels","H3CharacterSwapPrepareVideo","H3CharacterSwapRecoverMasks","H3CharacterSwapSelectSubject","H3CharacterSwapSettings","H3CharacterSwapShot","H3CharacterSwapWindowPlan"]},"files":["checkpoints/sam3.1_multiplex_fp16.safetensors","diffusion_models/minimax_h3_ref2va_pruned_int8_convrot.safetensors","loras/h3_character_swap_v1.5.safetensors","loras/minimax_h3_fl2v_turbo_8step_v1.0_768p_comfyui_bf16.safetensors","text_encoders/qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors","vae/minimax_h3_audio_vae_fp32.safetensors","vae/minimax_h3_video_vae_fp16.safetensors"],"optional":["loras/h3_character_swap_pro4500_1000.safetensors"],"vramGb":24,"isolated":false,"firstRun":[]},
"video-character-swap-h3-relay": {"core":["BasicScheduler","CFGGuider","CLIPLoader","CLIPTextEncode","CheckpointLoaderSimple","CreateVideo","EndLoop","GetImageSize","ImageFromBatch","KSamplerSelect","LTXVSeparateAVLatent","LoadImage","LoadVideo","LoraLoaderModelOnly","MiniMaxH3AddGuide","MiniMaxH3ReferenceToVideo","MiniMaxH3SigmaShift","ModelAttentionBackend","RandomNoise","SAM3_Detect","SAM3_TrackToMask","SAM3_VideoTrack","SamplerCustomAdvanced","SaveVideo","SelectCLIPDevice","StartLoop","UNETLoader","VAEDecode","VAEEncode","VAELoader","Video Slice"],"packs":{"h3-relay":["H3RelayAppendWindow","H3RelayApplyEditMask","H3RelayApplyHistory","H3RelayExpandMask","H3RelayFinishWindows","H3RelayPrepareSource","H3RelayRecoverMasks","H3RelaySamplingMemory","H3RelaySelectMask","H3RelayTextMemory","H3RelayWindowInputs","H3RelayWindowPlan"]},"files":["checkpoints/sam3.1_multiplex_fp16.safetensors","diffusion_models/minimax_h3_ref2va_pruned_int8_convrot.safetensors","loras/h3_character_swap_v1.5.safetensors","loras/minimax_h3_fl2v_turbo_8step_v1.0_768p_comfyui_bf16.safetensors","text_encoders/qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors","vae/minimax_h3_audio_vae_fp32.safetensors","vae/minimax_h3_video_vae_fp16.safetensors"],"optional":["loras/h3_character_swap_pro4500_1000.safetensors"],"vramGb":24,"isolated":false,"firstRun":[]},
"video-character-swap-h3-segment": {"core":["BasicScheduler","CFGGuider","CLIPLoader","CLIPTextEncode","CheckpointLoaderSimple","CreateVideo","EndLoop","GetImageSize","GetVideoComponents","ImageFromBatch","ImageScale","KSamplerSelect","LTXVSeparateAVLatent","LoadImage","LoadVideo","LoraLoaderModelOnly","MiniMaxH3AddGuide","MiniMaxH3ReferenceToVideo","MiniMaxH3SigmaShift","ModelAttentionBackend","RandomNoise","SAM3_Detect","SAM3_TrackToMask","SAM3_VideoTrack","SamplerCustomAdvanced","SaveVideo","SelectCLIPDevice","StartLoop","UNETLoader","VAEDecode","VAEEncode","VAELoader","Video Slice"],"packs":{"ComfyUI-VideoHelperSuite":["VHS_VideoCombine"],"h3-relay":["H3RelayAppendWindow","H3RelayApplyEditMask","H3RelayApplyHistory","H3RelayExpandMask","H3RelayFinishWindows","H3RelayPrepareSource","H3RelayRecoverMasks","H3RelaySamplingMemory","H3RelaySelectMask","H3RelayTextMemory","H3RelayWindowInputs","H3RelayWindowPlan"]},"files":["checkpoints/sam3.1_multiplex_fp16.safetensors","diffusion_models/minimax_h3_ref2va_pruned_int8_convrot.safetensors","loras/h3_character_swap_v1.5.safetensors","loras/minimax_h3_fl2v_turbo_8step_v1.0_768p_comfyui_bf16.safetensors","text_encoders/qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors","vae/minimax_h3_audio_vae_fp32.safetensors","vae/minimax_h3_video_vae_fp16.safetensors"],"optional":["loras/h3_character_swap_pro4500_1000.safetensors"],"vramGb":24,"isolated":false,"firstRun":[]},
diff --git a/workflows/comfyui/video-blockout-wan22-fun-vace.json b/workflows/comfyui/video-blockout-wan22-fun-vace.json
new file mode 100644
index 00000000..c57e1f3c
--- /dev/null
+++ b/workflows/comfyui/video-blockout-wan22-fun-vace.json
@@ -0,0 +1,500 @@
+{
+ "1": {
+ "class_type": "LoadVideo",
+ "inputs": {
+ "file": "segment.mp4"
+ },
+ "_meta": {
+ "title": "blockout depth segment (<=81 frames @16 fps, near = bright)"
+ }
+ },
+ "2": {
+ "class_type": "GetVideoComponents",
+ "inputs": {
+ "video": [
+ "1",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "GetVideoComponents"
+ }
+ },
+ "3": {
+ "class_type": "ImageScale",
+ "inputs": {
+ "image": [
+ "2",
+ 0
+ ],
+ "upscale_method": "lanczos",
+ "width": 832,
+ "height": 480,
+ "crop": "center"
+ },
+ "_meta": {
+ "title": "depth frames at the work size"
+ }
+ },
+ "4": {
+ "class_type": "LoadImage",
+ "inputs": {
+ "image": "first_frame.png"
+ },
+ "_meta": {
+ "title": "first frame drawn from the references (Qwen-Image-Edit 2511), or the last frame of the window before"
+ }
+ },
+ "5": {
+ "class_type": "ImageScale",
+ "inputs": {
+ "image": [
+ "4",
+ 0
+ ],
+ "upscale_method": "lanczos",
+ "width": 832,
+ "height": 480,
+ "crop": "center"
+ },
+ "_meta": {
+ "title": "ImageScale"
+ }
+ },
+ "11": {
+ "class_type": "CLIPLoader",
+ "inputs": {
+ "clip_name": "umt5_xxl_fp8_e4m3fn_scaled.safetensors",
+ "type": "wan",
+ "device": "default"
+ },
+ "_meta": {
+ "title": "CLIPLoader"
+ }
+ },
+ "12": {
+ "class_type": "CLIPTextEncode",
+ "inputs": {
+ "clip": [
+ "11",
+ 0
+ ],
+ "text": "A woman walks slowly down a narrow corridor holding a torch; the door at the end swings open. Cinematic, photographic, natural motion."
+ },
+ "_meta": {
+ "title": "CLIPTextEncode"
+ }
+ },
+ "13": {
+ "class_type": "CLIPTextEncode",
+ "inputs": {
+ "clip": [
+ "11",
+ 0
+ ],
+ "text": "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
+ },
+ "_meta": {
+ "title": "CLIPTextEncode"
+ }
+ },
+ "14": {
+ "class_type": "VAELoader",
+ "inputs": {
+ "vae_name": "wan_2.1_vae.safetensors"
+ },
+ "_meta": {
+ "title": "VAELoader"
+ }
+ },
+ "15": {
+ "class_type": "WanVaceToVideo",
+ "inputs": {
+ "positive": [
+ "12",
+ 0
+ ],
+ "negative": [
+ "13",
+ 0
+ ],
+ "vae": [
+ "14",
+ 0
+ ],
+ "width": 832,
+ "height": 480,
+ "length": [
+ "30",
+ 0
+ ],
+ "batch_size": 1,
+ "strength": 1,
+ "control_video": [
+ "33",
+ 0
+ ],
+ "control_masks": [
+ "40",
+ 0
+ ],
+ "reference_image": [
+ "5",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "WanVaceToVideo"
+ }
+ },
+ "16": {
+ "class_type": "UNETLoader",
+ "inputs": {
+ "unet_name": "wan2.2_fun_vace_high_noise_14B_fp8_scaled.safetensors",
+ "weight_dtype": "default"
+ },
+ "_meta": {
+ "title": "UNETLoader"
+ }
+ },
+ "17": {
+ "class_type": "UNETLoader",
+ "inputs": {
+ "unet_name": "wan2.2_fun_vace_low_noise_14B_fp8_scaled.safetensors",
+ "weight_dtype": "default"
+ },
+ "_meta": {
+ "title": "UNETLoader"
+ }
+ },
+ "18": {
+ "class_type": "LoraLoaderModelOnly",
+ "inputs": {
+ "model": [
+ "16",
+ 0
+ ],
+ "lora_name": "wan2.2_t2v_lightx2v_4steps_lora_v1.1_high_noise.safetensors",
+ "strength_model": 1
+ },
+ "_meta": {
+ "title": "LoraLoaderModelOnly"
+ }
+ },
+ "19": {
+ "class_type": "LoraLoaderModelOnly",
+ "inputs": {
+ "model": [
+ "17",
+ 0
+ ],
+ "lora_name": "wan2.2_t2v_lightx2v_4steps_lora_v1.1_low_noise.safetensors",
+ "strength_model": 1
+ },
+ "_meta": {
+ "title": "LoraLoaderModelOnly"
+ }
+ },
+ "20": {
+ "class_type": "ModelSamplingSD3",
+ "inputs": {
+ "model": [
+ "18",
+ 0
+ ],
+ "shift": 5
+ },
+ "_meta": {
+ "title": "ModelSamplingSD3"
+ }
+ },
+ "21": {
+ "class_type": "ModelSamplingSD3",
+ "inputs": {
+ "model": [
+ "19",
+ 0
+ ],
+ "shift": 5
+ },
+ "_meta": {
+ "title": "ModelSamplingSD3"
+ }
+ },
+ "22": {
+ "class_type": "KSamplerAdvanced",
+ "inputs": {
+ "model": [
+ "20",
+ 0
+ ],
+ "add_noise": "enable",
+ "noise_seed": 0,
+ "steps": 4,
+ "cfg": 1,
+ "sampler_name": "euler",
+ "scheduler": "simple",
+ "positive": [
+ "15",
+ 0
+ ],
+ "negative": [
+ "15",
+ 1
+ ],
+ "latent_image": [
+ "15",
+ 2
+ ],
+ "start_at_step": 0,
+ "end_at_step": 2,
+ "return_with_leftover_noise": "enable"
+ },
+ "_meta": {
+ "title": "KSamplerAdvanced"
+ }
+ },
+ "23": {
+ "class_type": "KSamplerAdvanced",
+ "inputs": {
+ "model": [
+ "21",
+ 0
+ ],
+ "add_noise": "disable",
+ "noise_seed": 0,
+ "steps": 4,
+ "cfg": 1,
+ "sampler_name": "euler",
+ "scheduler": "simple",
+ "positive": [
+ "15",
+ 0
+ ],
+ "negative": [
+ "15",
+ 1
+ ],
+ "latent_image": [
+ "22",
+ 0
+ ],
+ "start_at_step": 2,
+ "end_at_step": 10000,
+ "return_with_leftover_noise": "disable"
+ },
+ "_meta": {
+ "title": "KSamplerAdvanced"
+ }
+ },
+ "24": {
+ "class_type": "TrimVideoLatent",
+ "inputs": {
+ "samples": [
+ "23",
+ 0
+ ],
+ "trim_amount": [
+ "15",
+ 3
+ ]
+ },
+ "_meta": {
+ "title": "TrimVideoLatent"
+ }
+ },
+ "25": {
+ "class_type": "VAEDecode",
+ "inputs": {
+ "samples": [
+ "24",
+ 0
+ ],
+ "vae": [
+ "14",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "VAEDecode"
+ }
+ },
+ "26": {
+ "class_type": "CreateVideo",
+ "inputs": {
+ "images": [
+ "25",
+ 0
+ ],
+ "fps": 16,
+ "bit_depth": "auto",
+ "color_space": "sRGB",
+ "codec": "none"
+ },
+ "_meta": {
+ "title": "CreateVideo (silent: sound comes afterwards)"
+ }
+ },
+ "27": {
+ "class_type": "SaveVideo",
+ "inputs": {
+ "video": [
+ "26",
+ 0
+ ],
+ "filename_prefix": "fuobe/video-blockout-wan22-fun-vace",
+ "format": "auto",
+ "format.codec": "auto",
+ "codec": "auto"
+ },
+ "_meta": {
+ "title": "SaveVideo"
+ }
+ },
+ "30": {
+ "class_type": "PrimitiveInt",
+ "inputs": {
+ "value": 81
+ },
+ "_meta": {
+ "title": "frames (4n+1, <= source frames)"
+ }
+ },
+ "31": {
+ "class_type": "ComfyMathExpression",
+ "inputs": {
+ "expression": "a - 1",
+ "values.a": [
+ "30",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "ComfyMathExpression"
+ }
+ },
+ "32": {
+ "class_type": "ImageFromBatch",
+ "inputs": {
+ "image": [
+ "3",
+ 0
+ ],
+ "batch_index": 1,
+ "length": [
+ "31",
+ 1
+ ]
+ },
+ "_meta": {
+ "title": "depth frames 1..N-1 (frame 0 is the first frame)"
+ }
+ },
+ "33": {
+ "class_type": "BatchImagesNode",
+ "inputs": {
+ "images.image0": [
+ "5",
+ 0
+ ],
+ "images.image1": [
+ "32",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "BatchImagesNode"
+ }
+ },
+ "34": {
+ "class_type": "SolidMask",
+ "inputs": {
+ "value": 0,
+ "width": 832,
+ "height": 480
+ },
+ "_meta": {
+ "title": "SolidMask"
+ }
+ },
+ "35": {
+ "class_type": "SolidMask",
+ "inputs": {
+ "value": 1,
+ "width": 832,
+ "height": 480
+ },
+ "_meta": {
+ "title": "SolidMask"
+ }
+ },
+ "36": {
+ "class_type": "RepeatImageBatch",
+ "inputs": {
+ "image": [
+ "37",
+ 0
+ ],
+ "amount": [
+ "31",
+ 1
+ ]
+ },
+ "_meta": {
+ "title": "RepeatImageBatch"
+ }
+ },
+ "37": {
+ "class_type": "MaskToImage",
+ "inputs": {
+ "mask": [
+ "35",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "MaskToImage"
+ }
+ },
+ "38": {
+ "class_type": "MaskToImage",
+ "inputs": {
+ "mask": [
+ "34",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "MaskToImage"
+ }
+ },
+ "39": {
+ "class_type": "BatchImagesNode",
+ "inputs": {
+ "images.image0": [
+ "38",
+ 0
+ ],
+ "images.image1": [
+ "36",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "BatchImagesNode"
+ }
+ },
+ "40": {
+ "class_type": "ImageToMask",
+ "inputs": {
+ "image": [
+ "39",
+ 0
+ ],
+ "channel": "red"
+ },
+ "_meta": {
+ "title": "ImageToMask"
+ }
+ }
+}