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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
N7-5 fixes: the open engine asks before it renders, a refused render leaves no upload, the mask only when asked
Claude58cce100d412
diff --git a/scripts/comfy/README.md b/scripts/comfy/README.mdindex daf29811..49903236 100644--- a/scripts/comfy/README.md+++ b/scripts/comfy/README.md@@ -351,6 +351,31 @@ COMFYUI_URL=http://127.0.0.1:<port> COMFYUI_MODELS_DIR=<that ComfyUI>/models nodscrambled stereo three times as long), so a file with more than 2 channels is split in `mono` and its background is themusic and effects stems added up (the provider rewires node 4 to `AudioMerge` add).+## Fly path (N7-5)++One hand-built graph films a still along a camera path keyframed in Cinema's 3D scene, on core nodes only+(docs/research/new-models-7.md §3.6):++```bash+npm run build -- wan21-i2v-uni3c-path+node validate-workflows.mjs wan21-i2v-uni3c-path --shared+```++| id | capability | what | validated here |+|---|---|---|---|+| `wan21-i2v-uni3c-path` | camera-path | `UNETLoader` (Wan 2.1 I2V 14B 720P fp8; `checkpoint` swaps in the 480P fp8 file) → `ModelSamplingSD3` (`shift`) → `ModelPatchLoader` (Uni3C) + `WanUni3CControlnetApply` (`strength`, 0–1) on the browser's render of the path (`video`: `LoadVideo` → `GetVideoComponents`; the node pads or cuts it to the latent's frames and centre-crops it to the size) → umt5 / CLIP vision H / Wan VAE → `WanImageToVideo` (the still as `image`, 81 frames) → `KSampler` (`steps` 30, `cfg` 5, uni_pc; a guess to tune on a GPU) → `VAEDecode` → `CreateVideo` (16 fps) → `SaveVideo` | `/prompt` only (no GPU here); a model-free `LoadVideo` run read the browser's render as 81 frames |++- **Weights**, pinned in `library.spec.mjs`: Kijai/WanVideo_comfy `Wan21_Uni3C_controlnet_fp16.safetensors` @ `8260d429`+ (1,997,314,376 B, in `models/model_patches`) and Comfy-Org/Wan-2.1 `wan2.1_i2v_720p_14B_fp8_scaled.safetensors` @+ `123acf1c` (16,401,356,938 B); optional: Kijai/WanVideo_comfy_fp8_scaled's 480P fp8 file @ `4d02bd37` (16,643,349,018 B).+ The 480P Q8 GGUF Fuobe pins for InfiniteTalk can't load here: core `UNETLoader` reads no GGUF (that needs city96's+ ComfyUI-GGUF pack). Loading Kijai's file through core `ModelPatchLoader` is inferred from its header keys, not run.+- **The render** comes from the browser (`src/components/cinema/scene-engine.ts` `recordPath`): 81 frames at 16 fps, black+ where nothing was seen, VP8 in WebM at exact frame times. Its hole mask is made only when asked for (core's Uni3C node+ has no mask input; WorldCast, N7-9, will ask).+- **Licences, as information**: Apache-2.0 (Wan 2.1; Uni3C, whose Kijai repack carries no licence field).+- **GPU**: Uni3C's own figures are 46–51 GB with offload; Fuobe's older 24 GB note is unverified.+## Adding a workflow1. Find the template name in `$COMFYUI_DIR/.venv/lib/python3.*/site-packages/comfyui_workflow_templates_json/templates/index.json`diff --git a/scripts/comfy/library.spec.mjs b/scripts/comfy/library.spec.mjsindex c158fb7f..da0e7a20 100644--- a/scripts/comfy/library.spec.mjs+++ b/scripts/comfy/library.spec.mjs@@ -278,10 +278,11 @@ export const KNOWN_MODELS = {'seedvr2_ema_vae_fp16.safetensors': { folder: 'vae', url: 'https://huggingface.co/Comfy-Org/SeedVR2/resolve/main/vae/seedvr2_ema_vae_fp16.safetensors' },// N7-5 (Fly path, docs/research/new-models-7.md §3.4 / §3.6): Uni3C's ControlNet for core ModelPatchLoader and the Wan 2.1 I2V// 720P it was trained on, at the revisions the research read (1,997,314,376 B and 16,401,356,938 B); the 480P fp8 file- // InfiniteTalk's native graph already uses is the drop-in to try on a smaller GPU (`checkpoint`).+ // InfiniteTalk's native graph already uses is the drop-in to try on a smaller GPU (`checkpoint`), pinned at the commit+ // that uploaded it (16,643,349,018 B, SHA-256 2ff92228…; InfiniteTalk's own entry keeps its template's URL).'Wan21_Uni3C_controlnet_fp16.safetensors': { folder: 'model_patches', url: 'https://huggingface.co/Kijai/WanVideo_comfy/resolve/8260d429d19fd7a72304cad059160b95d843913f/Wan21_Uni3C_controlnet_fp16.safetensors' },'wan2.1_i2v_720p_14B_fp8_scaled.safetensors': { folder: 'diffusion_models', url: 'https://huggingface.co/Comfy-Org/Wan-2.1/resolve/123acf1cc74bccbb9bfff8ac1ee72edc08c2341d/split_files/diffusion_models/wan2.1_i2v_720p_14B_fp8_scaled.safetensors' },- 'Wan2_1-I2V-14B-480p_fp8_e4m3fn_scaled_KJ.safetensors': { folder: 'diffusion_models', url: 'https://huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/resolve/main/I2V/Wan2_1-I2V-14B-480p_fp8_e4m3fn_scaled_KJ.safetensors' },+ 'Wan2_1-I2V-14B-480p_fp8_e4m3fn_scaled_KJ.safetensors': { folder: 'diffusion_models', url: 'https://huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/resolve/4d02bd37ce7d852ae45a4c2841956db727b480b4/I2V/Wan2_1-I2V-14B-480p_fp8_e4m3fn_scaled_KJ.safetensors' },// DBS (docs/research/dbs-separation-7.md §3.1): DBSLoader reads models/dbs/<model>/{config.json, model.safetensors}, so the// keys are paths under the folder (what GET /models/dbs lists). Pinned revisions; install-comfyui.sh checks the SHA-256.'DBS-BSRNN-DnR/model.safetensors': { folder: 'dbs', url: 'https://huggingface.co/JusperLee/DBS-BSRNN-DnR/resolve/5af343f57f106fbb95efe8a60f1a3999eeb0aef8/model.safetensors' },diff --git a/src/components/cinema/scene-engine.ts b/src/components/cinema/scene-engine.tsindex 798008f7..31b9bf06 100644--- a/src/components/cinema/scene-engine.ts+++ b/src/components/cinema/scene-engine.ts@@ -225,10 +225,10 @@ async function vp8Supported(width: number, height: number, fps: number): Promise* `count` frames of two streams (`draw(i)` gives frame i of each) encoded with WebCodecs and written as two WebM files:* every frame kept, frame i at i / fps, a keyframe each second.*/-async function encodeVp8(count: number, width: number, height: number, fps: number, draw: (i: number) => [ImageData, ImageData]): Promise<[Uint8Array, Uint8Array]> {- const chunks: EncodedFrame[][] = [[], []];+async function encodeVp8(count: number, width: number, height: number, fps: number, outputs: number, draw: (i: number) => ImageData[]): Promise<Uint8Array[]> {+ const chunks: EncodedFrame[][] = Array.from({ length: outputs }, () => []);let failure: unknown;- const encoders = [0, 1].map((k) => {+ const encoders = chunks.map((_, k) => {const e = new VideoEncoder({output: (chunk) => {const data = new Uint8Array(chunk.byteLength);@@ -261,17 +261,17 @@ async function encodeVp8(count: number, width: number, height: number, fps: numb}if (chunks.some((c) => c.length !== count)) throw new Error(`The path render lost frames (${chunks[0].length} of ${count})`);const track = { codec: "V_VP8" as const, width, height, fps };- return [muxWebM(track, chunks[0]), muxWebM(track, chunks[1])];+ return chunks.map((c) => muxWebM(track, c));}-/** The fallback: two canvases recorded with MediaRecorder, each frame handed over 1/fps apart. */-async function recordWithMediaRecorder(type: string, count: number, width: number, height: number, fps: number, draw: (i: number) => [ImageData, ImageData]): Promise<[Blob, Blob]> {- const canvases = [0, 1].map(() => Object.assign(document.createElement("canvas"), { width, height }));+/** The fallback: a canvas per stream recorded with MediaRecorder, each frame handed over 1/fps apart. */+async function recordWithMediaRecorder(type: string, count: number, width: number, height: number, fps: number, outputs: number, draw: (i: number) => ImageData[]): Promise<Blob[]> {+ const canvases = Array.from({ length: outputs }, () => Object.assign(document.createElement("canvas"), { width, height }));const ctxs = canvases.map((c) => c.getContext("2d")!);const streams = canvases.map((c) => c.captureStream(0));const tracks = streams.map((s) => s.getVideoTracks()[0] as MediaStreamTrack & { requestFrame?: () => void });const recorders = streams.map((s) => new MediaRecorder(s, { mimeType: type, videoBitsPerSecond: 8_000_000 }));- const chunks: Blob[][] = [[], []];+ const chunks: Blob[][] = recorders.map(() => []);const stopped = recorders.map((r, i) => {r.ondataavailable = (e) => e.data.size && chunks[i].push(e.data);return new Promise<void>((resolve) => (r.onstop = () => resolve()));@@ -294,7 +294,7 @@ async function recordWithMediaRecorder(type: string, count: number, width: numbestreams.forEach((s) => s.getTracks().forEach((t) => t.stop()));}const base = type.split(";")[0];- return [new Blob(chunks[0], { type: base }), new Blob(chunks[1], { type: base })];+ return chunks.map((c) => new Blob(c, { type: base }));}export class SceneEngine {@@ -658,11 +658,15 @@ export class SceneEngine {/*** Record the scene along a path (build plan N7-5): every frame of `path` (OpenCV camera-to-world poses and a pixel* intrinsic, src/lib/camera-path.ts framePoses) rendered at its size with nothing behind the scene, as two videos at- * `fps`: `render` (black where nothing was seen: Uni3C's render_video) and `mask` (white = a hole; core's Uni3C node has- * no mask input, so it is kept for WorldCast). With WebCodecs every frame is encoded (VP8) and written to WebM at its- * exact time; without it MediaRecorder records the frames handed over 1/fps apart, which may drop one.+ * `fps`: `render` (black where nothing was seen: Uni3C's render_video) and, when `mask` is asked for, the hole mask+ * (white = a hole; core's Uni3C node has no mask input, so only WorldCast will ask, and Film doesn't pay for a second+ * encode). With WebCodecs every frame is encoded (VP8) and written to WebM at its exact time; without it MediaRecorder+ * records the frames handed over 1/fps apart, which may drop one.*/- async recordPath(path: FramePoses, o: { fps: number; onProgress?: (p: number) => void; signal?: AbortSignal }): Promise<{ render: Blob; mask: Blob; type: string; frames: number }> {+ async recordPath(+ path: FramePoses,+ o: { fps: number; mask?: boolean; onProgress?: (p: number) => void; signal?: AbortSignal },+ ): Promise<{ render: Blob; mask?: Blob; type: string; frames: number }> {if (!this.view || !this.info) throw new Error("The scene isn't ready yet");const { width, height, poses, intrinsic } = path;const exact = await vp8Supported(width, height, o.fps);@@ -673,8 +677,9 @@ export class SceneEngine {const out = new THREE.WebGLRenderTarget(width, height);const buf = new Uint8Array(width * height * 4);const render = new ImageData(width, height);- const mask = new ImageData(width, height);- /** Frame i into `render` and `mask`: WebGL reads bottom-up, and a pixel nothing covered is transparent black. */+ const mask = o.mask ? new ImageData(width, height) : null;+ const images = mask ? [render, mask] : [render];+ /** Frame i into `render` (and `mask`): WebGL reads bottom-up, and a pixel nothing covered is transparent black. */const frame = (i: number) => {this.draw(out, width, height, width, height, color, { pose: flyPoseOf(poses[i]), vFov });this.renderer.readRenderTargetPixels(out, 0, 0, width, height, buf);@@ -687,6 +692,7 @@ export class SceneEngine {render.data[dst + x + 1] = hole ? 0 : buf[src + x + 1];render.data[dst + x + 2] = hole ? 0 : buf[src + x + 2];render.data[dst + x + 3] = 255;+ if (!mask) continue;const m = hole ? 255 : 0;mask.data[dst + x] = m;mask.data[dst + x + 1] = m;@@ -701,21 +707,21 @@ export class SceneEngine {this.playing = true;try {if (exact) {- const [a, b] = await encodeVp8(poses.length, width, height, o.fps, (i) => {+ const [a, b] = await encodeVp8(poses.length, width, height, o.fps, images.length, (i) => {stop();frame(i);o.onProgress?.((i + 1) / poses.length);- return [render, mask];+ return images;});- return { render: new Blob([a as BlobPart], { type }), mask: new Blob([b as BlobPart], { type }), type, frames: poses.length };+ return { render: new Blob([a as BlobPart], { type }), ...(b ? { mask: new Blob([b as BlobPart], { type }) } : {}), type, frames: poses.length };}- const [r, m] = await recordWithMediaRecorder(type, poses.length, width, height, o.fps, (i) => {+ const [r, m] = await recordWithMediaRecorder(type, poses.length, width, height, o.fps, images.length, (i) => {stop();frame(i);o.onProgress?.((i + 1) / poses.length);- return [render, mask];+ return images;});- return { render: r, mask: m, type: type.split(";")[0], frames: poses.length };+ return { render: r, ...(m ? { mask: m } : {}), type: type.split(";")[0], frames: poses.length };} finally {color.depthTexture?.dispose();color.dispose();diff --git a/src/components/cinema/scene-viewer.tsx b/src/components/cinema/scene-viewer.tsxindex ad437702..660e004c 100644--- a/src/components/cinema/scene-viewer.tsx+++ b/src/components/cinema/scene-viewer.tsx@@ -12,11 +12,12 @@ import { Slider } from "@/components/ui/slider";import { Switch } from "@/components/ui/switch";import { Textarea } from "@/components/ui/textarea";import { EngineSwitch } from "@/components/studio/engine-switch";-import { uploadFile } from "@/lib/api";+import { uploadFile, useDeleteUpload, useModelAccess, useStatus } from "@/lib/api";import { getModel } from "@/lib/catalog";import { IMAGE_ASPECTS, PATH_MODELS, PATH_RENDER_FIRST, RECOMPOSE_MODELS, planCinema, type CinemaGenerateInput, type DirectorSettings } from "@/lib/catalog/cinema";import { PATH_FPS, PATH_FRAMES, PHOTO_KEY, addKey, flyPoseOf, framePoses, fromScenePose, keyAt, keyPose, presetKeys, removeKey, renderSize, type CameraKey } from "@/lib/camera-path";import type { Engine } from "@/lib/catalog/types";+import { ACCESS_PLACE, offered } from "@/lib/model-access";import { APERTURE, FLY_KEYS, F_STOPS, LENS, LENS_STOPS, captureSize, formatStop, frameRect, ratioOf, scenePose, twoFinger, type Rect } from "@/lib/scene3d";import { cn } from "@/lib/utils";import { useCinemaGenerate } from "./hooks";@@ -160,6 +161,20 @@ export default function SceneViewer({ take, projectId, engine, onEngine, setting);const pathPrice = usePlanPrice(pathPlan);const pathBusy = previewing || !!filming;+ const appStatus = useStatus().data;+ const access = useModelAccess();+ const deleteUpload = useDeleteUpload();++ /**+ * What would refuse an open run anyway, asked before the browser renders every frame and uploads them: the model+ * switched off, or (demo mode off) no ComfyUI to run it on. The server checks again when the run is sent.+ */+ const openRefusal = (): string | undefined => {+ const m = pathPlan.model;+ if (!offered(access, m.id, "open")) return `${m.name} is turned off in ${ACCESS_PLACE}. Turn it back on there, or film on the cloud engine`;+ if (appStatus && !pathPrice.demo && !m.routes.some((r) => appStatus.providers[r.provider]?.configured)) return "Connect ComfyUI in Settings to film a path on your GPU";+ return undefined;+ };// The frame: the ratio's largest rectangle, centred, leaving room for the bars over the view.const frame: Rect | null = useMemo(() => {@@ -313,12 +328,13 @@ export default function SceneViewer({ take, projectId, engine, onEngine, settingconst filmPath = async () => {const eng = engineRef.current;if (!eng || !info || filming || previewing) return;- const blocker = pathPlan.blocker && pathPlan.blocker !== PATH_RENDER_FIRST ? pathPlan.blocker : undefined;+ const blocker = (pathPlan.blocker && pathPlan.blocker !== PATH_RENDER_FIRST ? pathPlan.blocker : undefined) ?? (engine === "open" ? openRefusal() : undefined);if (blocker) {toast.error(blocker);return;}setPathOpen(false);+ let uploaded: string | undefined;try {let render: string | undefined;if (engine === "open") {@@ -329,12 +345,16 @@ export default function SceneViewer({ take, projectId, engine, onEngine, settingconst rec = await eng.recordPath(poses, { fps: PATH_FPS, onProgress: setProgress });const ext = rec.type.includes("mp4") ? "mp4" : "webm";setFilming("send");- render = (await uploadFile(new File([rec.render], `path-render.${ext}`, { type: rec.type }))).url;+ const asset = await uploadFile(new File([rec.render], `path-render.${ext}`, { type: rec.type }));+ uploaded = asset.id;+ render = asset.url;} else setFilming("send");await generate.mutateAsync({ input: { ...pathInput, path: { ...pathInput.path!, ...(render ? { render } : {}) } }, folderId: take.generation.folderId });setQueued((n) => n + 1);toast.success("Filming this path — it lands next to the scene as a new take", { duration: 3000 });} catch (e) {+ // A render the run didn't take isn't left in Uploads (the server refuses to delete one that is used).+ if (uploaded) deleteUpload.mutate(uploaded);// Closing the viewer stops a recording: nothing to report then.if ((e as Error).name !== "AbortError") toast.error((e as Error).message || "Couldn't film this path");} finally {diff --git a/workflows/comfyui/manifest.json b/workflows/comfyui/manifest.jsonindex 6f27d3c5..cb7fe8d5 100644--- a/workflows/comfyui/manifest.json+++ b/workflows/comfyui/manifest.json@@ -15723,7 +15723,7 @@{"file": "Wan2_1-I2V-14B-480p_fp8_e4m3fn_scaled_KJ.safetensors","folder": "diffusion_models",- "url": "https://huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/resolve/main/I2V/Wan2_1-I2V-14B-480p_fp8_e4m3fn_scaled_KJ.safetensors",+ "url": "https://huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/resolve/4d02bd37ce7d852ae45a4c2841956db727b480b4/I2V/Wan2_1-I2V-14B-480p_fp8_e4m3fn_scaled_KJ.safetensors","sizeGb": 16.64,"optional": true}