One-click character swap for videos: an open-source, local Higgsfield Genjutsu alternative built on ComfyUI and MiniMax H3, with FLUX.3 Klein relighting.
Add ControlNet tab to Object swap
D3voz71d12cbbd0b9
diff --git a/README.md b/README.mdindex 0a813a4..fa6eed4 100644--- a/README.md+++ b/README.md@@ -8,7 +8,7 @@ The app is a small Next.js front end over a ComfyUI workflow. It uses [`@comfyor- **Simple motion transfer**: available. One character replaces the main person (the one who fills the most of the frame). Runs `workflows/simple.api.json`, exported from `H3 One-Click Single Swap (DMAD 6 step).json`.- **Advanced motion transfer**: available. 1–4 characters, each with an optional role; every tracked person is matched to a role per shot, and people without a character stay untouched. Runs `workflows/advanced.api.json`, exported from `H3 One-Click Advanced Swap (DMAD 6 step).json`; **One pass per person** (two characters) runs `workflows/advanced_maxq.api.json`.-- **Object swap**: available. **Change** what SAM tracks (hair, a jacket, a car) into what you describe or show in a picture; **Remove** it; or change the **Background** around it (`person` stays). Only that area is regenerated. **From picture** runs the Simple swap with the picture as the character: its face, hair and outfit, with the original background. Runs `workflows/object.api.json`, exported from `H3 One-Click Object Swap (DMAD 6 step).json`.+- **Object swap**: available. **Change** what SAM tracks (hair, a jacket, a car) into what you describe or show in a picture; **Remove** it; or change the **Background** around it (`person` stays). Only that area is regenerated. **From picture** runs the Simple swap with the picture as the character: its face, hair and outfit, with the original background. **ControlNet** takes both the person and the place from the picture: the whole frame is regenerated, and a depth map of the person in the video (SAM 3.1 + Depth Anything V2, through the H3 Fun ControlNet Union 2.0) keeps their framing, camera and motion. Everyone else in the video is replaced by the picture's setting. It runs as one H3 clip of up to 15 s (a longer part is cut to its first 15 s), because a continuation clip loses the depth framing. Runs `workflows/object.api.json`, exported from `H3 One-Click Object Swap (DMAD 6 step).json`; ControlNet runs `workflows/control.api.json`, exported from `H3 One-Click Picture Swap ControlNet (DMAD 6 step).json`.- **Post-processing**: available, for a finished video. **Fix faces**: H3 draws faces poorly when the person is small in the frame, so this redraws the face of the person in a photo at close-up size and pastes it back. Runs `workflows/face.api.json`, written by `user/default/openjutsu_face_build.py`. **Fix colours** softens H3's harsh look without an H3 run: Image Detail Contrast takes some fine detail contrast out, then Orion4D's DCTL Tone Mapper grades every frame. Runs `workflows/color.api.json`.## Requirements@@ -32,6 +32,7 @@ Install these into `ComfyUI/custom_nodes` (ComfyUI Manager finds the first three| [ComfyUI-Impact-Pack](https://github.com/ltdrdata/ComfyUI-Impact-Pack) | Fix faces: SAM loader || [comfyui-image-detail-contrast](https://github.com/D3voz/comfyui-image-detail-contrast) | Fix colours: Image Detail Contrast || [Orion4D_FXMax](https://github.com/orion4d/Orion4D_FXMax) | Fix colours: DCTL Tone Mapper and its presets |+| [comfyui_controlnet_aux](https://github.com/Fannovel16/comfyui_controlnet_aux) | ControlNet: Depth Anything V2 (downloads `depth_anything_v2_vitb.pth` on first use) |Restart ComfyUI after installing them.@@ -50,6 +51,7 @@ Before uploading a job, Openjutsu checks the selected workflow against ComfyUI's| `ultralytics/bbox`, `ultralytics/segm` | `face_yolov8m.pt`, `person_yolov8m-seg.pt` ([Bingsu/adetailer](https://huggingface.co/Bingsu/adetailer)), for Fix faces || `sams` | `sam_vit_b_01ec64.pth`, for Fix faces || `insightface/models` | `buffalo_l` (InsightFace downloads it on first use), for Fix faces |+| `model_patches` | `minimax_h3_fun_controlnet_union_2.0_pruned_int8_convrot.safetensors` ([Kijai/MiniMax-H3-experimental](https://huggingface.co/Kijai/MiniMax-H3-experimental/tree/main/model_patches)), for ControlNet |## Run it locallydiff --git a/app/api/jobs/route.ts b/app/api/jobs/route.tsindex c5ae61a..fff6b9a 100644--- a/app/api/jobs/route.ts+++ b/app/api/jobs/route.ts@@ -1,6 +1,7 @@import { apiAccess, HttpError, readFormData } from "../../../lib/http.ts";import { NextResponse } from "next/server";-import { listModels, submitAdvanced, submitColor, submitFace, submitMask, submitMontage, submitObject, submitPeople, submitSimple } from "../../../lib/comfy.ts";+import { listModels, submitAdvanced, submitColor, submitControl, submitFace, submitMask, submitMontage, submitObject, submitPeople, submitSimple } from "../../../lib/comfy.ts";+import type { ControlSettings } from "../../../lib/control.ts";import { TRACKS_FILE, type Label } from "../../../lib/montage.ts";import { DEFAULT_TONE, DETAIL, TONE_MODES, TONE_RANGES, type ColorSettings, type ToneMode, type ToneSettings, type ToneValue } from "../../../lib/color.ts";import { CHUNK_SECONDS, FACE_STYLES, type FaceSettings, type FaceStyle } from "../../../lib/face.ts";@@ -138,6 +139,13 @@ function parseSimple(form: FormData) {return { picture, settings };}+function parseControl(form: FormData) {+ const picture = parsePicture(form.get("picture"));+ const { resolution, seed } = parseRun(form);+ const settings: ControlSettings = { target: parseMask(form).target, noLipSync: form.get("no_lip_sync") === "true", resolution, seed };+ return { picture, settings };+}+function parseAdvanced(form: FormData) {const pictures = form.getAll("picture").map(parsePicture);if (pictures.length < 1 || pictures.length > MAX_CHARACTERS) throw new Error(`Add 1-${MAX_CHARACTERS} character photos.`);@@ -221,6 +229,10 @@ async function submitJob(request: Request) {const { picture, settings } = parseObject(form);const model = parseModel(form, await listModels());submit = () => submitObject(video, section, picture, settings, model);+ } else if (mode === "control") {+ const { picture, settings } = parseControl(form);+ const model = parseModel(form, await listModels());+ submit = () => submitControl(video, section, picture, settings, model);} else if (mode === "face") {const { picture, settings } = parseFace(form);const model = parseModel(form, await listModels());diff --git a/components/openjutsu.tsx b/components/openjutsu.tsxindex 9404f15..a3e0833 100644--- a/components/openjutsu.tsx+++ b/components/openjutsu.tsx@@ -9,6 +9,7 @@ import { CLIP_SECONDS, DEFAULT_TARGET, MARGINS, MAX_SEED, MIN_SECTION_SECONDS, Mimport { MAX_CHARACTERS } from "../lib/advanced.ts";import { DEFAULT_MODEL, MAX_LORAS, STEPS, STRENGTH, type Lora } from "../lib/model.ts";import type { EditMode, PlacementKeyframe } from "../lib/object.ts";+import { CONTROL_MAX_SECONDS } from "../lib/control.ts";import { ObjectPlacement } from "./object-placement.tsx";import { CHUNK_SECONDS, faceChunkCount, type FaceStyle } from "../lib/face.ts";import { DEFAULT_PRESET, DEFAULT_TONE, DETAIL, TONE_MODES, TONE_RANGES, toneFromPreset, type ToneSettings, type ToneValue } from "../lib/color.ts";@@ -17,7 +18,7 @@ import { appearances, renderLabels, type Appearance, type Kept, type Label, typetype Character = { file: File; url: string; role: string };type Mode = "simple" | "advanced" | "object" | "post";type Post = "face" | "color";-type Kind = "simple" | "mask" | "advanced" | "advanced_maxq" | "object" | "face" | "color" | "people" | "montage";+type Kind = "simple" | "mask" | "advanced" | "advanced_maxq" | "object" | "control" | "face" | "color" | "people" | "montage";type TonePreset = { name: string; settings: Record<string, unknown> };// frames: the video, part and crop SAM sawtype Run = { id: string; kind: Kind; margin: Margin; clips: number; clipSeconds: number; startedAt: number; frames: string };@@ -41,14 +42,15 @@ const FACE_STYLE_TEXT: Record<FaceStyle, { label: string; hint: string }> = {mouth: { label: "Follow the mouth", hint: "The face follows the video's expressions and mouth movements; a little less like the photo." },};-// "From picture" is the Simple person swap with the picture as the character.-type EditTab = EditMode | "picture";+// "From picture" is the Simple person swap with the picture as the character; "ControlNet" takes the person and the setting from it.+type EditTab = EditMode | "picture" | "controlnet";const EDITS: { id: EditTab; label: string; target: string; what: string; to: string; toHint: string }[] = [{ id: "change", label: "Change", target: "hair, top", what: "What to change", to: "short bright pink hair and a black leather jacket", toHint: "What it becomes" },{ id: "add", label: "Add", target: "on the table", what: "Where it goes", to: "a chocolate cake on a plate", toHint: "Object to add" },{ id: "remove", label: "Remove", target: "poster", what: "What to remove", to: "a plain wall", toHint: "What shows instead (optional)" },{ id: "background", label: "Background", target: "person", what: "What stays", to: "a snowy mountain pass at dusk", toHint: "The new place" },{ id: "picture", label: "From picture", target: "person", what: "Who is replaced", to: "", toHint: "" },+ { id: "controlnet", label: "ControlNet", target: "person", what: "Who is replaced", to: "", toHint: "" },];function readRun(): Run | null {@@ -316,11 +318,13 @@ export function Openjutsu() {return snapped;}- const clips = !video?.duration ? 0 : faceFix ? faceChunkCount(part.length || video.duration, chunkSeconds) : clipCount(part.length || video.duration, clipSeconds);const edit = EDITS.find((e) => e.id === editMode)!;const fromPicture = mode === "object" && editMode === "picture";+ const controlNet = mode === "object" && editMode === "controlnet";+ const clips = !video?.duration ? 0 : faceFix ? faceChunkCount(part.length || video.duration, chunkSeconds) : controlNet ? 1 : clipCount(part.length || video.duration, clipSeconds);+ const pictureOnly = fromPicture || controlNet;const ready = colorFix ? detailOn || toneOn : mode === "object"- ? editMode === "remove" || (fromPicture ? !!look : (editMode !== "add" || placement.length > 0) && (!!changeTo.trim() || !!look))+ ? editMode === "remove" || (pictureOnly ? !!look : (editMode !== "add" || placement.length > 0) && (!!changeTo.trim() || !!look)): !!character;function chooseLook(files: File[]) {@@ -345,7 +349,7 @@ export function Openjutsu() {form.set("hat_fix", String(hatFix));form.set("no_lip_sync", String(noLipSync));form.set("margin", margin);- form.set("target", fromPicture ? editTarget.trim() || edit.target : target);+ form.set("target", pictureOnly ? editTarget.trim() || edit.target : target);if (kind === "simple" && fromPicture && look) {form.set("picture", look.file);form.set("role", "");@@ -353,7 +357,8 @@ export function Openjutsu() {form.set("picture", character.file);form.set("role", character.role);}- if (kind === "simple") {+ if (kind === "control" && look) form.set("picture", look.file);+ if (kind === "simple" || kind === "control") {form.set("resolution", resolutionField);form.set("seed", String(seed));form.set("clip_seconds", String(clipSeconds));@@ -428,6 +433,7 @@ export function Openjutsu() {else if (kind === "montage") selection = { kind, settings: { ...shared, roles: shown.map((c) => c.role) }, pictures: shown.length, review: review ?? null, model: selectedModel };else if (kind === "object") selection = { kind, settings: { ...shared, mode: editMode as EditMode, target: String(form.get("target")), changeTo, biggestOnly, keepOutline,...(editMode === "add" ? { placement: placement.map((p) => ({ ...p, frame: p.frame - Math.round((whole ? 0 : part.start) * 24) })) } : {}) }, picture: !!look && editMode !== "remove", model: selectedModel };+ else if (kind === "control") selection = { kind, settings: { target: String(form.get("target")), resolution, noLipSync, seed }, model: selectedModel };else if (kind === "face") selection = { kind, settings: { style: faceStyle, seed, chunkSeconds }, model: selectedModel };else if (kind === "color") selection = { kind, settings: { detail: detailOn ? detail : null, tone: toneOn ? tone : null } };else if (kind === "mask") selection = { kind, hatFix, margin, target: String(form.get("target")) };@@ -443,7 +449,7 @@ export function Openjutsu() {const response = await fetch("/api/jobs", { method: "POST", body: form });const body = await response.json();if (!response.ok) throw new Error(body.error ?? "Could not start the job.");- const next: Run = { id: body.id, kind, margin, clips: Math.max(clips, 1), clipSeconds: kind === "face" ? chunkSeconds : clipSeconds, startedAt: Date.now(), frames };+ const next: Run = { id: body.id, kind, margin, clips: Math.max(clips, 1), clipSeconds: kind === "face" ? chunkSeconds : kind === "control" ? CONTROL_MAX_SECONDS : clipSeconds, startedAt: Date.now(), frames };writeRun(next);setJob(body);setProgress(null);@@ -642,7 +648,7 @@ export function Openjutsu() {<span>{edit.what} <small>{editMode === "add" ? "Describe the placement, for example on the table in front of the person." : "What SAM tracks, in English."}{(editMode === "change" || editMode === "remove") && " Separate several with commas."}</small></span><input value={editTarget} maxLength={100} placeholder={edit.target} onChange={(event) => setEditTarget(event.target.value)} /></label>- {!fromPicture && <label>+ {!pictureOnly && <label><span>{edit.toHint}</span><input value={changeTo} maxLength={300} placeholder={`e.g. ${edit.to}`} onChange={(event) => setChangeTo(event.target.value)} /></label>}@@ -654,7 +660,7 @@ export function Openjutsu() {) : (<DropZone accept="image/*" onFiles={chooseLook} className="add"><strong>+</strong>- <span>{fromPicture ? "The picture to copy" : editMode === "add" ? "Picture of the object (optional)" : editMode === "background" ? "Picture of the place (optional)" : "Picture of the new look (optional)"}</span>+ <span>{fromPicture ? "The picture to copy" : controlNet ? "The person in their place" : editMode === "add" ? "Picture of the object (optional)" : editMode === "background" ? "Picture of the place (optional)" : "Picture of the new look (optional)"}</span></DropZone>))}<p className="hint">@@ -663,6 +669,7 @@ export function Openjutsu() {{editMode === "remove" && "What SAM tracks is erased and filled with what is around it. The camera, people and sound stay."}{editMode === "background" && "Everything except what SAM tracks becomes the new place; the camera movement stays."}{fromPicture && "The person in the video becomes the person in the picture: face, hair and outfit. The background, motion, camera and sound stay."}+ {controlNet && `The person and the place both come from the picture. A depth map of the person in the video keeps their framing, camera and motion; the sound stays. Everyone else in the video is replaced by the picture's setting. Runs as one clip of up to ${CONTROL_MAX_SECONDS} s.`}</p>{editMode === "add" && video && canvas && <ObjectPlacement key={`${video.url}:${resolutionField}`} src={video.url}start={whole ? 0 : part.start} end={whole ? video.duration : part.start + part.length} width={canvas[0]} height={canvas[1]} points={placement} onChange={setPlacement} />}@@ -792,8 +799,8 @@ export function Openjutsu() {<input type="checkbox" checked={hatFix} onChange={(event) => setHatFix(event.target.checked)} /><i aria-hidden /></label>}- {(mode === "simple" || mode === "advanced") && <label className="setting toggle">- <span>No lip-sync <small>For songs the people in the video do not sing or talk along to, so the new {mode === "advanced" ? "people" : "person"} do{mode === "advanced" ? "" : "es"} not lip-sync them (about 30 s more per clip).</small></span>+ {(mode === "simple" || mode === "advanced" || controlNet) && <label className="setting toggle">+ <span>No lip-sync <small>For songs the people in the video do not sing or talk along to, so the new {mode === "advanced" ? "people" : "person"} do{mode === "advanced" ? "" : "es"} not lip-sync them{controlNet ? "" : " (about 30 s more per clip)"}.</small></span><input type="checkbox" checked={noLipSync} onChange={(event) => setNoLipSync(event.target.checked)} /><i aria-hidden /></label>}@@ -804,7 +811,7 @@ export function Openjutsu() {<i aria-hidden /></label>)}- {mode !== "post" && <div className="setting">+ {mode !== "post" && !controlNet && <div className="setting"><span>Mask margin <small>{mode === "object"? editMode === "background" ? "How far the new place reaches into the edge of what stays." : "Room around it for a bigger new shape and its shadow.": <>Room around the person for a differently built character.{mode === "simple" ? " Check mask shows it." : ""}</>}</small></span>@@ -824,13 +831,13 @@ export function Openjutsu() {<span>Chunk length <small>{chunkSeconds.toFixed(1)} s of face per H3 generation; chunks overlap by 1 s and are crossfaded.</small></span><input type="range" min={CHUNK_SECONDS.min} max={CHUNK_SECONDS.max} step={0.5} value={chunkSeconds} onChange={(event) => setChunkSeconds(Number(event.target.value))} /></div>- ) : (+ ) : !controlNet && (<div className="setting"><span>Clip length <small>{clipSeconds.toFixed(1)} s per H3 generation</small></span><input type="range" min={CLIP_SECONDS.min} max={CLIP_SECONDS.max} step={0.5} value={clipSeconds} onChange={(event) => setClipSeconds(Number(event.target.value))} /></div>)}- {mode !== "post" && <div className="setting">+ {mode !== "post" && !controlNet && <div className="setting"><span>Motion reference <small>Size of the grey figures H3 copies the motion from. Bigger follows the source poses a bit more closely; sampling takes about a third longer at 768 px and about 2.4× as long at 1376 px.</small></span><div className="segmented">{MOTION_SIZES.map((m) => (@@ -878,7 +885,7 @@ export function Openjutsu() {<button className="secondary" disabled={!video || !character || submitting} onClick={() => submit("people")}>Find people</button><button className="primary" disabled={!video || !character || submitting} onClick={() => submit("montage")}>{submitting ? checkingSetup ? "Checking setup…" : "Uploading…" : "Generate"}</button></>) : (- <button className="primary" disabled={!video || !ready || submitting} onClick={() => submit(mode === "object" ? fromPicture ? "simple" : "object" : mode === "post" ? post : mode === "simple" ? "simple" : onePassEach ? "advanced_maxq" : "advanced")}>+ <button className="primary" disabled={!video || !ready || submitting} onClick={() => submit(mode === "object" ? controlNet ? "control" : fromPicture ? "simple" : "object" : mode === "post" ? post : mode === "simple" ? "simple" : onePassEach ? "advanced_maxq" : "advanced")}>{submitting ? checkingSetup ? "Checking setup…" : "Uploading…" : "Generate"}</button>)}@@ -887,7 +894,9 @@ export function Openjutsu() {? !video ? "Add a video." : ready ? `${(part.length || video.duration).toFixed(1)} s of video` : "Turn on detail contrast, the tone mapper or both.": clips && ready? mode === "advanced" && montage ? `${clips} clip${clips > 1 ? "s" : ""} or more at ${canvas ? `${canvas[0]}×${canvas[1]}` : resolution}; Find people (about 3 minutes per 18 s) lets you check the picks first.`- : faceFix ? `Up to ${clips} chunk${clips > 1 ? "s" : ""} of face` : `${clips} clip${clips > 1 ? "s" : ""} at ${canvas ? `${canvas[0]}×${canvas[1]}` : resolution}`+ : faceFix ? `Up to ${clips} chunk${clips > 1 ? "s" : ""} of face`+ : controlNet ? `One clip at ${canvas ? `${canvas[0]}×${canvas[1]}` : resolution}${(part.length || video!.duration) > CONTROL_MAX_SECONDS ? `: only the first ${CONTROL_MAX_SECONDS} s of this part are used` : ""}`+ : `${clips} clip${clips > 1 ? "s" : ""} at ${canvas ? `${canvas[0]}×${canvas[1]}` : resolution}`: mode === "object" && editMode === "add" && video && !placement.length ? "Draw where the new object should go.": `Add a video and ${mode === "object" ? editMode === "add" ? "describe the object to add" : "say what it becomes" : faceFix ? "the photo of the person" : mode === "simple" ? "a character photo" : "character photos"}.`}</small></div>diff --git a/lib/comfy.ts b/lib/comfy.tsindex 8835c4e..73018e3 100644--- a/lib/comfy.ts+++ b/lib/comfy.ts@@ -9,6 +9,7 @@ import { applyModel, type ModelSettings } from "./model.ts";import { OBJECT_PICTURE, OBJECT_VIDEO, pruneObject, type ObjectSettings } from "./object.ts";import { FACE_PICTURE, FACE_VIDEO, pruneFace, type FaceSettings } from "./face.ts";import { COLOR_VIDEO, pruneColor, type ColorSettings } from "./color.ts";+import { CONTROL_PICTURE, CONTROL_VIDEO, pruneControl, setControlSection, type ControlSettings } from "./control.ts";import { PEOPLE_NODES, peopleRoles, pruneMontage, type Review } from "./montage.ts";export type PublicJob = {@@ -39,7 +40,7 @@ export function rawJobEvents(job: Job, signal: AbortSignal) {return low().getJobEvents(job.urls.events || job.id, { signal });}-export const JOB_KINDS = ["simple", "mask", "advanced", "advanced_maxq", "object", "face", "color", "people", "montage"] as const;+export const JOB_KINDS = ["simple", "mask", "advanced", "advanced_maxq", "object", "control", "face", "color", "people", "montage"] as const;export type JobKind = (typeof JOB_KINDS)[number];export async function loadGraph(kind: JobKind): Promise<ApiGraph> {@@ -110,6 +111,17 @@ export async function submitObject(video: File, section: Section, picture: Filereturn publicJob(await comfy.submit(workflow));}+export async function submitControl(video: File, section: Section, picture: File, settings: ControlSettings, model: ModelSettings) {+ const comfy = client();+ const graph = pruneControl(await loadGraph("control"), settings);+ applyModel(graph, model);+ setControlSection(graph, section);+ const workflow = comfy.workflows.fromJson(graph);+ workflow.setInput(nodeByTitle(graph, CONTROL_VIDEO), "video", await upload(comfy, video));+ workflow.setInput(nodeByTitle(graph, CONTROL_PICTURE), "image", await upload(comfy, picture));+ return publicJob(await comfy.submit(workflow));+}+export async function submitFace(video: File, section: Section, picture: File, settings: FaceSettings, model: ModelSettings) {const comfy = client();const graph = pruneFace(await loadGraph("face"), settings);diff --git a/lib/control.ts b/lib/control.tsnew file mode 100644index 0000000..f5aadcf--- /dev/null+++ b/lib/control.ts@@ -0,0 +1,33 @@+// ControlNet picture swap: the whole frame, the main person and the setting, comes from the picture. A depth video of only+// the main person (SAM 3.1 + Depth Anything V2) holds the framing, camera and poses through the H3 Fun ControlNet Union 2.0.+// workflows/control.api.json is exported (ComfyUI user/default/oneclick_control_build.js) with No lip-sync on; nodes are found by title.+import { nodeByTitle } from "./advanced.ts";+import { dropNoLipSync, setResolution, setSection, type ApiGraph, type Resolution, type Section } from "./simple.ts";++export type ControlSettings = {+ target: string; // what SAM tracks; the biggest one becomes the person in the picture+ resolution: Resolution;+ noLipSync: boolean;+ seed: number;+};++// One H3 clip, the longest H3 is trained on: a continuation clip loses the depth framing where its new frames start.+export const CONTROL_MAX_SECONDS = 15;++export const CONTROL_VIDEO = "Source video (people get replaced)";+export const CONTROL_PICTURE = "Picture 1";+const PLAN = "Swap Plan (roles, seed, size)";++export function pruneControl(source: ApiGraph, settings: ControlSettings): ApiGraph {+ const graph: ApiGraph = structuredClone(source);+ if (!settings.noLipSync) dropNoLipSync(graph);+ graph[nodeByTitle(graph, "SAM: what to replace")].inputs.text = settings.target;+ Object.assign(graph[nodeByTitle(graph, PLAN)].inputs, { seed: settings.seed, clip_seconds: CONTROL_MAX_SECONDS, roles: "" });+ setResolution(graph, nodeByTitle(graph, PLAN), nodeByTitle(graph, CONTROL_VIDEO), settings.resolution);+ return graph;+}++// The whole video, or a longer part, is cut to its first CONTROL_MAX_SECONDS.+export function setControlSection(graph: ApiGraph, section: Section) {+ setSection(graph, nodeByTitle(graph, CONTROL_VIDEO), { start: section.start, length: Math.min(section.length || CONTROL_MAX_SECONDS, CONTROL_MAX_SECONDS) });+}diff --git a/lib/model.ts b/lib/model.tsindex 1ad35c8..5a2425e 100644--- a/lib/model.ts+++ b/lib/model.ts@@ -18,7 +18,7 @@ export const STRENGTH = { min: -4, max: 4 };// Mutates graph: the steps (on the Swap Plan, or the Schedule in Fix faces, which has no plan), the chosen diffusion model,// then the LoRAs in order into whatever read the old LoRA node.export function applyModel(graph: ApiGraph, settings: ModelSettings) {- const plans = Object.values(graph).filter((node) => ["H3OneClickSwapPlan", "H3AdvancedSwapPlan", "H3MontagePlan", "H3ObjectSwapPlan"].includes(node.class_type));+ const plans = Object.values(graph).filter((node) => ["H3OneClickSwapPlan", "H3AdvancedSwapPlan", "H3PictureSwapPlan", "H3MontagePlan", "H3ObjectSwapPlan"].includes(node.class_type));if (plans.length > 1) throw new Error(`Expected one Swap Plan node in the workflow, found ${plans.length}.`);(plans[0] ?? graph[nodeByTitle(graph, "Schedule")]).inputs.steps = settings.steps;const unet = nodeByTitle(graph, "H3 Diffusion Model");diff --git a/lib/setup.ts b/lib/setup.tsindex 218fbbc..64a94d1 100644--- a/lib/setup.ts+++ b/lib/setup.ts@@ -1,5 +1,6 @@import { pruneAdvanced, type AdvancedSettings } from "./advanced.ts";import { pruneColor, type ColorSettings } from "./color.ts";+import { pruneControl, type ControlSettings } from "./control.ts";import { pruneFace, type FaceSettings } from "./face.ts";import { applyModel, type ModelSettings } from "./model.ts";import { PEOPLE_NODES, pruneMontage, type Review } from "./montage.ts";@@ -10,6 +11,7 @@ export type SetupRequest =| { kind: "simple"; settings: SimpleSettings; model: ModelSettings }| { kind: "advanced" | "advanced_maxq"; settings: AdvancedSettings; pictures: number; model: ModelSettings }| { kind: "object"; settings: ObjectSettings; picture: boolean; model: ModelSettings }+ | { kind: "control"; settings: ControlSettings; model: ModelSettings }| { kind: "face"; settings: FaceSettings; model: ModelSettings }| { kind: "color"; settings: ColorSettings }| { kind: "mask"; hatFix: boolean; margin: Margin; target: string }@@ -28,7 +30,7 @@ export type NodeRegistry = Record<string, NodeInfo>;const PACKS = [{ name: "ComfyUI-MiniMaxH3-Context-Loop (0.7.3+)", url: "https://github.com/ethanfel/ComfyUI-MiniMaxH3-Context-Loop", nodes: ["MiniMaxH3GenerationProfile", "MiniMaxH3SourceTimeline", "MiniMaxH3ChainPlanModern", "MiniMaxH3ChainLoopStart", "MiniMaxH3ChainCurrent", "MiniMaxH3ChainContext", "MiniMaxH3ChainSegmentSave", "MiniMaxH3ChainReview", "MiniMaxH3ChainLoopEnd", "MiniMaxH3ChainAssemble", "MiniMaxH3ContexLoopSourceSlice", "MiniMaxH3ContexMaskedTarget", "MiniMaxH3ContexMaskGridPreview", "MiniMaxH3LoopTrim"] },- { name: "comfyui-h3-oneclick-swap", url: "https://github.com/D3voz/comfyui-h3-oneclick-swap", nodes: ["H3OneClickSwapPlan", "H3AdvancedSwapPlan", "H3ObjectSwapPlan", "H3ObjectPlacementMask", "H3PeopleMask", "H3GreyMannequins", "H3ClipShots", "H3FillShots", "H3TrackCrops", "H3TrackRoles", "H3RoleMask", "H3SubjectPrompt", "H3MontagePeople", "H3MontageTracks", "H3MontagePicks", "H3MontagePlan", "H3MontagePass", "H3FaceChunks", "H3FaceJoin"] },+ { name: "comfyui-h3-oneclick-swap", url: "https://github.com/D3voz/comfyui-h3-oneclick-swap", nodes: ["H3OneClickSwapPlan", "H3AdvancedSwapPlan", "H3PictureSwapPlan", "H3ObjectSwapPlan", "H3ObjectPlacementMask", "H3PeopleMask", "H3GreyMannequins", "H3ClipShots", "H3FillShots", "H3TrackCrops", "H3TrackRoles", "H3RoleMask", "H3SubjectPrompt", "H3MontagePeople", "H3MontageTracks", "H3MontagePicks", "H3MontagePlan", "H3MontagePass", "H3FaceChunks", "H3FaceJoin"] },{ name: "ComfyUI-Fantastic-MiniMaxH3-PromptBuilder", url: "https://github.com/Adudeguyman/ComfyUI-Fantastic-MiniMaxH3-PromptBuilder", nodes: ["MiniMaxH3FantasticVideoEditLatent"] },{ name: "ComfyUI-KJNodes", url: "https://github.com/kijai/ComfyUI-KJNodes", nodes: ["GrowMaskWithBlur", "ImageAndMaskPreview"] },{ name: "ComfyUI-VideoHelperSuite", url: "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite", nodes: ["VHS_LoadVideo", "VHS_SelectEveryNthImage", "VHS_VideoCombine"] },@@ -36,6 +38,7 @@ const PACKS = [{ name: "ComfyUI-Impact-Pack", url: "https://github.com/ltdrdata/ComfyUI-Impact-Pack", nodes: ["SAMLoader"] },{ name: "comfyui-image-detail-contrast", url: "https://github.com/D3voz/comfyui-image-detail-contrast", nodes: ["ImageDetailContrast"] },{ name: "Orion4D_FXMax", url: "https://github.com/orion4d/Orion4D_FXMax", nodes: ["Orion4D_FXMax_DCTLToneMapper"] },+ { name: "comfyui_controlnet_aux", url: "https://github.com/Fannovel16/comfyui_controlnet_aux", nodes: ["DepthAnythingV2Preprocessor"] },];const CORE = { name: "ComfyUI (update required)", url: "https://github.com/Comfy-Org/ComfyUI", nodes: [] as string[] };const MODEL_INPUTS: Record<string, Record<string, string>> = {@@ -45,6 +48,7 @@ const MODEL_INPUTS: Record<string, Record<string, string>> = {VAELoader: { vae_name: "vae" },CheckpointLoaderSimple: { ckpt_name: "checkpoints" },SAMLoader: { model_name: "sams" },+ ModelPatchLoader: { name: "model_patches" },H3FaceTrackCrop: { detector: "ultralytics", fallback_detector: "ultralytics" },};@@ -52,6 +56,7 @@ export function setupGraph(source: ApiGraph, selection: SetupRequest): ApiGraphlet graph: ApiGraph;if (selection.kind === "simple") graph = pruneSimple(source, selection.settings);else if (selection.kind === "object") graph = pruneObject(source, selection.picture, selection.settings);+ else if (selection.kind === "control") graph = pruneControl(source, selection.settings);else if (selection.kind === "face") graph = pruneFace(source, selection.settings);else if (selection.kind === "color") graph = pruneColor(source, selection.settings);else if (selection.kind === "mask") graph = pruneMask(source, selection.hatFix, selection.margin, selection.target);diff --git a/test/control.test.ts b/test/control.test.tsnew file mode 100644index 0000000..bd91f8c--- /dev/null+++ b/test/control.test.ts@@ -0,0 +1,54 @@+import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import test from "node:test";+import { nodeByTitle } from "../lib/advanced.ts";+import { CONTROL_MAX_SECONDS, CONTROL_PICTURE, CONTROL_VIDEO, pruneControl, setControlSection, type ControlSettings } from "../lib/control.ts";+import { applyModel } from "../lib/model.ts";+import { isLink, type ApiGraph } from "../lib/simple.ts";++const graph: ApiGraph = JSON.parse(readFileSync(new URL("../workflows/control.api.json", import.meta.url), "utf8"));+const settings = (noLipSync: boolean): ControlSettings => ({ target: "dancer", resolution: "480p", noLipSync, seed: 3 });+const byClass = (g: ApiGraph, type: string) => Object.keys(g).filter((id) => g[id].class_type === type);+const dangling = (g: ApiGraph) => Object.values(g).flatMap((node) => Object.values(node.inputs)).filter((v) => isLink(v) && !g[v[0]]);++test("the export regenerates the whole frame from the picture, held by the person depth", () => {+ assert.equal(graph[nodeByTitle(graph, CONTROL_VIDEO)].class_type, "VHS_LoadVideo");+ assert.equal(graph[nodeByTitle(graph, CONTROL_PICTURE)].class_type, "LoadImage");+ const [fun] = byClass(graph, "MiniMaxH3FunControlNetApply");+ assert.deepEqual(graph[fun].inputs.control_video, [nodeByTitle(graph, "Depth of the main person only (control video)"), 0]);+ for (const id of byClass(graph, "BasicGuider").concat(byClass(graph, "BasicScheduler"))) assert.deepEqual(graph[id].inputs.model, [fun, 0]);+ const whole = nodeByTitle(graph, "Whole frame (regenerate everything)");+ for (const type of ["MiniMaxH3FantasticVideoEditLatent", "MiniMaxH3ContexMaskedTarget"]) assert.deepEqual(graph[byClass(graph, type)[0]].inputs.mask, [whole, 0]);+ const ref = graph[byClass(graph, "MiniMaxH3ReferenceToVideo")[0]].inputs;+ assert.ok(ref["ref_images.ref_image_0"] && !ref["ref_videos.ref_video_0"], "the picture only, no source video reference");+});++test("settings reach the plan and SAM; No lip-sync off rewires the audio and drops the prompt switch", () => {+ const pruned = pruneControl(graph, settings(false));+ const plan = pruned[nodeByTitle(pruned, "Swap Plan (roles, seed, size)")].inputs;+ assert.deepEqual([plan.resolution, plan.seed, plan.clip_seconds, plan.roles, plan.no_lip_sync], ["480p", 3, CONTROL_MAX_SECONDS, "", undefined]);+ assert.equal(pruned[nodeByTitle(pruned, "SAM: what to replace")].inputs.text, "dancer");+ assert.equal(byClass(pruned, "AudioAdjustVolume").length, 0);+ assert.deepEqual(dangling(pruned), []);+ assert.equal(byClass(pruneControl(graph, settings(true)), "AudioAdjustVolume").length, 2);+ assert.ok(byClass(graph, "AudioAdjustVolume").length === 2, "the source graph is not modified");+});++test("the video is cut to one clip of at most 15 s", () => {+ const frames = (section: { start: number; length: number }) => {+ const pruned = pruneControl(graph, settings(true));+ setControlSection(pruned, section);+ const loader = pruned[nodeByTitle(pruned, CONTROL_VIDEO)].inputs;+ return [loader.skip_first_frames, loader.frame_load_cap];+ };+ assert.deepEqual(frames({ start: 0, length: 0 }), [0, 360]);+ assert.deepEqual(frames({ start: 2, length: 20 }), [48, 360]);+ assert.deepEqual(frames({ start: 1, length: 8 }), [24, 192]);+});++test("the model settings apply to the picture plan", () => {+ const pruned = pruneControl(graph, settings(true));+ applyModel(pruned, { model: "other.safetensors", loras: [], steps: 9 });+ assert.equal(pruned[byClass(pruned, "H3PictureSwapPlan")[0]].inputs.steps, 9);+ assert.deepEqual(dangling(pruned), []);+});diff --git a/test/setup.test.ts b/test/setup.test.tsindex 7d1abdf..1ca8927 100644--- a/test/setup.test.ts+++ b/test/setup.test.ts@@ -24,7 +24,7 @@ function registryFor(...graphs: ApiGraph[]): NodeRegistry {return registry;}-test("all nine workflows pass with their nodes and model filenames registered", () => {+test("all ten workflows pass with their nodes and model filenames registered", () => {for (const kind of JOB_KINDS) {const graph = load(kind);assert.deepEqual(inspectSetup(graph, registryFor(graph)), { ok: true, packs: [], models: [] }, kind);@@ -43,7 +43,7 @@ test("missing nodes are grouped by their source pack, including both published D});test("all custom node types in the exports have a pack mapping", () => {- const custom = /^(H3|MiniMaxH3(?!ReferenceToVideo|SigmaShift)|VHS_|GrowMaskWithBlur$|ImageAndMaskPreview$|ImageDetailContrast$|Orion4D_|SAMLoader$)/;+ const custom = /^(H3|MiniMaxH3(?!ReferenceToVideo|SigmaShift|FunControlNetApply)|VHS_|GrowMaskWithBlur$|ImageAndMaskPreview$|ImageDetailContrast$|Orion4D_|SAMLoader$)/;const graphs = JOB_KINDS.map(load);const missing = inspectSetup(Object.fromEntries(graphs.flatMap((g, i) => Object.entries(g).map(([id, node]) => [`${i}_${id}`, node]))), {});const core = missing.packs.find((p) => p.url === "https://github.com/Comfy-Org/ComfyUI")!;diff --git a/workflows/control.api.json b/workflows/control.api.jsonnew file mode 100644index 0000000..3709850--- /dev/null+++ b/workflows/control.api.json@@ -0,0 +1,1311 @@+{+ "2": {+ "inputs": {+ "image": "apt_vest_reference.png"+ },+ "class_type": "LoadImage",+ "_meta": {+ "title": "Picture 1",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "3": {+ "inputs": {+ "upscale_method": "area",+ "largest_size": 768,+ "image": [+ "2",+ 0+ ]+ },+ "class_type": "ImageScaleToMaxDimension",+ "_meta": {+ "title": "Shrink for the describer",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "4": {+ "inputs": {+ "prompt": "Describe the person in this picture for a casting sheet, in one sentence of about 40 words: apparent age and gender, hair, facial hair, skin tone, build, and their complete outfit including footwear. No preamble, no background.",+ "max_length": 120,+ "sampling_mode": "off",+ "thinking": false,+ "use_default_template": true,+ "mtp": "auto",+ "clip": [+ "13",+ 0+ ],+ "image": [+ "3",+ 0+ ]+ },+ "class_type": "TextGenerate",+ "_meta": {+ "title": "Describe picture 1",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "5": {+ "inputs": {+ "video": "spiderman_jeangrey_apt.mp4",+ "force_rate": 24,+ "custom_width": 0,+ "custom_height": 0,+ "frame_load_cap": 0,+ "skip_first_frames": 0,+ "select_every_nth": 1,+ "format": "None"+ },+ "class_type": "VHS_LoadVideo",+ "_meta": {+ "title": "Source video (people get replaced)",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "6": {+ "inputs": {+ "start_index": 0,+ "duration": 2048,+ "audio": [+ "5",+ 2+ ]+ },+ "class_type": "TrimAudioDuration",+ "_meta": {+ "title": "Soundtrack (whole video)",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "7": {+ "inputs": {+ "select_every_nth": 48,+ "skip_first_images": 24,+ "images": [+ "5",+ 0+ ]+ },+ "class_type": "VHS_SelectEveryNthImage",+ "_meta": {+ "title": "One frame every 2 s",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "8": {+ "inputs": {+ "batch_index": 0,+ "length": 20,+ "image": [+ "7",+ 0+ ]+ },+ "class_type": "ImageFromBatch",+ "_meta": {+ "title": "At most 20 frames",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "9": {+ "inputs": {+ "upscale_method": "area",+ "largest_size": 640,+ "image": [+ "8",+ 0+ ]+ },+ "class_type": "ImageScaleToMaxDimension",+ "_meta": {+ "title": "Shrink for the describer",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "10": {+ "inputs": {+ "prompt": "These are frames from one video, in time order. List the people who appear most, up to four, the person with the most screen time first. Write one numbered line per person: first their role in the video in two to four words, without gender, that stays true in every shot, then \" - \" and how they look, like \"1. the guitarist - tall man with a grey beard in a denim jacket\". Each person appears once. Output only the list.",+ "max_length": 160,+ "sampling_mode": "off",+ "thinking": false,+ "use_default_template": true,+ "mtp": "auto",+ "clip": [+ "13",+ 0+ ],+ "image": [+ "9",+ 0+ ]+ },+ "class_type": "TextGenerate",+ "_meta": {+ "title": "Who is in the video",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "11": {+ "inputs": {+ "clip_seconds": 6,+ "overlap_frames": 39,+ "resolution": "736p",+ "steps": 6,+ "seed": 0,+ "roles": "",+ "no_lip_sync": [+ "68",+ 0+ ],+ "short_edge": 0,+ "source_frames": [+ "5",+ 0+ ],+ "picture_1": [+ "2",+ 0+ ],+ "picture_1_text": [+ "4",+ 0+ ],+ "video_people": [+ "10",+ 0+ ]+ },+ "class_type": "H3PictureSwapPlan",+ "_meta": {+ "title": "Swap Plan (roles, seed, size)",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "13": {+ "inputs": {+ "clip_name": "qwen3vl_8b_int8_convrot.safetensors",+ "type": "stable_diffusion",+ "device": "default"+ },+ "class_type": "CLIPLoader",+ "_meta": {+ "title": "Describer: Qwen3-VL 8B",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "15": {+ "inputs": {+ "unet_name": "minimax_h3_ref2va_pruned_int8_convrot.safetensors",+ "weight_dtype": "default"+ },+ "class_type": "UNETLoader",+ "_meta": {+ "title": "H3 Diffusion Model",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "16": {+ "inputs": {+ "lora_name": "minimax_h3_DMAD_4step_full_lora_avg_rank_39_bf16.safetensors",+ "strength_model": 1,+ "model": [+ "15",+ 0+ ]+ },+ "class_type": "LoraLoaderModelOnly",+ "_meta": {+ "title": "DMAD LoRA",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "17": {+ "inputs": {+ "attention": "comfy kitchen attention",+ "model": [+ "16",+ 0+ ]+ },+ "class_type": "ModelAttentionBackend",+ "_meta": {+ "title": "Comfy Kitchen Attention",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "18": {+ "inputs": {+ "shift_video": 12,+ "shift_audio": 2,+ "model": [+ "17",+ 0+ ]+ },+ "class_type": "MiniMaxH3SigmaShift",+ "_meta": {+ "title": "Sigma Shift",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "19": {+ "inputs": {+ "clip_name": "qwen3vl_32b_minimax_h3_int4_convrot.safetensors",+ "type": "minimax",+ "device": "default"+ },+ "class_type": "CLIPLoader",+ "_meta": {+ "title": "H3 Text Encoder",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "20": {+ "inputs": {+ "vae_name": "minimax_h3_video_vae_int8_convrot.safetensors"+ },+ "class_type": "VAELoader",+ "_meta": {+ "title": "Video VAE",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "21": {+ "inputs": {+ "vae_name": "minimax_h3_audio_vae_fp32.safetensors"+ },+ "class_type": "VAELoader",+ "_meta": {+ "title": "Audio VAE",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "22": {+ "inputs": {+ "sampler_name": "euler"+ },+ "class_type": "KSamplerSelect",+ "_meta": {+ "title": "Sampler",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "23": {+ "inputs": {+ "ckpt_name": "sam3.1_multiplex_fp16.safetensors"+ },+ "class_type": "CheckpointLoaderSimple",+ "_meta": {+ "title": "SAM 3.1",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "24": {+ "inputs": {+ "text": "person",+ "clip": [+ "23",+ 1+ ]+ },+ "class_type": "CLIPTextEncode",+ "_meta": {+ "title": "SAM: what to replace",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "25": {+ "inputs": {+ "scene_continuity": "Hard picture + protected audio",+ "audio_profile": "Generate audio"+ },+ "class_type": "MiniMaxH3GenerationProfile",+ "_meta": {+ "title": "Generation Profile",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "26": {+ "inputs": {+ "plan_json": "{\n \"shots\": [\n {\n \"id\": \"intro\",\n \"prompt\": \"Describe the opening shot.\"\n },\n {\n \"id\": \"continuation\",\n \"prompt\": \"Continue the same take.\"\n }\n ]\n}",+ "run_name": [+ "11",+ 3+ ],+ "generation_fingerprint": "",+ "width": [+ "11",+ 1+ ],+ "height": [+ "11",+ 2+ ],+ "encode_mode": "video",+ "crop": "center",+ "default_duration_seconds": 15,+ "default_steps": 6,+ "base_seed": 0,+ "segment_crf": 16,+ "video_blend_frames": 0,+ "chain_policy": [+ "25",+ 0+ ],+ "plan_json_input": [+ "11",+ 0+ ]+ },+ "class_type": "MiniMaxH3ChainPlanModern",+ "_meta": {+ "title": "Production Plan (filled by Swap Plan)",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "27": {+ "inputs": {+ "video_path": "",+ "audio_path": "",+ "embedded_audio": "auto",+ "skip_first_frames": 0,+ "source_audio": [+ "6",+ 0+ ]+ },+ "class_type": "MiniMaxH3SourceTimeline",+ "_meta": {+ "title": "Source soundtrack",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "28": {+ "inputs": {+ "start_clip": 1,+ "scene_range": "",+ "verify_resume_history": true,+ "plan": [+ "26",+ 0+ ],+ "source_timeline": [+ "27",+ 0+ ]+ },+ "class_type": "MiniMaxH3ChainLoopStart",+ "_meta": {+ "title": "Loop Start",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "29": {+ "inputs": {+ "align_audio_reference": false,+ "state": [+ "28",+ 1+ ]+ },+ "class_type": "MiniMaxH3ChainCurrent",+ "_meta": {+ "title": "Current Clip",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "30": {+ "inputs": {+ "prompt": [+ "46",+ 0+ ],+ "width": [+ "29",+ 8+ ],+ "height": [+ "29",+ 9+ ],+ "length": [+ "29",+ 6+ ],+ "ref_image_size": "match",+ "clip": [+ "19",+ 0+ ],+ "vae": [+ "20",+ 0+ ],+ "audio_vae": [+ "21",+ 0+ ],+ "ref_images.ref_image_0": [+ "2",+ 0+ ],+ "ref_audios.ref_audio_0": [+ "70",+ 0+ ]+ },+ "class_type": "MiniMaxH3ReferenceToVideo",+ "_meta": {+ "title": "Reference Conditioning",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "31": {+ "inputs": {+ "source_fps": 24,+ "crop": "center",+ "state": [+ "29",+ 0+ ],+ "latent": [+ "30",+ 1+ ],+ "audio_vae": [+ "21",+ 0+ ],+ "source_frames": [+ "5",+ 0+ ],+ "source_audio": [+ "69",+ 0+ ]+ },+ "class_type": "MiniMaxH3ContexLoopSourceSlice",+ "_meta": {+ "title": "Source clip (frames + audio)",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "32": {+ "inputs": {+ "upscale_method": "area",+ "largest_size": 512,+ "image": [+ "5",+ 0+ ]+ },+ "class_type": "ImageScaleToMaxDimension",+ "_meta": {+ "title": "Shot list frames (~512 px)",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "33": {+ "inputs": {+ "expression": "round(a * 24)",+ "values.a": [+ "29",+ 10+ ]+ },+ "class_type": "ComfyMathExpression",+ "_meta": {+ "title": "Clip start frame",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "34": {+ "inputs": {+ "batch_index": [+ "33",+ 1+ ],+ "length": [+ "29",+ 6+ ],+ "image": [+ "32",+ 0+ ]+ },+ "class_type": "ImageFromBatch",+ "_meta": {+ "title": "Shot list frames for this clip",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "35": {+ "inputs": {+ "upscale_method": "area",+ "largest_size": 1008,+ "image": [+ "5",+ 0+ ]+ },+ "class_type": "ImageScaleToMaxDimension",+ "_meta": {+ "title": "SAM video (1008 px, SAM's own size)",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "36": {+ "inputs": {+ "batch_index": [+ "33",+ 1+ ],+ "length": [+ "29",+ 6+ ],+ "image": [+ "35",+ 0+ ]+ },+ "class_type": "ImageFromBatch",+ "_meta": {+ "title": "SAM frames for this clip",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "37": {+ "inputs": {+ "noise_seed": [+ "29",+ 5+ ]+ },+ "class_type": "RandomNoise",+ "_meta": {+ "title": "Clip Seed",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "38": {+ "inputs": {+ "detection_threshold": 0.35,+ "max_objects": 0,+ "detect_interval": 1,+ "images": [+ "36",+ 0+ ],+ "model": [+ "23",+ 0+ ],+ "conditioning": [+ "24",+ 0+ ]+ },+ "class_type": "SAM3_VideoTrack",+ "_meta": {+ "title": "SAM 3.1 track every person",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "39": {+ "inputs": {+ "headroom": 0,+ "hold_frames": 1,+ "max_people": 1,+ "track_data": [+ "38",+ 0+ ]+ },+ "class_type": "H3PeopleMask",+ "_meta": {+ "title": "Main person, no headroom (for the depth)",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "40": {+ "inputs": {+ "mask": [+ "39",+ 0+ ]+ },+ "class_type": "MaskToImage",+ "_meta": {+ "title": "Main person mask as image",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "41": {+ "inputs": {+ "ckpt_name": "depth_anything_v2_vitb.pth",+ "resolution": 512,+ "image": [+ "36",+ 0+ ]+ },+ "class_type": "DepthAnythingV2Preprocessor",+ "_meta": {+ "title": "Depth of this clip (Depth Anything V2)",+ "cnr_id": "comfyui_controlnet_aux",+ "ver": "a587a4c1594524c1d2de5cd1a86cd868ff448e1c"+ }+ },+ "42": {+ "inputs": {+ "blend_factor": 1,+ "blend_mode": "multiply",+ "image1": [+ "41",+ 0+ ],+ "image2": [+ "40",+ 0+ ]+ },+ "class_type": "ImageBlend",+ "_meta": {+ "title": "Depth of the main person only (control video)",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "43": {+ "inputs": {+ "value": 1,+ "width": [+ "29",+ 8+ ],+ "height": [+ "29",+ 9+ ]+ },+ "class_type": "SolidMask",+ "_meta": {+ "title": "Whole frame (regenerate everything)",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "44": {+ "inputs": {+ "cut_threshold": 40,+ "images": [+ "34",+ 0+ ],+ "shot_prompt": [+ "11",+ 4+ ]+ },+ "class_type": "H3ClipShots",+ "_meta": {+ "title": "Find this clip's cuts",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "45": {+ "inputs": {+ "prompt": [+ "44",+ 1+ ],+ "max_length": 500,+ "sampling_mode": "off",+ "thinking": false,+ "use_default_template": true,+ "mtp": "auto",+ "clip": [+ "13",+ 0+ ],+ "image": [+ "44",+ 0+ ]+ },+ "class_type": "TextGenerate",+ "_meta": {+ "title": "Write this clip's shot list (Qwen3-VL)",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "46": {+ "inputs": {+ "prompt": [+ "29",+ 4+ ],+ "shots": [+ "45",+ 0+ ]+ },+ "class_type": "H3FillShots",+ "_meta": {+ "title": "Insert shot list into prompt",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "47": {+ "inputs": {+ "source": [+ "46",+ 0+ ]+ },+ "class_type": "PreviewAny",+ "_meta": {+ "title": "Clip prompt (what H3 gets)",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "48": {+ "inputs": {+ "name": "minimax_h3_fun_controlnet_union_2.0_pruned_int8_convrot.safetensors"+ },+ "class_type": "ModelPatchLoader",+ "_meta": {+ "title": "H3 Fun ControlNet Union 2.0",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "49": {+ "inputs": {+ "strength": 1,+ "start_percent": 0,+ "end_percent": 1,+ "model": [+ "18",+ 0+ ],+ "model_patch": [+ "48",+ 0+ ],+ "vae": [+ "20",+ 0+ ],+ "control_video": [+ "42",+ 0+ ]+ },+ "class_type": "MiniMaxH3FunControlNetApply",+ "_meta": {+ "title": "Apply ControlNet (person depth)",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "50": {+ "inputs": {+ "images": [+ "42",+ 0+ ]+ },+ "class_type": "PreviewImage",+ "_meta": {+ "title": "Control video (person depth)",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "51": {+ "inputs": {+ "grow": 0,+ "keep_audio": true,+ "megapixels": 0,+ "vae": [+ "20",+ 0+ ],+ "images": [+ "31",+ 0+ ],+ "mask": [+ "43",+ 0+ ],+ "audio_vae": [+ "21",+ 0+ ],+ "audio": [+ "31",+ 1+ ]+ },+ "class_type": "MiniMaxH3FantasticVideoEditLatent",+ "_meta": {+ "title": "Edit latent (source + mask + audio)",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "52": {+ "inputs": {+ "mask_meaning": "white = generate",+ "audio_mode": "preserve source audio",+ "mask_conversion": "H3 exact (causal/token max)",+ "target_latent": [+ "51",+ 0+ ],+ "mask": [+ "43",+ 0+ ]+ },+ "class_type": "MiniMaxH3ContexMaskedTarget",+ "_meta": {+ "title": "Masked target",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "53": {+ "inputs": {+ "state": [+ "29",+ 0+ ],+ "conditioning": [+ "30",+ 0+ ],+ "vae": [+ "20",+ 0+ ],+ "latent": [+ "52",+ 0+ ],+ "audio_vae": [+ "21",+ 0+ ]+ },+ "class_type": "MiniMaxH3ChainContext",+ "_meta": {+ "title": "Apply Clip Context",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "54": {+ "inputs": {+ "model": [+ "49",+ 0+ ],+ "conditioning": [+ "53",+ 0+ ]+ },+ "class_type": "BasicGuider",+ "_meta": {+ "title": "Guider",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "55": {+ "inputs": {+ "scheduler": "simple",+ "steps": [+ "29",+ 7+ ],+ "denoise": 1,+ "model": [+ "49",+ 0+ ]+ },+ "class_type": "BasicScheduler",+ "_meta": {+ "title": "Schedule",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "56": {+ "inputs": {+ "noise": [+ "37",+ 0+ ],+ "guider": [+ "54",+ 0+ ],+ "sampler": [+ "22",+ 0+ ],+ "sigmas": [+ "55",+ 0+ ],+ "latent_image": [+ "53",+ 3+ ]+ },+ "class_type": "SamplerCustomAdvanced",+ "_meta": {+ "title": "Sample Video + Audio",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "57": {+ "inputs": {+ "samples": [+ "56",+ 0+ ],+ "vae": [+ "20",+ 0+ ]+ },+ "class_type": "VAEDecode",+ "_meta": {+ "title": "Decode Video",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "58": {+ "inputs": {+ "samples": [+ "56",+ 0+ ],+ "vae": [+ "21",+ 0+ ]+ },+ "class_type": "VAEDecodeAudio",+ "_meta": {+ "title": "Decode Audio",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "59": {+ "inputs": {+ "trim_frames": [+ "53",+ 1+ ],+ "fps": 24,+ "match_tail": true,+ "audio_trim_mode": "sync_with_video",+ "images": [+ "63",+ 0+ ],+ "audio": [+ "58",+ 0+ ],+ "state": [+ "29",+ 0+ ]+ },+ "class_type": "MiniMaxH3LoopTrim",+ "_meta": {+ "title": "Trim Overlap",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "60": {+ "inputs": {+ "batch_index": 2,+ "length": 1,+ "image": [+ "57",+ 0+ ]+ },+ "class_type": "ImageFromBatch",+ "_meta": {+ "title": "Frame 2",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "61": {+ "inputs": {+ "amount": 2,+ "image": [+ "60",+ 0+ ]+ },+ "class_type": "RepeatImageBatch",+ "_meta": {+ "title": "Frame 2 as frames 0 and 1 (they show the picture)",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "62": {+ "inputs": {+ "batch_index": 2,+ "length": 4096,+ "image": [+ "57",+ 0+ ]+ },+ "class_type": "ImageFromBatch",+ "_meta": {+ "title": "Frame 2 to the end",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "63": {+ "inputs": {+ "images.image0": [+ "61",+ 0+ ],+ "images.image1": [+ "62",+ 0+ ]+ },+ "class_type": "BatchImagesNode",+ "_meta": {+ "title": "Clip with frames 0 and 1 replaced",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "64": {+ "inputs": {+ "state": [+ "29",+ 0+ ],+ "images": [+ "59",+ 0+ ],+ "sampled_latent": [+ "56",+ 0+ ],+ "audio": [+ "59",+ 1+ ],+ "images_with_overlap": [+ "59",+ 2+ ]+ },+ "class_type": "MiniMaxH3ChainSegmentSave",+ "_meta": {+ "title": "Save Clip + Checkpoint",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "65": {+ "inputs": {+ "enabled": false,+ "play_notification_sound": false,+ "auto_continue_timeout_minutes": 0,+ "unload_models_while_waiting": false,+ "assemble_partial_on_stop": true,+ "partial_audio_source": "checkpointed",+ "candidate_count": 1,+ "review_each_candidate": false,+ "state": [+ "29",+ 0+ ],+ "segment": [+ "64",+ 0+ ],+ "audio": [+ "59",+ 1+ ]+ },+ "class_type": "MiniMaxH3ChainReview",+ "_meta": {+ "title": "Review (off = no pause)",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "66": {+ "inputs": {+ "between_scene_cleanup": "off",+ "execution_mode": "recursive",+ "flow": [+ "28",+ 0+ ],+ "state": [+ "29",+ 0+ ],+ "images": [+ "59",+ 0+ ],+ "sampled_latent": [+ "56",+ 0+ ],+ "segment": [+ "65",+ 0+ ]+ },+ "class_type": "MiniMaxH3ChainLoopEnd",+ "_meta": {+ "title": "Loop End",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "67": {+ "inputs": {+ "audio_source": "source",+ "filename": "swap_%date:yyyy-MM-dd%",+ "audio_bitrate": 256,+ "copy_to_output": true,+ "output_subfolder": "h3_oneclick_swap",+ "blend_schedule": "plan",+ "boundary_tone_match": "off",+ "color_stabilization": "off",+ "delete_checkpoints_after_assembly": false,+ "generated_audio_join": "av_overlap",+ "manifest": [+ "66",+ 0+ ]+ },+ "class_type": "MiniMaxH3ChainAssemble",+ "_meta": {+ "title": "Final Video",+ "cnr_id": "comfyui-workflow-encrypt",+ "ver": "1.0.0"+ }+ },+ "68": {+ "inputs": {+ "value": true+ },+ "class_type": "PrimitiveBoolean",+ "_meta": {+ "title": "No lip-sync in the prompt",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "69": {+ "inputs": {+ "volume": -100,+ "audio": [+ "6",+ 0+ ]+ },+ "class_type": "AudioAdjustVolume",+ "_meta": {+ "title": "Mute the clip audio H3 hears",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ },+ "70": {+ "inputs": {+ "volume": -100,+ "audio": [+ "29",+ 12+ ]+ },+ "class_type": "AudioAdjustVolume",+ "_meta": {+ "title": "Mute the reference audio H3 hears",+ "cnr_id": "comfy-core",+ "ver": "0.42.0"+ }+ }+}\ No newline at end of file