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.

Video references: a picture's person moving like the clip runs as Motion transfer

Adarshb10bc94c9714
diff --git a/scripts/comfy/validation-state.json b/scripts/comfy/validation-state.json
index f7a47102..198bcc35 100644
--- a/scripts/comfy/validation-state.json
+++ b/scripts/comfy/validation-state.json
@@ -1367,6 +1367,12 @@
"error": "HTTP 400: missing_node_type: Node 'VRMBG 3.0: each frame conditioned on the one before' not found. The custom node may not be installed. (Node ID '#3')",
"at": "2026-11-02T11:08:13.090Z"
},
+ "video-motion-transfer-h3": {
+ "sha256": "5968d25aa34e29478d41f88a812e4ec183ea64d2e7a44663c7bad9b1669bb9f8",
+ "validated": true,
+ "error": null,
+ "at": "2026-11-11T10:48:42.399Z"
+ },
"video-mux-audio": {
"sha256": "68af795bae0c0e89749819173916044e4024a6ce3035f830b48c80e0b6899181",
"validated": true,
diff --git a/src/app/api/generations/route.ts b/src/app/api/generations/route.ts
index 60210ee9..8337a865 100644
--- a/src/app/api/generations/route.ts
+++ b/src/app/api/generations/route.ts
@@ -32,6 +32,8 @@ import { withRunStamp, type RunStamp } from "@/server/run-stamp";
import { hostedRunsOn } from "@/server/hosted-switch";
import { endTry, notePressRun, pressPrior, pressRun, pressTries, pressTry, readPressId } from "@/server/run-requests";
import { limitFields, limitWords } from "@/lib/limit-words";
+import { motionCopyRequest } from "@/lib/motion-copy";
+import { storedMedia } from "@/server/storage";
/**
* List generations, newest first. Filters: kind / kinds, features (`x*` = prefix), models, statuses,
@@ -183,6 +185,11 @@ export async function POST(request: Request) {
// The owner's run sent with an API token (a script, the CLI, an agent) and no source of its own reads as automated.
let req = account ? { ...asked, account: account.id, source: undefined, sourceName: undefined, engine: accountEngineMode(account.id) === "open" ? ("open" as const) : asked.engine } : { ...asked, account: undefined, ...(token && !asked.source && { source: "api" as const }) };
const onOwn = <T,>(fn: () => T): T => (account ? asAccount(account.id, fn) : fn());
+ // The person in a picture moving like the clip, asked of H3 with references, runs as Motion transfer (src/lib/motion-copy.ts),
+ // from the start of the clip for as long as it lasts.
+ const clip = req.inputs?.videos?.[0];
+ const copied = motionCopyRequest(req, clip ? onOwn(() => storedMedia(clip)?.info?.duration) : undefined);
+ if (copied) req = copied;
// A visitor's price check: priced as it would run, as that visitor (an account: its own GPU and keys; a guest: the open
// engine, no demo).
const priced = <T,>(fn: () => T): T => (viewer.kind === "owner" ? fn() : account ? asAccount(account.id, fn) : asVisitor(null, fn));
diff --git a/src/lib/h3-references.ts b/src/lib/h3-references.ts
index b20795b2..5cc3202c 100644
--- a/src/lib/h3-references.ts
+++ b/src/lib/h3-references.ts
@@ -148,110 +148,21 @@ export function expandH3References(wf: ComfyWorkflow, files: H3ReferenceFiles):
return out;
}
-/** Where a motion copy takes place: the clip's setting and camera (with the new person in it), or the picture's own setting. */
-export type H3MotionPlace = "picture" | "clip";
-
-/** The place a motion copy uses when the words don't say. */
-export const H3_MOTION_DEFAULT_PLACE: H3MotionPlace = "clip";
-
-export interface H3MotionPlan {
- /** The picture whose person performs the motion (1-based). */
- picture: number;
- /** How the words name that person ("woman"), or "person". */
- who: string;
- place: H3MotionPlace;
-}
-
const MOTION_WORD = /\b(?:danc\w*|move|moves|moving|movements?|motion|choreograph\w*|steps|poses?|posing|gestures?|perform\w*|mimic\w*|copy|copies|copying|imitat\w*)\b/i;
-const PERSON_WORD = /^(?:woman|man|girl|boy|lady|guy|person|model|dancer|actor|actress|character|singer|athlete)$/i;
-const PLACE_NOUN = "(?:setting|place|room|background|location|studio|stage|scene|set)";
-const placeOf = (tag: "Video" | "Picture") =>
- new RegExp(`\\b${PLACE_NOUN}\\s+(?:of|from|in)\\s+<${tag} \\d+>|<${tag} \\d+>'s\\s+${PLACE_NOUN}\\b|\\b(?:same|that)\\s+${PLACE_NOUN}\\s+as\\s+<${tag} \\d+>`, "i");
-const CLIP_PLACE = placeOf("Video");
-const PICTURE_PLACE = placeOf("Picture");
const IN_LAYOUT = /\b(?:integrated_multimodal_description|subject_definitions)\s*:/;
/**
- * Whether the words ask for the person in a reference picture to perform the movement of the reference clip ("the woman in
- * image 1 dancing like the woman in clip 1"), and which picture and place. Null for anything else, for words already in
- * H3's layout, and for more than one clip or any voice or music clip.
+ * Whether the words ask for the person in a reference picture to perform the movement of the one reference clip ("the
+ * woman in image 1 dancing like the woman in clip 1"), and which picture (1-based). Null for anything else, for words
+ * already in H3's layout, and for more than one clip or any voice or music clip.
*/
-export function h3MotionPlan(words: string, refs: { images: number; videos: number; audios: number }): H3MotionPlan | null {
+export function h3MotionPlan(words: string, refs: { images: number; videos: number; audios: number }): { picture: number } | null {
if (refs.images < 1 || refs.videos !== 1 || refs.audios > 0) return null;
const text = h3ReferenceTags(words.trim());
if (!text || IN_LAYOUT.test(text)) return null;
const sentences = text.split(/(?<=[.!?])\s+|\n+/);
if (!sentences.some((s) => (/<Video 1>/.test(s) || /\bthe (?:clip|video)\b/i.test(s)) && MOTION_WORD.test(s))) return null;
- const named = /\b(?:the|a|an)\s+(\w+)\s+(?:in|from|of)\s+<Picture (\d+)>/i.exec(text);
- const picture = named ? Number(named[2]) : Number(/<Picture (\d+)>/.exec(text)?.[1] ?? 1);
- if (picture < 1 || picture > refs.images) return null;
- const who = named && PERSON_WORD.test(named[1]) ? named[1].toLowerCase() : "person";
- const place: H3MotionPlace = CLIP_PLACE.test(text) ? "clip" : PICTURE_PLACE.test(text) ? "picture" : H3_MOTION_DEFAULT_PLACE;
- return { picture, who, place };
-}
-
-/** The person's words as the shot's action: the request verb goes, the pictured person becomes <Subject 1>, the clip's performer is named by role. */
-function motionAction(words: string, picture: number): string {
- let s = h3ReferenceTags(words.trim())
- .replace(/^(?:please\s+)?(?:create|make|generate|render|produce|show)\s+(?:me\s+)?(?:(?:a|an|the)\s+)?(?:(?:short\s+)?(?:video|clip|film|animation)\s+)?(?:(?:of|where|in which|showing)\s+)?/i, "")
- .replace(new RegExp(`\\b(?:the|a|an)\\s+\\w+\\s+(?:in|from|of)\\s+<Picture ${picture}>`, "gi"), "<Subject 1>")
- .replace(/\b(?:the|a|an)\s+\w+\s+(?:in|from|of)\s+<Video 1>/gi, "the performer of <Video 1>")
- .replace(/\s+/g, " ")
- .trim();
- if (!s) return "";
- s = s[0].toUpperCase() + s.slice(1);
- return /[.!?]$/.test(s) ? s : `${s}.`;
-}
-
-const PRONOUN: Record<string, [string, string]> = { woman: ["her", "her"], girl: ["her", "her"], lady: ["her", "her"], actress: ["her", "her"], man: ["him", "his"], boy: ["him", "his"], guy: ["him", "his"], actor: ["him", "his"] };
-
-/**
- * H3's full-reference layout for a motion copy: the person of the picture, with the complete outfit, performs the movement,
- * framing and timing of the clip in every frame through the last frame. Place "clip": the clip's setting and camera stay
- * and its performer becomes the pictured person. Place "picture": the clip supplies only motion and every surface comes from
- * the picture. The clip's own sound is reused unless a sound or music line is given. Other pictures stay further references.
- * Null when the words are not a motion copy (h3MotionPlan).
- */
-export function h3MotionPrompt(
- words: string,
- refs: { images: number; videos: number; audios: number },
- opts: { place?: H3MotionPlace; sound?: string; music?: string } = {},
-): string | null {
- const found = h3MotionPlan(words, refs);
- if (!found) return null;
- const place = opts.place ?? found.place;
- const P = `<Picture ${found.picture}>`;
- const V = "<Video 1>";
- const [them, their] = PRONOUN[found.who] ?? ["them", "their"];
- const inClip = place === "clip";
- const extra: string[] = [];
- for (let n = 1, k = 3; n <= refs.images; n++) if (n !== found.picture) extra.push(`<Subject ${k++}> is what <Picture ${n}> shows, used as the shot describes.`);
- const defs = [
- `<Subject 1> is the ${found.who} in ${P}, with ${their} complete outfit.`,
- `<Subject 2> is the setting of ${inClip ? V : P}.`,
- inClip
- ? `${V} is the source of the setting, camera, body movement, framing and timing. Its performer becomes <Subject 1>.`
- : `${V} is a motion guide at 24 fps. It supplies only the body poses, arm and leg movements, head direction, framing and timing; every visible surface comes from ${P}.`,
- ...extra,
- ];
- const summary = `[reference generation + audio reuse] The target video shows <Subject 1> in <Subject 2>, performing the movement of ${V} with its ${inClip ? "camera, framing" : "framing"} and timing, from the first frame to the last.`;
- const retention = [
- `<Subject 1> (appears in [Shot 1]): fully_preserved - the identity and complete outfit of ${P}.`,
- inClip ? `<Subject 2> (setting): fully_preserved - the place, light and camera of ${V}.` : `<Subject 2> (setting): fully_preserved - the place of ${P} fills the frame around <Subject 1> in every frame.`,
- inClip
- ? `${V} (setting, motion and timing): partially_preserved - its place, camera, movement and timing stay; its performer is <Subject 1>.`
- : `${V} (motion and timing): attribute_transfer - its movement is performed by <Subject 1>.`,
- ];
- const shot = inClip
- ? `[Shot 1] The performer of ${V} is <Subject 1> in every frame through the last frame, with the face, hair and complete outfit of ${P}. <Subject 1> performs every movement of ${V} at the same moment, full body in frame, with its camera and framing, in real time. One continuous take.`
- : `[Shot 1] <Subject 1> performs every movement of ${V} at the same moment, moving into each new pose with its timing, full body in frame, through the last frame. The setting of ${P} stays fully visible around ${them} in every frame. One continuous take.`;
- const action = motionAction(words, found.picture);
- return [
- `subject_definitions:\n${defs.join("\n")}`,
- `summary:\n${summary}`,
- `retention_analysis:\n${retention.join("\n")}`,
- `detailed_description:\nLive-action footage in the setting and light of ${inClip ? V : P}.\n${shot}${action ? ` ${action}` : ""}`,
- `overall_soundscape:\n${opts.sound?.trim() || `The sound of ${V}, reused unchanged.`}`,
- `non_diegetic_music:\n${opts.music?.trim() || `The music of ${V}, reused unchanged.`}`,
- ].join("\n\n");
+ const named = /\b(?:the|a|an)\s+\w+\s+(?:in|from|of)\s+<Picture (\d+)>/i.exec(text);
+ const picture = named ? Number(named[1]) : Number(/<Picture (\d+)>/.exec(text)?.[1] ?? 1);
+ return picture >= 1 && picture <= refs.images ? { picture } : null;
}
diff --git a/src/lib/motion-copy.ts b/src/lib/motion-copy.ts
new file mode 100644
index 00000000..6c74544f
--- /dev/null
+++ b/src/lib/motion-copy.ts
@@ -0,0 +1,35 @@
+import { MOTION_H3, OPENJUTSU_LIMITS } from "@/lib/catalog/genjutsu";
+import type { GenerationRequest } from "@/lib/catalog/types";
+import { h3MotionPlan } from "@/lib/h3-references";
+
+/** The video model whose reference runs can ask for a motion copy. */
+const H3_REFERENCES = "oss-minimax-h3";
+
+/**
+ * A Video studio run on MiniMax H3 with references that asks for the person in a picture to perform the movement of the clip
+ * ("the woman in image 1 dancing like the woman in clip 1") as Genjutsu's Motion transfer on H3: the picture is the look,
+ * the clip's surface normals the motion, the clip's sound kept. Reference-to-video copies a reference clip as footage, so
+ * this run goes to the tool made for it. The person's words stay the run's prompt; the graph writes its own words.
+ * `clipSeconds`: the clip's length, when known (the motion is taken from its start). Null for every other run.
+ */
+export function motionCopyRequest<T extends GenerationRequest>(req: T, clipSeconds?: number): T | null {
+ if (req.modelId !== H3_REFERENCES || req.op !== "ref2v" || req.engine === "cloud" || !req.prompt) return null;
+ const images = req.inputs?.images ?? [];
+ const videos = req.inputs?.videos ?? [];
+ const audios = req.inputs?.audios ?? [];
+ const plan = h3MotionPlan(req.prompt, { images: images.length, videos: videos.length, audios: audios.length });
+ if (!plan) return null;
+ const { minSeconds, maxSeconds } = OPENJUTSU_LIMITS;
+ const asked = Number(req.params?.duration) > 0 ? Number(req.params?.duration) : 5;
+ const room = clipSeconds && clipSeconds > 0 ? clipSeconds : maxSeconds;
+ const seconds = Math.round(Math.max(minSeconds, Math.min(asked, room, maxSeconds)) * 1000) / 1000;
+ const quality = /^(?:1080|768|720)p$/.test(String(req.params?.resolution ?? "720p")) ? "720p" : "480p";
+ const seed = typeof req.params?.seed === "number" ? { seed: req.params.seed } : {};
+ return {
+ ...req,
+ modelId: MOTION_H3,
+ op: "motion-transfer",
+ inputs: { video: videos[0], images: [images[plan.picture - 1]] },
+ params: { ...seed, resolution: quality, extra: { openjutsu: { seconds, quality, motion: 0, scene: "", ...seed } } },
+ };
+}
diff --git a/src/server/generations.ts b/src/server/generations.ts
index 09e4e902..c0d10bdf 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -40,7 +40,7 @@ import { computeDimensions } from "@/lib/comfy";
import { captionFromWords, captionWords, parseCaption } from "@/lib/ideogram-caption";
import { AUTO_IMAGE, AUTO_LARGE_MODELS, autoCandidates, autoModelsFor, autoNext, autoPatterns, autoResolution, nextDeclinedFallback } from "@/lib/auto-image";
import { h3Frames, h3Prompt, inH3Layout } from "@/lib/h3-prompt";
-import { h3MotionPrompt, h3ReferenceTags, h3TalkPrompt } from "@/lib/h3-references";
+import { h3ReferenceTags, h3TalkPrompt } from "@/lib/h3-references";
import {
CHAIN_LIST_SLACK,
LAST_FRAME_CHAIN,
@@ -3753,11 +3753,7 @@ async function handOver(id: string, route: ModelRoute, providerId: ProviderId, p
prompt = wrapped;
update(id, { prompt });
} else if (plan.model.options.promptFormat === "minimax-h3" && plan.op === "ref2v" && prompt) {
- // A person in a picture performing a clip's movement gets H3's full-reference layout, so each input has its role.
- const refs = { images: req.inputs?.images?.length ?? 0, videos: req.inputs?.videos?.length ?? 0, audios: req.inputs?.audios?.length ?? 0 };
- const wrapped =
- h3MotionPrompt(prompt, refs, { sound: plan.sound?.soundscape, music: plan.sound?.music }) ??
- h3Prompt(h3ReferenceTags(prompt), "t2v", h3Frames(plan.params.duration ?? plan.model.defaults?.duration ?? 5), plan.sound?.soundscape, plan.sound?.music);
+ const wrapped = h3Prompt(h3ReferenceTags(prompt), "t2v", h3Frames(plan.params.duration ?? plan.model.defaults?.duration ?? 5), plan.sound?.soundscape, plan.sound?.music);
if (wrapped !== prompt) {
prompt = wrapped;
update(id, { prompt });
diff --git a/tests/comfy-library-4.test.ts b/tests/comfy-library-4.test.ts
index d6f4c037..15c8f719 100644
--- a/tests/comfy-library-4.test.ts
+++ b/tests/comfy-library-4.test.ts
@@ -143,7 +143,6 @@ describe("round-4 ComfyUI workflows", () => {
// Genjutsu's Openjutsu modes not checked against ComfyUI yet; each opens only after its /prompt
// check and a real render (workflows/comfyui/gpu-tested.json, src/server/genjutsu-live.ts).
"image-from-picture-prepare",
- "video-motion-transfer-h3",
]);
for (const w of manifest.workflows) for (const o of w.outputs) if (o.role) expect(ROLES, `${w.id} ${o.role}`).toContain(o.role);
});
diff --git a/tests/comfy-openjutsu-modes.test.ts b/tests/comfy-openjutsu-modes.test.ts
index ea749952..9251c6c8 100644
--- a/tests/comfy-openjutsu-modes.test.ts
+++ b/tests/comfy-openjutsu-modes.test.ts
@@ -20,7 +20,7 @@ const entry = (id: string) => manifest.workflows.find((w) => w.id === id)!;
const graph = (id: string) => JSON.parse(fs.readFileSync(path.join(dir, `${id}.json`), "utf8")) as ComfyWorkflow;
const IDS = Object.values(OPENJUTSU_WORKFLOWS);
// Checked against a ComfyUI with the packs installed (validate-workflows.mjs).
-const CHECKED = new Set<string>(["video-group-swap-h3","video-scene-edit-h3","video-fix-faces-h3","video-fix-colours","video-scene-describe","video-from-picture-solar","video-from-picture-h3","video-group-swap-h3-one-by-one"]);
+const CHECKED = new Set<string>(["video-group-swap-h3","video-scene-edit-h3","video-fix-faces-h3","video-fix-colours","video-scene-describe","video-from-picture-solar","video-from-picture-h3","video-group-swap-h3-one-by-one","video-motion-transfer-h3"]);
const PINS: Record<string, [string, string]> = {
"ComfyUI-MiniMaxH3-Context-Loop": ["OJ_CONTEXT_LOOP_REF", "43afeffcc570beb5f7382593e79e4b211c7e02f6"],
diff --git a/tests/genjutsu-live.test.ts b/tests/genjutsu-live.test.ts
index 0b12e72c..0d69a45f 100644
--- a/tests/genjutsu-live.test.ts
+++ b/tests/genjutsu-live.test.ts
@@ -46,8 +46,8 @@ describe("Genjutsu's live gate", () => {
it("the committed record opens only the features that passed, and the page passes the gate to the studio", () => {
const record = JSON.parse(fs.readFileSync(path.join(ROOT, "workflows/comfyui/gpu-tested.json"), "utf8")) as { features: Record<string, { passed: boolean }> };
- expect(Object.keys(record.features).sort()).toEqual(["body-double-clip", "body-double-photo", "clean-voice-first", "finish-colours", "finish-faces", "group-swap", "group-swap-one-by-one", "original-sound", "picture-h3-renderer", "reshoot-edit", "reshoot-swap"]);
- expect(Object.entries(genjutsuLive()).filter(([, on]) => on).map(([k]) => k).sort()).toEqual(["finish-colours", "finish-faces", "group-swap", "group-swap-one-by-one", "picture-h3-renderer", "reshoot-edit", "reshoot-swap"]);
+ expect(Object.keys(record.features).sort()).toEqual(["body-double-clip", "body-double-photo", "clean-voice-first", "finish-colours", "finish-faces", "group-swap", "group-swap-one-by-one", "motion-h3", "original-sound", "picture-h3-renderer", "reshoot-edit", "reshoot-swap"]);
+ expect(Object.entries(genjutsuLive()).filter(([, on]) => on).map(([k]) => k).sort()).toEqual(["finish-colours", "finish-faces", "group-swap", "group-swap-one-by-one", "motion-h3", "picture-h3-renderer", "reshoot-edit", "reshoot-swap"]);
const page = fs.readFileSync(path.join(ROOT, "src/app/(studio)/genjutsu/page.tsx"), "utf8");
expect(page).toContain("const live = genjutsuLive();");
// The page's mode examples are only the ones open to everyone (the owner's come from an owner-only route).
diff --git a/tests/h3-motion-prompt.test.ts b/tests/h3-motion-prompt.test.ts
deleted file mode 100644
index b7a9974e..00000000
--- a/tests/h3-motion-prompt.test.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-import { describe, expect, it } from "vitest";
-import { h3MotionPlan, h3MotionPrompt, H3_MOTION_DEFAULT_PLACE } from "@/lib/h3-references";
-
-const ONE = { images: 1, videos: 1, audios: 0 };
-const ASK = "create a video of the woman in image 1 dancing like the woman in clip 1";
-const FIELDS = ["subject_definitions:", "summary:", "retention_analysis:", "detailed_description:", "overall_soundscape:", "non_diegetic_music:"];
-
-/** Every tag used is defined in subject_definitions, and every input has a tag there. */
-function tagsDefined(p: string, images: number) {
- const defs = p.slice(0, p.indexOf("summary:"));
- const used = new Set(p.match(/<(?:Subject|Picture|Video|Audio) \d+>/g));
- for (const t of used) expect(defs, `${t} defined`).toContain(t);
- for (let n = 1; n <= images; n++) expect(defs).toContain(`<Picture ${n}>`);
- expect(defs).toContain("<Video 1>");
-}
-
-describe("h3MotionPlan", () => {
- it("finds a motion copy in the studio's words", () => {
- expect(h3MotionPlan(ASK, ONE)).toEqual({ picture: 1, who: "woman", place: H3_MOTION_DEFAULT_PLACE });
- expect(h3MotionPlan("Make the man in image 2 do the same moves as clip 1", { images: 2, videos: 1, audios: 0 })).toMatchObject({ picture: 2, who: "man" });
- expect(h3MotionPlan("image 1 copies the choreography of the clip", ONE)).toMatchObject({ picture: 1, who: "person" });
- });
-
- it("reads the place from the words", () => {
- expect(h3MotionPlan("the woman in image 1 dances like clip 1, in the room of image 1", ONE)?.place).toBe("picture");
- expect(h3MotionPlan("the woman in image 1 dances like clip 1 in the same studio as clip 1", ONE)?.place).toBe("clip");
- });
-
- it("leaves other reference runs alone", () => {
- expect(h3MotionPlan("the woman in image 1 walks along the beach at sunset", ONE)).toBeNull();
- expect(h3MotionPlan(ASK, { images: 0, videos: 1, audios: 0 })).toBeNull();
- expect(h3MotionPlan(ASK, { images: 1, videos: 2, audios: 0 })).toBeNull();
- expect(h3MotionPlan(ASK, { images: 1, videos: 1, audios: 1 })).toBeNull();
- expect(h3MotionPlan(`integrated_multimodal_description: [Shot 1] ${ASK}`, ONE)).toBeNull();
- expect(h3MotionPlan(`subject_definitions:\n<Subject 1> is the woman in <Picture 1>.\n\nsummary: ${ASK}`, ONE)).toBeNull();
- expect(h3MotionPlan("the woman in image 3 dances like clip 1", ONE)).toBeNull();
- });
-});
-
-describe("h3MotionPrompt", () => {
- for (const place of ["clip", "picture"] as const) {
- it(`writes the full-reference layout (${place} setting)`, () => {
- const p = h3MotionPrompt(ASK, ONE, { place })!;
- const at = FIELDS.map((f) => p.indexOf(f));
- expect(at.every((i) => i >= 0)).toBe(true);
- expect([...at].sort((a, b) => a - b)).toEqual(at);
- expect(p).toContain("<Subject 1> is the woman in <Picture 1>, with her complete outfit.");
- expect(p).toContain("[reference generation + audio reuse]");
- expect(p).toContain("in every frame");
- expect(p).toContain("[Shot 1]");
- tagsDefined(p, 1);
- // What H3 reads names only what is wanted, at real-time pace, with the picture carrying the look.
- expect(p).not.toMatch(/\b(?:no|not|never|without|don't|avoid)\b/i);
- expect(p).not.toMatch(/\b(?:slowly|slow motion|gently|languid|leisurely)\b/i);
- expect(p).not.toMatch(/\b(?:skin|make-up|makeup|glow\w*|shimmer\w*)\b/i);
- expect(p).not.toMatch(/\bcreate a video\b/i);
- // The clip's performer is named by role, never as a second woman to keep.
- expect(p).not.toMatch(/the woman in <Video 1>/);
- });
- }
-
- it("keeps the clip's setting and camera, with its performer replaced", () => {
- const p = h3MotionPrompt(ASK, ONE, { place: "clip" })!;
- expect(p).toContain("<Subject 2> is the setting of <Video 1>.");
- expect(p).toContain("The performer of <Video 1> is <Subject 1> in every frame through the last frame");
- });
-
- it("uses the clip for motion only when the picture's setting is asked for", () => {
- const p = h3MotionPrompt(ASK, ONE, { place: "picture" })!;
- expect(p).toContain("<Subject 2> is the setting of <Picture 1>.");
- expect(p).toContain("attribute_transfer");
- expect(p).toContain("every visible surface comes from <Picture 1>");
- });
-
- it("defines further pictures and takes a preset's sound lines", () => {
- const p = h3MotionPrompt("the woman in image 1 dances like clip 1, wearing the gown of image 2", { images: 2, videos: 1, audios: 0 }, { sound: "Heels on a wooden floor.", music: "N/A" })!;
- expect(p).toContain("<Subject 3> is what <Picture 2> shows");
- tagsDefined(p, 2);
- expect(p).toContain("overall_soundscape:\nHeels on a wooden floor.");
- expect(p).toContain("non_diegetic_music:\nN/A");
- });
-
- it("returns null when the words are not a motion copy", () => {
- expect(h3MotionPrompt("the woman in image 1 walks into the scene of clip 1", ONE)).toBeNull();
- });
-});
diff --git a/tests/motion-copy.test.ts b/tests/motion-copy.test.ts
new file mode 100644
index 00000000..37809eb3
--- /dev/null
+++ b/tests/motion-copy.test.ts
@@ -0,0 +1,79 @@
+import { describe, expect, it } from "vitest";
+import { MOTION_H3, OPENJUTSU_LIMITS } from "@/lib/catalog/genjutsu";
+import { getModel } from "@/lib/catalog";
+import type { GenerationRequest } from "@/lib/catalog/types";
+import { h3MotionPlan } from "@/lib/h3-references";
+import { motionCopyRequest } from "@/lib/motion-copy";
+
+const ONE = { images: 1, videos: 1, audios: 0 };
+const ASK = "create a video of the woman in image 1 dancing like the woman in clip 1";
+const IMG = "/api/files/uploads/2026-11-11/pic.png";
+const CLIP = "/api/files/uploads/2026-11-11/clip.mp4";
+
+const videoRun = (over: Partial<GenerationRequest> = {}): GenerationRequest => ({
+ feature: "video",
+ modelId: "oss-minimax-h3",
+ op: "ref2v",
+ prompt: ASK,
+ inputs: { images: [IMG], videos: [CLIP] },
+ params: { aspectRatio: "auto", resolution: "768p", duration: 5 },
+ engine: "open",
+ ...over,
+});
+
+describe("h3MotionPlan", () => {
+ it("finds a picture's person asked to move like the clip", () => {
+ expect(h3MotionPlan(ASK, ONE)).toEqual({ picture: 1 });
+ expect(h3MotionPlan("Make the man in image 2 do the same moves as clip 1", { images: 2, videos: 1, audios: 0 })).toEqual({ picture: 2 });
+ expect(h3MotionPlan("image 1 copies the choreography of the clip", ONE)).toEqual({ picture: 1 });
+ });
+
+ it("leaves other reference runs alone", () => {
+ expect(h3MotionPlan("the woman in image 1 walks along the beach at sunset", ONE)).toBeNull();
+ expect(h3MotionPlan("the woman in image 1 walks into the scene of clip 1", ONE)).toBeNull();
+ expect(h3MotionPlan(ASK, { images: 0, videos: 1, audios: 0 })).toBeNull();
+ expect(h3MotionPlan(ASK, { images: 1, videos: 2, audios: 0 })).toBeNull();
+ expect(h3MotionPlan(ASK, { images: 1, videos: 1, audios: 1 })).toBeNull();
+ expect(h3MotionPlan(`integrated_multimodal_description: [Shot 1] ${ASK}`, ONE)).toBeNull();
+ expect(h3MotionPlan("the woman in image 3 dances like clip 1", ONE)).toBeNull();
+ });
+});
+
+describe("motionCopyRequest", () => {
+ it("sends the run to Motion transfer on H3 with the picture and the clip", () => {
+ const out = motionCopyRequest(videoRun({ account: "acc1", place: "pool" } as Partial<GenerationRequest>), 12.3)!;
+ expect(out.modelId).toBe(MOTION_H3);
+ expect(out.op).toBe("motion-transfer");
+ expect(getModel(MOTION_H3)!.routes.some((r) => r.op === "motion-transfer" && r.provider === "comfyui")).toBe(true);
+ expect(out.inputs).toEqual({ video: CLIP, images: [IMG] });
+ expect(out.params).toEqual({ resolution: "720p", extra: { openjutsu: { seconds: 5, quality: "720p", motion: 0, scene: "" } } });
+ // The person's words and the run's place and account stay as they were.
+ expect(out.prompt).toBe(ASK);
+ expect(out.feature).toBe("video");
+ expect((out as GenerationRequest & { account?: string; place?: string }).account).toBe("acc1");
+ expect((out as GenerationRequest & { place?: string }).place).toBe("pool");
+ });
+
+ it("takes the picture the words name, and the run's seed", () => {
+ const out = motionCopyRequest(videoRun({ prompt: "the man in image 2 dances like clip 1", inputs: { images: ["/a.png", "/b.png"], videos: [CLIP] }, params: { resolution: "480p", duration: 5, seed: 42 } }))!;
+ expect(out.inputs?.images).toEqual(["/b.png"]);
+ expect(out.params).toEqual({ seed: 42, resolution: "480p", extra: { openjutsu: { seconds: 5, quality: "480p", motion: 0, scene: "", seed: 42 } } });
+ });
+
+ it("fits the length inside the clip and Motion transfer's limits", () => {
+ const secs = (duration: number, clip?: number) => (motionCopyRequest(videoRun({ params: { resolution: "768p", duration } }), clip)!.params!.extra!.openjutsu as { seconds: number }).seconds;
+ expect(secs(10, 4.2)).toBe(4.2);
+ expect(secs(10)).toBe(10);
+ expect(secs(30)).toBe(OPENJUTSU_LIMITS.maxSeconds);
+ expect(secs(1, 12)).toBe(OPENJUTSU_LIMITS.minSeconds);
+ });
+
+ it("leaves every other run as it is", () => {
+ expect(motionCopyRequest(videoRun({ prompt: "the woman in image 1 walks along the beach" }))).toBeNull();
+ expect(motionCopyRequest(videoRun({ op: "i2v" }))).toBeNull();
+ expect(motionCopyRequest(videoRun({ modelId: "minimax-h3" }))).toBeNull();
+ expect(motionCopyRequest(videoRun({ engine: "cloud" }))).toBeNull();
+ expect(motionCopyRequest(videoRun({ prompt: "" }))).toBeNull();
+ expect(motionCopyRequest(videoRun({ inputs: { images: [IMG], videos: [CLIP], audios: ["/v.wav"] } }))).toBeNull();
+ });
+});
diff --git a/workflows/comfyui/gpu-tested.json b/workflows/comfyui/gpu-tested.json
index 797cd797..1f9cce91 100644
--- a/workflows/comfyui/gpu-tested.json
+++ b/workflows/comfyui/gpu-tested.json
@@ -10,6 +10,7 @@
"body-double-clip": { "passed": true, "date": "2026-11-08" },
"finish-faces": { "passed": true, "date": "2026-11-09" },
"reshoot-edit": { "passed": true, "date": "2026-11-08" },
- "reshoot-swap": { "passed": true, "date": "2026-11-08" }
+ "reshoot-swap": { "passed": true, "date": "2026-11-08" },
+ "motion-h3": { "passed": true, "date": "2026-11-11" }
}
}
diff --git a/workflows/comfyui/manifest.json b/workflows/comfyui/manifest.json
index 377f8ef3..0a4f48b7 100644
--- a/workflows/comfyui/manifest.json
+++ b/workflows/comfyui/manifest.json
@@ -29219,7 +29219,7 @@
],
"vramGb": 24,
"license": "MiniMax H3 Community License (H3 Ref2VA, its VAEs, the packaged Qwen3-VL text encoder, the DMAD LoRA derived from it): territory EXCLUDES the US, the EU, the UK and South Korea; commercial use above US$20M yearly revenue needs MiniMax's written authorization; show \"MiniMax H3\" on the product's interface; no outputs used to improve other AI models · Qwen3-VL 8B describer Apache-2.0 · SAM 3.1 under Meta's SAM License · graphs from D3voz/openjutsu (MIT) · Context Loop nodes GPL-3.0, Fantastic PromptBuilder MIT, H3 OneClick Swap MIT · Metric3D BSD-2-Clause",
- "validated": false,
+ "validated": true,
"notes": "Genjutsu Motion transfer's \"MiniMax H3\" model (oss-h3-motion): video-from-picture-h3 with the character photo itself as Picture 1 (no prepared first frame) and words that put the character in the photo's setting. video = the part fitted at 24 fps, image = the character photo. params.extra.openjutsu: seconds, quality 480p | 720p, motion 0 | 512 | 768, seed (the same settings as From picture's video).",
"autoDownloads": [
"Metric3D vit-small (metric_depth_vit_small_800k.pth) -> custom_nodes/comfyui_controlnet_aux/ckpts/JUGGHM/Metric3D (fetched on first run unless placed there)"