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
Video tools: MiniMax H3 fits each studio's shape, length and memory
Adarshda0f8042e3a4
diff --git a/src/components/ads/multiplier.tsx b/src/components/ads/multiplier.tsxindex 4de8bc25..070d927b 100644--- a/src/components/ads/multiplier.tsx+++ b/src/components/ads/multiplier.tsx@@ -12,7 +12,8 @@ import { areaCls } from "@/components/brand/fields";import { uploadImages } from "@/components/brand/image-list";import { fileToSlot, LibraryGrid, type SlotValue } from "@/components/studio/media-slot";import { VideoTrimmer } from "@/components/studio/video-trimmer";-import { initialClip, mentionedImages, MULTIPLIER, MULTIPLIER_MODELS, multiplierResolution, type ClipRange as Range, type MarketingRun, type RunEstimate } from "@/lib/catalog/marketing";+import { getModel } from "@/lib/catalog";+import { initialClip, mentionedImages, MULTIPLIER, MULTIPLIER_MODELS, multiplierResolution, UGC_MODELS, type ClipRange as Range, type MarketingRun, type RunEstimate } from "@/lib/catalog/marketing";import { formatCost } from "@/lib/format";import { probeBlob, probeUrl } from "@/lib/media-probe";import { useAskBeforeUpload, useModelAccess } from "@/lib/api";@@ -499,7 +500,7 @@ export function AdMultiplier({ models }: { models: Record<string, ModelInfo> })/></div><p className="flex flex-wrap items-center justify-center gap-1.5 pt-6 text-center text-[12px] text-muted-foreground">- <Sparkles className="size-3" /> {engineMode === "open" ? "" : "Cloud: Kling O3 edit, Happy Horse edit, Gemini Omni Flash · "}Open source: Fuobe Genjutsu (Wan Animate), Wan 2.2 clips joined around your ad+ <Sparkles className="size-3" /> {engineMode === "open" ? "" : "Cloud: Kling O3 edit, Happy Horse edit, Gemini Omni Flash · "}Open source: Fuobe Genjutsu (Wan Animate), {getModel(UGC_MODELS.open.clip)?.name} clips joined around your ad</p></div></div>diff --git a/src/components/marketing/click-to-ad.tsx b/src/components/marketing/click-to-ad.tsxindex 287ce705..85ef1d51 100644--- a/src/components/marketing/click-to-ad.tsx+++ b/src/components/marketing/click-to-ad.tsx@@ -14,7 +14,8 @@ import { AddFromLink, priceText, ProductThumb, UploadProductButton } from "@/comimport { SelfHostNote } from "@/components/self-host-note";import type { SlotValue } from "@/components/studio/media-slot";import { uploadFile, useLikelyVisitor } from "@/lib/api";-import { AD_STYLES, END_CARD, KIT_LABELS, type BrandKit, type MarketingRun, type Product, type RunEstimate } from "@/lib/catalog/marketing";+import { getModel } from "@/lib/catalog";+import { AD_STYLES, END_CARD, KIT_LABELS, UGC_MODELS, type BrandKit, type MarketingRun, type Product, type RunEstimate } from "@/lib/catalog/marketing";import { formatCost } from "@/lib/format";import { cn } from "@/lib/utils";import { toastError } from "@/lib/refusals";@@ -460,7 +461,7 @@ export function ClickToAd({ models }: { models: Record<string, ModelInfo> }) {/></div><p className="flex items-center justify-center gap-1.5 pt-4 text-[12px] text-muted-foreground">- <Sparkles className="size-3" /> {engineMode === "open" ? "" : "Cloud: Seedance 2.5 shots or an OmniHuman presenter, ElevenLabs voice, Auto Subtitle · "}Open source: Wan 2.2, InfiniteTalk, Chatterbox (your voice sample), caption burn-in+ <Sparkles className="size-3" /> {engineMode === "open" ? "" : "Cloud: Seedance 2.5 shots or an OmniHuman presenter, ElevenLabs voice, Auto Subtitle · "}Open source: {getModel(UGC_MODELS.open.clip)?.name}, InfiniteTalk, Chatterbox (your voice sample), caption burn-in</p></div></div>diff --git a/src/lib/catalog/cinema.ts b/src/lib/catalog/cinema.tsindex 8e6743cd..173c5b57 100644--- a/src/lib/catalog/cinema.ts+++ b/src/lib/catalog/cinema.ts@@ -602,7 +602,7 @@ export const CAST_SHEET_MODEL = "oss-zimage-soul-cast";*/export const CINEMA_MODELS: Record<CinemaMode, Record<Engine, string[]>> = {video: {- cloud: [CINEMA_MODEL, "minimax-h3", "seedance-2-5", "kling-3", "veo-3-1", "minimax-h3-max", "wan-3"],+ cloud: [CINEMA_MODEL, "minimax-h3", "seedance-2-5", "kling-3", "veo-3-1", "minimax-h3-max"],open: [CINEMA_MODEL, "oss-minimax-h3", "oss-ltx25", "oss-wan22-14b"],},image: { cloud: [CINEMA_STILL_MODEL, "nano-banana-pro", "seedream-5-pro"], open: [CINEMA_STILL_MODEL, "oss-ideogram-4", "oss-qwen-image-21", "oss-krea2-realism", "oss-moss-image"] },@@ -1294,6 +1294,27 @@ function nearest<T extends number>(values: T[], want: number): T {/** Cinema's image tiers on a model whose tiers are 720p / 1080p (Fuobe Soul: about 1 and 2 megapixels). */const IMAGE_TIER: Record<string, string> = { "1K": "720p", "2K": "1080p", "4K": "1080p" };+/** A video tier's height in pixels: "720p" and "768P" name theirs, "2K" and "4K" are 1440 and 2160. */+function tierHeight(label: string): number | undefined {+ const p = /^(\d{3,4})p$/i.exec(label);+ if (p) return Number(p[1]);+ return ({ "2k": 1440, "4k": 2160 } as Record<string, number>)[label.toLowerCase()];+}++/**+ * The model's video tier for a Cinema tier: the same one in any case ("1080p" is "1080P"), else the nearest in height,+ * the higher one on a tie. On MiniMax H3, 720p and 1080p are both its 768P (its 2K is further from 1080p).+ */+function videoTier(options: string[], want: string): string | undefined {+ const h = tierHeight(want);+ if (h === undefined) return undefined;+ const sized = options.flatMap((o) => {+ const oh = tierHeight(o);+ return oh === undefined ? [] : [{ o, d: Math.abs(oh - h), oh }];+ });+ return sized.sort((a, b) => a.d - b.d || b.oh - a.oh)[0]?.o;+}+/** Fit ratio, resolution, duration and batch to what the model takes, saying what changed. */function fitParams(model: ModelDef, input: CinemaGenerateInput, notes: string[], kind: CinemaMode): GenParams {const o = model.options;@@ -1309,6 +1330,12 @@ function fitParams(model: ModelDef, input: CinemaGenerateInput, notes: string[],else if (IMAGE_TIER[res] && o.resolutions.includes(IMAGE_TIER[res])) {params.resolution = IMAGE_TIER[res];if (res === "4K") notes.push(`${model.name} makes up to about 2 megapixels (its ${params.resolution} size)`);+ } else if (kind === "video" && videoTier(o.resolutions, res)) {+ const tier = videoTier(o.resolutions, res)!;+ params.resolution = tier;+ if (tier.toLowerCase() !== res.toLowerCase()) {+ notes.push(tierHeight(tier)! < tierHeight(res)! ? `${model.name} renders up to ${tier} here` : `${model.name} renders at ${tier} here`);+ }} else {const order = kind === "video" ? VIDEO_RESOLUTIONS : [...IMAGE_RESOLUTIONS, "0.5K", "1.5K", "720p", "1080p"];const below = o.resolutions.filter((r) => order.indexOf(r) <= order.indexOf(res) && order.indexOf(r) >= 0);diff --git a/src/lib/catalog/clip-lengths.ts b/src/lib/catalog/clip-lengths.tsindex fc6d4f91..e916a40d 100644--- a/src/lib/catalog/clip-lengths.ts+++ b/src/lib/catalog/clip-lengths.ts@@ -3,14 +3,34 @@ import type { ModelDef } from "./types";/*** Clip lengths a studio plans with, per model, where the catalog also lists a shorter clip than the model is trained* for. MiniMax H3 on your GPU is trained on 5–15 s clips (124–362 frames at 24 fps); its 3 s clip serves the presets- * made at that length. A studio that picks the length itself (Faceless and the Explainer, Storyboard films, Marketing,- * Cinema) asks it for 5, 10 or 15 s.+ * made at that length. A studio that picks one of a few lengths itself (Storyboard films, Click to Ad, Cinema) asks it+ * for 5, 10 or 15 s.*/export const PLANNED_DURATIONS: Readonly<Record<string, readonly number[]>> = { "oss-minimax-h3": [5, 10, 15] };+/**+ * Models that render any whole number of seconds in a range, where a studio fits the clip to a length of its own+ * (a Faceless scene cut to its lines, a Marketing motion ad of the length asked for). MiniMax H3 on your GPU renders+ * any length on its 17n + 5 frame grid: 3 s up to the 15 s it is trained for.+ */+export const LENGTH_RANGES: Readonly<Record<string, readonly [number, number]>> = { "oss-minimax-h3": [3, 15] };+/** The clip lengths a studio plans with on a model: PLANNED_DURATIONS, else the catalog's own. */export function plannedDurations(model: Pick<ModelDef, "id" | "options"> | undefined): number[] | undefined {if (!model) return undefined;const planned = PLANNED_DURATIONS[model.id];return planned ? [...planned] : model.options.durations;}++/** The range of whole seconds a model renders, when it takes any length in one (LENGTH_RANGES). */+export function lengthRange(model: Pick<ModelDef, "id"> | undefined): [number, number] | undefined {+ const r = model ? LENGTH_RANGES[model.id] : undefined;+ return r ? [r[0], r[1]] : undefined;+}++/**+ * Video models whose clips share one canvas and frame rate when their start frames share one shape: MiniMax H3 on your+ * GPU makes each clip in its still's shape at 24 fps. A studio joins them with the copy join (oss-join-encoded), which+ * never decodes them, so a long film takes no more memory than a short one. The copy keeps each clip's own sound.+ */+export const COPY_JOIN_VIDEOS: ReadonlySet<string> = new Set(["oss-minimax-h3"]);diff --git a/src/lib/catalog/faceless.ts b/src/lib/catalog/faceless.tsindex 4c95c37f..aa582fbd 100644--- a/src/lib/catalog/faceless.ts+++ b/src/lib/catalog/faceless.ts@@ -1,5 +1,5 @@import { describeMove, KEN_BURNS_FPS, sceneMoves } from "@/lib/av/ken-burns";-import { plannedDurations } from "./clip-lengths";+import { COPY_JOIN_VIDEOS, lengthRange, plannedDurations } from "./clip-lengths";import { estimateCost } from "./plan";import { pricingAt } from "./promo";import type { ChainSlot, Engine, Generation, GenerationRequest, ModelDef } from "./types";@@ -204,7 +204,7 @@ export const STYLES: VisualStyle[] = [style("Pastel Flat 2D","Soft pastel colours and simple flat illustrations",- "soft pastel flat 2D illustration: simple rounded shapes without outlines, gentle gradients, calm friendly characters, lots of breathing room",+ "soft pastel flat 2D illustration: simple rounded shapes in flat fills of colour, edges defined by colour alone, gentle gradients, calm friendly characters, lots of breathing room","soft eased motion, elements float gently, calm pacing",330,),@@ -612,7 +612,7 @@ export interface EngineModels {join: string;/** Joins at most this many clips at once (longer films are folded). */joinMax: number;- /** Frame by frame's join (open: packet copy of the Ken Burns clips, flat memory) and its fold size. */+ /** The join of clips on one canvas (Frame by frame, MiniMax H3 on your GPU; open: packet copy, flat memory) and its fold size. */framesJoin: string;framesJoinMax: number;/** Puts the voice on the film (no music). */@@ -691,8 +691,8 @@ export const ENGINE_MODELS: Record<Engine, EngineModels> = {/*** Clip lengths each block video model can make. Gemini Omni Flash takes any whole number of seconds* from 3 to 10 (research: duration 3–10), hosted MiniMax H3 any from 5 to 15 (fal's schema); the Ken Burns- * moves 1–30 s (fal) and 1–10 s per job (ComfyUI, longer scenes split); the others list their durations in the- * catalog, MiniMax H3 on your GPU the 5, 10 and 15 s it is trained for (plannedDurations).+ * moves 1–30 s (fal) and 1–10 s per job (ComfyUI, longer scenes split); MiniMax H3 on your GPU any from 3 to 15+ * (lengthRange), so each scene is cut to where its lines are spoken; the others list their durations in the catalog.*/export const DURATION_RANGES: Record<string, [number, number]> = { "gemini-omni-flash": [3, 10], "minimax-h3": [5, 15], "ken-burns": [1, 30], "oss-ken-burns": [1, 10] };@@ -760,10 +760,10 @@ export function shotsFor(seconds: number, durations: number[] | undefined, rangereturn best ?? Array.from({ length: n }, () => max);}-/** The block video model's shots for a block (MiniMax H3 on your GPU: 5, 10 or 15 s each). */+/** The block video model's shots for a block (MiniMax H3 on your GPU: any 3 to 15 s each). */export function blockShots(seconds: number, model: ModelDef | undefined): number[] {if (!model) return [Math.round(seconds)];- return shotsFor(seconds, plannedDurations(model), DURATION_RANGES[model.id]);+ return shotsFor(seconds, plannedDurations(model), DURATION_RANGES[model.id] ?? lengthRange(model));}// ---------------------------------------------------------------------------@@ -858,6 +858,9 @@ export function resolveModels(settings: EpisodeSettings, narrationChars: number,const narration = settings.engine === "open" ? m.narration : sample ? m.cloneNarration : narrationChars > m.narrationMaxChars ? m.longNarration : m.narration;// Style references win; attached source images otherwise go to a model that reads them.const fromSources = !settings.styleRefs.length && !!settings.sourceImages?.length && !!m.sourceStill;+ // Clips that share one canvas and frame rate are joined packet by packet, in flat memory however long the film: the+ // Ken Burns moves, and MiniMax H3 on your GPU from stills drawn in the episode's shape (an edit keeps its source's).+ const copyJoin = frames || (COPY_JOIN_VIDEOS.has(video) && !fromSources);return {still: settings.styleRefs.length ? m.styleStill : fromSources ? m.sourceStill! : m.still,...(fromSources && { stillOp: "edit" as const }),@@ -868,8 +871,8 @@ export function resolveModels(settings: EpisodeSettings, narrationChars: number,loop: settings.music ? m.loop : null,level: settings.music ? (m.levelMusic ?? null) : null,mux: settings.music ? m.mixMusic : m.mux,- join: frames ? m.framesJoin : m.join,- joinMax: frames ? m.framesJoinMax : m.joinMax,+ join: copyJoin ? m.framesJoin : m.join,+ joinMax: copyJoin ? m.framesJoinMax : m.joinMax,captions: settings.subtitles ? m.captions : null,align: m.align,captionsUseWords: m.captionsUseWords,diff --git a/src/lib/catalog/marketing.ts b/src/lib/catalog/marketing.tsindex e2478ba6..429b338e 100644--- a/src/lib/catalog/marketing.ts+++ b/src/lib/catalog/marketing.ts@@ -969,7 +969,7 @@ export function formatModels(format: FormatDef, engine: Engine, has: { product:switch (format.pipeline) {case "motion":return [- { id: "oss-minimax-h3", note: "MiniMax H3, 5–15 s clips with sound" },+ { id: "oss-minimax-h3", note: "One 5–15 s clip with sound" },{ id: "oss-wan22-14b-fast", note: "Wan 2.2 14B, shot by shot" },];case "ugc":@@ -989,7 +989,7 @@ export function formatModels(format: FormatDef, engine: Engine, has: { product:case "poster":return has.product? [original, { id: "gpt-image-2-5", note: "Draws the exact text" }, { id: "nano-banana-pro" }, { id: "ideogram-4-5" }]- : [original, { id: "ideogram-4-5", note: "Exact text in your brand colours" }, { id: "recraft-4-1" }, { id: "gpt-image-2-5" }];+ : [original, { id: "ideogram-4-5", note: "Draws the exact text" }, { id: "recraft-4-1" }, { id: "gpt-image-2-5" }];case "ugc-talking":case "tiktok":return [{ id: "omnihuman-2", note: "Full-body presenter" }, { id: "kling-avatar-2" }];diff --git a/src/server/assist/studio-tools.ts b/src/server/assist/studio-tools.tsindex 447bf754..6f5f4f1d 100644--- a/src/server/assist/studio-tools.ts+++ b/src/server/assist/studio-tools.ts@@ -322,7 +322,8 @@ function facelessSteps(i: FacelessToolInput, ctx: ToolContext, voiceFor: VoiceFoconst aspect = ["9:16", "16:9", "1:1"].includes(i.aspect_ratio ?? "") ? i.aspect_ratio! : "9:16";const stillModel = open ? "oss-qwen-image-21" : "nano-banana-pro";// Higgsfield's Faceless runs Gemini Omni Flash per block (16:9 / 9:16 only); square goes to Seedance. On your GPU,- // MiniMax H3 makes 5 s clips; its own sound is left out by the join, and the narration goes on in its place.+ // MiniMax H3 makes 5 s clips from stills of one shape; the copy join puts them together without decoding them, and+ // the mux lays the narration in place of their own sound.const clipModel = open ? "oss-minimax-h3" : aspect === "1:1" ? "seedance-2-5" : "gemini-omni-flash";const steps: (PipelineStep & { label: string })[] = [];scenes.forEach((s, k) => {@@ -337,23 +338,11 @@ function facelessSteps(i: FacelessToolInput, ctx: ToolContext, voiceFor: VoiceFo},);});- // Joins: the open join takes up to 4 clips a step, so longer episodes join in groups first.- const join = open ? "oss-join-clips" : "join-clips";+ // One join of every scene (8 at most): the copy join on your GPU, the cloud's join otherwise.+ const join = open ? "oss-join-encoded" : "join-clips";const clips = scenes.map((_, k) => `clip${k}`);- let film: string;- if (clips.length <= (open ? 4 : 24)) {- steps.push({ key: "film", label: "Joined scenes", request: req({ modelId: join, op: "concat", prompt: i.title?.trim() || "Episode" }), after: clips, chain: clips.map(() => ({ slot: "videos" as const })) });- film = "film";- } else {- const groups: string[] = [];- for (let g = 0; g * 4 < clips.length; g++) {- const part = clips.slice(g * 4, g * 4 + 4);- steps.push({ key: `part${g}`, label: `Scenes ${g * 4 + 1}–${g * 4 + part.length} joined`, request: req({ modelId: join, op: "concat", prompt: i.title?.trim() || "Episode" }), after: part, chain: part.map(() => ({ slot: "videos" as const })) });- groups.push(`part${g}`);- }- steps.push({ key: "film", label: "Joined scenes", request: req({ modelId: join, op: "concat", prompt: i.title?.trim() || "Episode" }), after: groups, chain: groups.map(() => ({ slot: "videos" as const })) });- film = "film";- }+ steps.push({ key: "film", label: "Joined scenes", request: req({ modelId: join, op: "concat", prompt: i.title?.trim() || "Episode" }), after: clips, chain: clips.map(() => ({ slot: "videos" as const })) });+ const film = "film";const narrator = narratorVoice(i, ctx, voiceFor);const narration = scenes.map((s) => s.narration.trim()).filter(Boolean).join("\n\n");steps.push(diff --git a/src/server/chains.ts b/src/server/chains.tsindex 6304dfb8..a3e3bc13 100644--- a/src/server/chains.ts+++ b/src/server/chains.ts@@ -91,14 +91,19 @@ export interface JoinOptions {step?: GenerationRequest["step"];/** A recipe's free dry run (GenerationRequest.demo): the join runs on the demo provider too. */demo?: boolean;+ /**+ * The clips share one canvas and frame rate (COPY_JOIN_VIDEOS from stills of one shape): on your GPU they are joined+ * packet by packet (oss-join-encoded, up to 24 at once), each with its own sound, in flat memory.+ */+ copy?: boolean;}-const joinModelId = (engine: Engine) => (engine === "open" ? "oss-join-clips" : "join-clips");+const joinModelId = (engine: Engine, copy = false) => (engine === "open" ? (copy ? "oss-join-encoded" : "oss-join-clips") : "join-clips");/** Join generations' clips, in order. ComfyUI joins 4 at a time, so longer films are joined in steps. */export function joinClips(ids: string[], o: JoinOptions): Generation {- const modelId = joinModelId(o.engine);- const max = o.engine === "open" ? 4 : 24;+ const modelId = joinModelId(o.engine, o.copy);+ const max = o.engine === "open" && !o.copy ? 4 : 24;// The clips run for real: the join must too (S9). Clips still waiting are canceled rather than paid for.const real = ids.some((id) => {const g = getGeneration(id);@@ -535,7 +540,8 @@ export function createMosaicRun(original: GenerationRequest, model: ModelDef, op/*** The model a storyboard film is animated with: MiniMax H3 on your GPU (5 s shots, its default), Seedance 2.5 in the- * cloud. A clip's own sound stays out of the film: the open join (video-concat-{n}) keeps the picture only.+ * cloud. MiniMax H3's shots, made from frames of one shape, are joined packet by packet (copy join), each shot with its+ * own sound; other open shots go through the decode join (video-concat-{n}), which keeps the picture only.*/export function filmModel(engine: Engine, modelId?: string): ModelDef {const m = getModel(modelId ?? (engine === "open" ? "oss-minimax-h3" : "seedance-2-5"));diff --git a/src/server/marketing.ts b/src/server/marketing.tsindex 5a1a5f30..c457930f 100644--- a/src/server/marketing.ts+++ b/src/server/marketing.ts@@ -2,7 +2,7 @@ import "server-only";import { nanoid } from "nanoid";import { z } from "zod";import { getModel, supportsOp } from "@/lib/catalog";-import { plannedDurations } from "@/lib/catalog/clip-lengths";+import { lengthRange, plannedDurations } from "@/lib/catalog/clip-lengths";import {AD_STYLES,brandLine,@@ -58,7 +58,9 @@ import { isOffered } from "./model-access";import { keepOffered } from "@/lib/model-access";import { engineMode } from "./settings";import { encodePng } from "./png";-import { saveFile, storedMedia } from "./storage";+import { localHead, saveFile, storedMedia } from "./storage";+import { imageSize } from "@/lib/image-size";+import { isH3Graph } from "@/lib/h3-prompt";/*** Marketing Studio (templates → product shots, posters, ads, product motion, UGC presenters),@@ -172,6 +174,55 @@ const need = (model: string): ModelDef => {return m;};+/** Qwen-Image 2.1's expand graph on your GPU: it grows a photo to the ad's shape before a clip starts on it. */+export const FIT_PHOTO_MODEL = "oss-qwen-image-21";+const FIT_PHOTO_PROMPT = "Continue the scene naturally beyond every edge with matching perspective, lighting, textures and grain.";++/** A clip model that makes its clip in the start frame's own shape: MiniMax H3 on your GPU (its i2v graph runs at "auto"). */+const keepsFrameShape = (clip: ModelDef) => clip.engine === "open" && clip.routes.some((r) => r.op === "i2v" && isH3Graph(r.endpoint));++/** Margins (multiples of 8 px) that grow a width × height picture to the aspect ratio; null when it's already that shape. */+export function padsTo(size: { width: number; height: number }, aspect: string): { padLeft: number; padTop: number; padRight: number; padBottom: number } | null {+ const [a, b] = aspect.split(":").map(Number);+ if (!(a > 0 && b > 0)) return null;+ const want = a / b;+ const have = size.width / size.height;+ if (Math.abs(have - want) / want < 0.02) return null;+ const side = (total: number) => Math.round(total / 2 / 8) * 8;+ if (have < want) {+ const x = side(size.height * want - size.width);+ return x > 0 ? { padLeft: x, padTop: 0, padRight: x, padBottom: 0 } : null;+ }+ const y = side(size.width / want - size.height);+ return y > 0 ? { padLeft: 0, padTop: y, padRight: 0, padBottom: y } : null;+}++/**+ * The start frame of a clip made from a photo. MiniMax H3 on your GPU keeps its start frame's shape, so a photo of+ * another shape (a square product photo in a 9:16 ad) is first grown to the ad's shape on Qwen-Image 2.1 (a step+ * added to `steps`, once per photo), and the clip starts on that picture. Any other clip model, a photo already in+ * shape, or one whose size can't be read starts on the photo itself.+ */+function startFrame(steps: Step[], photo: string, aspect: string | undefined, clip: ModelDef, feature: string): Pick<GenerationRequest, "inputs" | "chain"> & { after?: string[] } {+ const own = { inputs: { images: [photo] } };+ if (!aspect || !keepsFrameShape(clip) || !getModel(FIT_PHOTO_MODEL)) return own;+ const head = localHead(photo);+ const size = head ? imageSize(head) : null;+ const pads = size ? padsTo(size, aspect) : null;+ if (!pads) return own;+ let fit = steps.find((s) => s.request.modelId === FIT_PHOTO_MODEL && s.request.op === "outpaint" && s.request.inputs?.images?.[0] === photo);+ if (!fit) {+ const n = steps.filter((s) => s.key.startsWith("fit")).length + 1;+ fit = {+ key: `fit${n}`,+ label: n > 1 ? `Photo ${n} in ${aspect}` : `Photo in ${aspect}`,+ request: { feature, modelId: FIT_PHOTO_MODEL, op: "outpaint", prompt: FIT_PHOTO_PROMPT, inputs: { images: [photo] }, params: { extra: pads } },+ };+ steps.push(fit);+ }+ return { chain: [{ slot: "images", position: "first" }], after: [fit.key] };+}+/** The model's own aspect ratio closest to the wanted one ("auto" when it takes it, else by shape). */export function nearestAspect(want: string | undefined, allowed: string[] | undefined): string | undefined {if (!want || !allowed?.length || allowed.includes(want)) return want;@@ -351,25 +402,36 @@ export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlanconst motionText = (extra?: string) =>join(tpl ? fill(tpl.prompt, product, brand) : "A polished product commercial", extra, productLine(product), hasProduct && "The product stays exactly as in the first frame: same shape, label and colours", prompt, brandText, !hasProduct && website && `For the product at ${website}`);const base = { feature, modelId, params: { aspectRatio: aspect } as GenerationRequest["params"] };- // Open models make a few seconds per clip: longer motion is several shots from the product photo, joined.- const shots = open ? shotPlan(want, plannedDurations(model)) : [snapDuration(want, model.options.durations)];- if (!open && shots[0] !== want) notes.push(`${model.name} makes ${shots[0]} s clips — the closest to ${want} s`);+ // Open models make a few seconds per clip: longer motion is several shots from the product photo, joined. MiniMax H3+ // on your GPU renders any length from 3 to 15 s in one clip.+ const range = open ? lengthRange(model) : undefined;+ const shots = range && want <= range[1] ? [Math.max(range[0], Math.round(want))] : open ? shotPlan(want, plannedDurations(model)) : [snapDuration(want, model.options.durations)];+ if (shots.length === 1 && shots[0] !== want) notes.push(`${model.name} makes ${shots[0]} s clips — the closest to ${want} s`);const op: Operation = refs.length > 1 && supportsOp(model, "ref2v") ? "ref2v" : refs.length ? "i2v" : "t2v";if (op === "t2v" && !supportsOp(model, "t2v")) throw new PlanError("Attach a product to generate");const VARIATIONS = ["Wide establishing shot that introduces the product", "Slow push-in to a close-up of the product's details", "Graceful orbit around the product that ends on its hero angle", "Macro detail pass over the texture and label"];- const steps: Step[] = shots.map((d, i) => ({- key: `shot${i + 1}`,- label: shots.length > 1 ? `Shot ${i + 1} of ${shots.length}` : name,- request: {- ...base,- feature: shots.length > 1 ? `${feature}-step` : feature,- op,- prompt: motionText(shots.length > 1 ? VARIATIONS[i % VARIATIONS.length] : undefined).slice(0, MAX_PROMPT),- inputs: op === "t2v" ? undefined : { images: op === "ref2v" ? refs : refs.slice(0, 1) },- params: { ...base.params, duration: d, ...(model.options.audio && { generateAudio: true }) },- title,- },- }));+ // MiniMax H3 on your GPU keeps the photo's shape: a photo of another shape is grown to the format's first.+ const steps: Step[] = [];+ const { after: frameAfter, ...frame } = op === "i2v" ? startFrame(steps, refs[0], aspect, model, `${feature}-step`) : { after: undefined };+ if (frameAfter) notes.push(`${model.name} keeps its first frame's shape: the photo is grown to ${aspect} on Qwen-Image 2.1 first`);+ steps.push(+ ...shots.map(+ (d, i): Step => ({+ key: `shot${i + 1}`,+ label: shots.length > 1 ? `Shot ${i + 1} of ${shots.length}` : name,+ request: {+ ...base,+ feature: shots.length > 1 ? `${feature}-step` : feature,+ op,+ prompt: motionText(shots.length > 1 ? VARIATIONS[i % VARIATIONS.length] : undefined).slice(0, MAX_PROMPT),+ ...(op === "i2v" ? frame : { inputs: op === "t2v" ? undefined : { images: refs } }),+ params: { ...base.params, duration: d, ...(model.options.audio && { generateAudio: true }) },+ title,+ },+ ...(frameAfter && { after: frameAfter }),+ }),+ ),+ );if (shots.length > 1) {const joiner = UGC_MODELS[input.engine].join;steps.push({@@ -519,7 +581,9 @@ function planPresenter(p: PresenterPlan): RunPlan {}clips.push("captions");if (p.broll && p.productImages.length) {+ const { after: frameAfter, ...frame } = startFrame(steps, p.productImages[0], nearestAspect(aspect, clip.options.aspectRatios), clip, step);steps.push({+ ...(frameAfter && { after: frameAfter }),key: "broll",label: "Product close-up",request: {@@ -527,7 +591,7 @@ function planPresenter(p: PresenterPlan): RunPlan {modelId: M.clip,op: "i2v",prompt: join("Handheld close-up of the product turning slowly in soft natural light, shallow depth of field", KEEP_PRODUCT),- inputs: { images: p.productImages.slice(0, 1) },+ ...frame,params: { aspectRatio: nearestAspect(aspect, clip.options.aspectRatios), duration: clipLen(p.brollSeconds ?? 4), ...(clip.options.audio && { generateAudio: false }), ...(p.quality && { resolution: p.quality }) },},});@@ -784,10 +848,16 @@ function planAd(input: ClickToAdInput, ctx: { product: Product; brand?: BrandKitconst lens = open ? adShots(clip) : [4, 4, 4];const angles = ["Hero shot, the camera glides in", "Close-up on the details as light sweeps across", "The product in use, ending on a clean final frame"];const step = "click-to-ad-step";+ const shotAspect = nearestAspect(CLICK_TO_AD.aspect, clip.options.aspectRatios);+ // MiniMax H3 on your GPU keeps each photo's shape: a photo of another shape is grown to 9:16 first.+ const fits: Step[] = [];+ const frames = lens.map((_, i) => startFrame(fits, images[i % images.length], shotAspect === "auto" ? CLICK_TO_AD.aspect : shotAspect, clip, step));const steps: Step[] = [{ key: "voice", label: "Voiceover", request: { feature: step, modelId: M.voice, op: "tts", prompt: ctx.script, inputs: open ? { voiceAudio: input.voiceSample } : undefined, params: !open && input.voice ? { voice: input.voice } : undefined } },- ...lens.map(- (d, i): Step => ({+ ...fits,+ ...lens.map((d, i): Step => {+ const { after, ...frame } = frames[i];+ return {key: `shot${i + 1}`,label: `Shot ${i + 1} of ${lens.length}`,request: {@@ -795,11 +865,12 @@ function planAd(input: ClickToAdInput, ctx: { product: Product; brand?: BrandKitmodelId: M.clip,op: "i2v",prompt: join(angles[i % angles.length], style.visual, `Vertical 9:16 ad for ${ctx.product.name}`, KEEP_PRODUCT, ctx.brand && brandLine(ctx.brand)),- inputs: { images: [images[i % images.length]] },- params: { aspectRatio: nearestAspect(CLICK_TO_AD.aspect, clip.options.aspectRatios), duration: d, resolution: quality, ...(clip.options.audio && { generateAudio: false }) },+ ...frame,+ params: { aspectRatio: shotAspect, duration: d, resolution: quality, ...(clip.options.audio && { generateAudio: false }) },},- }),- ),+ ...(after && { after }),+ };+ }),{key: "film",label: "Joining the shots",diff --git a/src/server/storyboard.ts b/src/server/storyboard.tsindex 6d0a28dd..10bac701 100644--- a/src/server/storyboard.ts+++ b/src/server/storyboard.ts@@ -6,6 +6,7 @@ import { soulLook } from "@/lib/catalog/soul";import type { Engine, Generation, GenerationRequest } from "@/lib/catalog/types";import { storyboardName } from "@/lib/storyboard-board";import { supportsOp } from "@/lib/catalog";+import { COPY_JOIN_VIDEOS } from "@/lib/catalog/clip-lengths";import { filmModel, joinClips } from "./chains";import { llmText } from "./enhance";import { createGenerations, listGenerations, previewChained } from "./generations";@@ -138,6 +139,7 @@ export function createStoryboardFilm(batchId: string, opts: { modelId?: string }title: batchTitle,aspectRatio,resolution: model.defaults?.resolution,+ copy: COPY_JOIN_VIDEOS.has(model.id),step: { label: `Film · ${n} shots`, index: n, of: n + 1 },},);diff --git a/tests/assist-context.test.ts b/tests/assist-context.test.tsindex 11620e0e..c7b10956 100644--- a/tests/assist-context.test.ts+++ b/tests/assist-context.test.ts@@ -287,11 +287,12 @@ describe("studio tools", () => {expect(jobs.studio).toBeUndefined();});- it("a faceless episode joins its clips in groups of four on the open engine", () => {+ it("a faceless episode joins all its clips at once on both engines (the copy join on your GPU)", () => {const scenes = Array.from({ length: 6 }, (_, i) => ({ narration: `Line ${i}`, visual: `Scene ${i}` }));const steps = studio.fallbackSteps.faceless({ scenes, style: "flat 2D", aspect_ratio: "9:16" }, { engine: "open" });expect(steps.filter((s) => s.request.op === "t2i")).toHaveLength(6);- expect(steps.filter((s) => s.request.op === "concat").map((s) => s.key)).toEqual(["part0", "part1", "film"]);+ expect(steps.filter((s) => s.request.op === "concat").map((s) => [s.key, s.request.modelId])).toEqual([["film", "oss-join-encoded"]]);+ expect(steps.find((s) => s.key === "film")!.after).toEqual(scenes.map((_, k) => `clip${k}`));expect(steps.find((s) => s.key === "episode")).toMatchObject({ after: ["film", "voice"], request: { op: "mux", modelId: "oss-mux" } });expect(steps.find((s) => s.key === "voice")!.request.prompt).toBe(scenes.map((s) => s.narration).join("\n\n"));const cloud = studio.fallbackSteps.faceless({ scenes, style: "flat 2D" }, { engine: "cloud" });@@ -325,8 +326,8 @@ describe("studio tools", () => {expect(still.request).toMatchObject({ modelId: "oss-qwen-image-21", op: "t2i", params: { aspectRatio: "9:16" } });const clip = steps.find((s) => s.key === "clip0")!;expect(clip.request).toMatchObject({ modelId: "oss-minimax-h3", op: "i2v", params: { aspectRatio: "9:16", duration: 5 } });- // The clips are joined with the picture only, and the mux lays the narration on as the film's sound.- expect(steps.find((s) => s.key === "film")!.request.modelId).toBe("oss-join-clips");+ // The clips are joined by copy (one canvas, no decode), and the mux lays the narration on in place of their sound.+ expect(steps.find((s) => s.key === "film")!.request.modelId).toBe("oss-join-encoded");expect(steps.find((s) => s.key === "episode")).toMatchObject({ after: ["film", "voice"], chain: [{ slot: "video" }, { slot: "audio" }], request: { modelId: "oss-mux" } });for (const s of steps.filter((x) => x.key.startsWith("still") || x.key.startsWith("clip"))) expect(s.request.prompt, s.key).not.toMatch(NEGATION);});diff --git a/tests/chains-h3-sound.test.ts b/tests/chains-h3-sound.test.tsindex fec1d90e..f62b1156 100644--- a/tests/chains-h3-sound.test.ts+++ b/tests/chains-h3-sound.test.ts@@ -6,8 +6,8 @@ import { buildEpisodeGraph, defaultSettings, genreInfo, secondsFor, type Episode// MiniMax H3 makes every clip with its own sound. Where a pipeline lays a voice or music on the film (Faceless, the// Explainer, Content Factory, Assist's faceless episode, Click to Ad), that soundtrack takes the clips' place: the open-// joins build the film from the pictures, and the open mux replaces the film's sound. A Storyboard film has no-// soundtrack of its own: its open join keeps the picture only, as it did for silent clips.+// mux replaces the film's sound, whichever join built it. H3's clips share one canvas and frame rate, so Faceless and+// the Explainer join them with the copy join (no decode, flat memory); the decode joins build a film from the pictures.type Graph = Record<string, { class_type: string; inputs: Record<string, unknown> }>;const workflow = (id: string): Graph => JSON.parse(fs.readFileSync(path.join(__dirname, "../workflows/comfyui", `${id}.json`), "utf8"));@@ -87,14 +87,15 @@ describe("Faceless and the Explainer on MiniMax H3: the narration and the musicgetModel,);- it.each(["faceless", "explainer"] as const)("%s: clips with sound, joined as pictures, the voice and the bed mixed on", (feature) => {+ it.each(["faceless", "explainer"] as const)("%s: clips with sound, joined by copy, the voice and the bed mixed on in place of their sound", (feature) => {expect(getModel("oss-minimax-h3")!.options.audio).toBe("always");for (const music of [true, false]) {const g = graph(feature, { music });const clips = g.filter((s) => s.part === "clip");expect(clips.every((c) => c.request.modelId === "oss-minimax-h3")).toBe(true);const joins = g.filter((s) => s.part === "join");- expect(joins.every((j) => j.request.modelId === "oss-join-clips" && j.chain!.every((c) => c.slot === "videos"))).toBe(true);+ expect(joins.length).toBeGreaterThan(0);+ expect(joins.every((j) => j.request.modelId === "oss-join-encoded" && j.chain!.every((c) => c.slot === "videos"))).toBe(true);const mix = g.find((s) => s.key === "mix")!;expect(mix.request.modelId).toBe("oss-mux");expect(mix.after).toEqual(music ? ["join", "narration", "music"] : ["join", "narration"]);@@ -115,10 +116,24 @@ describe("Faceless and the Explainer on MiniMax H3: the narration and the musicexpect(route.note).toMatch(/one track: video-mux-audio-replace/);});- it("each H3 block lands on 5, 10 or 15 s", () => {+ it("each H3 block is one clip of 3 to 15 s, as long as the block", () => {const g = graph("faceless", { music: false });- const lengths = g.filter((s) => s.part === "clip").map((c) => c.request.params?.duration);- expect(lengths.length).toBeGreaterThan(0);- for (const d of lengths) expect([5, 10, 15]).toContain(d);+ const clips = g.filter((s) => s.part === "clip");+ expect(clips).toHaveLength(blocks.length);+ clips.forEach((c, i) => expect(c.request.params?.duration).toBe(blocks[i].seconds));+ for (const c of clips) expect(Number(c.request.params?.duration)).toBeGreaterThanOrEqual(3);+ });++ it("source pictures (an edit keeps each source's shape) go through the decode join, which fits every clip to the film", () => {+ const g = graph("faceless", { music: false, sourceImages: ["/api/files/uploads/a.png", "/api/files/uploads/b.png"] });+ const joins = g.filter((s) => s.part === "join");+ expect(joins.length).toBeGreaterThan(0);+ expect(joins.every((j) => j.request.modelId === "oss-join-clips")).toBe(true);+ });++ it("the copy join is a graph that never decodes a frame", () => {+ const g = workflow("video-concat-encoded");+ const classes = Object.values(g).map((v) => v.class_type).sort();+ expect(classes).toEqual(["ConcatenateVideo", "LoadVideo", "LoadVideo", "SaveVideo"]);});});diff --git a/tests/chains.test.ts b/tests/chains.test.tsindex ca693165..6a79dc12 100644--- a/tests/chains.test.ts+++ b/tests/chains.test.ts@@ -134,7 +134,8 @@ describe("storyboard film", () => {// MiniMax H3 on the GPU, in 5 s shots (its trained range starts there).expect(clips[0].modelId).toBe("oss-minimax-h3");expect(clips.every((c) => c.request.params?.duration === 5)).toBe(true);- expect(film.modelId).toBe("oss-join-clips");+ // H3's shots share one canvas and frame rate: the copy join, which never decodes them.+ expect(film.modelId).toBe("oss-join-encoded");// Start and end frame for every shot but the last.expect(dependsOn(clips[0].id)).toEqual([board.items[0].id, board.items[1].id]);expect(clips[0].request.chain).toEqual([{ slot: "images", position: "first" }, { slot: "endImage" }]);@@ -148,10 +149,19 @@ describe("storyboard film", () => {expect(first.request.inputs?.endImage).toBe(gens.getGeneration(board.items[1].id)!.outputs[0].url);}, 70_000);- it("joins long films in rounds of four on ComfyUI", async () => {+ it("joins a long MiniMax H3 film in one copy join", async () => {const board = await createStoryboard({ engine: "open", scenes: ["1", "2", "3", "4", "5", "6"] });const { batchId, items } = createStoryboardFilm(board.batchId);const joins = gens.listGenerations({ batchId }).filter((g) => g.op === "concat");+ expect(joins).toHaveLength(1);+ expect(joins[0].modelId).toBe("oss-join-encoded");+ expect(dependsOn(items[0].id)).toEqual(items.slice(1).map((g) => g.id));+ });++ it("joins long films in rounds of four on ComfyUI's decode join (Wan 2.2)", async () => {+ const board = await createStoryboard({ engine: "open", scenes: ["1", "2", "3", "4", "5", "6"] });+ const { batchId, items } = createStoryboardFilm(board.batchId, { modelId: "oss-wan22-14b-fast" });+ const joins = gens.listGenerations({ batchId }).filter((g) => g.op === "concat");expect(joins).toHaveLength(2);// Clips 1–4 are joined first; the final join takes that plus clips 5 and 6.const clips = items.filter((g) => g.op !== "concat").map((g) => g.id);diff --git a/tests/cinema-models.test.ts b/tests/cinema-models.test.tsindex b9aae211..a33acd59 100644--- a/tests/cinema-models.test.ts+++ b/tests/cinema-models.test.ts@@ -11,9 +11,9 @@ const input = (over: Partial<CinemaGenerateInput>): CinemaGenerateInput => ({ enconst refs = Array.from({ length: 6 }, (_, i) => `/api/files/uploads/r${i}.png`);describe("Cinema Studio's models", () => {- it("video: Fuobe Cinema, then MiniMax H3, on both engines; the cloud adds H3 Max and Wan 3.0", () => {+ it("video: Fuobe Cinema, then MiniMax H3, on both engines; the cloud adds H3 Max", () => {expect(CINEMA_MODELS.video.open).toEqual(["fuobe-cinema", "oss-minimax-h3", "oss-ltx25", "oss-wan22-14b"]);- expect(CINEMA_MODELS.video.cloud).toEqual(["fuobe-cinema", "minimax-h3", "seedance-2-5", "kling-3", "veo-3-1", "minimax-h3-max", "wan-3"]);+ expect(CINEMA_MODELS.video.cloud).toEqual(["fuobe-cinema", "minimax-h3", "seedance-2-5", "kling-3", "veo-3-1", "minimax-h3-max"]);for (const engine of ["open", "cloud"] as const) for (const id of CINEMA_MODELS.video[engine]) expect(getModel(id), id).toBeTruthy();// The default stays Fuobe Cinema.expect(planCinema(input({}), ctx).model.id).toBe("fuobe-cinema");@@ -31,6 +31,29 @@ describe("Cinema Studio's models", () => {expect(planCinema(input({ engine: "cloud", modelId: "minimax-h3" }), ctx).model.id).toBe("minimax-h3");});+ it("MiniMax H3 and H3 Max render at their own tier nearest to the one picked", () => {+ const res = (over: Partial<CinemaGenerateInput>) => planCinema(input({ engine: "cloud", ...over }), ctx);+ // fal names H3's tiers 480P, 768P and 2K; H3 Max adds 1080P.+ expect(res({ modelId: "minimax-h3", resolution: "720p" }).steps[0].request.params?.resolution).toBe("768P");+ expect(res({ modelId: "minimax-h3", resolution: "1080p" }).steps[0].request.params?.resolution).toBe("768P");+ expect(res({ modelId: "minimax-h3", resolution: "480p" }).steps[0].request.params?.resolution).toBe("480P");+ expect(res({ modelId: "minimax-h3-max", resolution: "720p" }).steps[0].request.params?.resolution).toBe("768P");+ expect(res({ modelId: "minimax-h3-max", resolution: "1080p" }).steps[0].request.params?.resolution).toBe("1080P");+ const h3 = res({ modelId: "minimax-h3", resolution: "720p" });+ expect(h3.notes.join(" ")).not.toMatch(/renders up to/);+ expect(h3.costUsd).toBeGreaterThan(0);+ // A take with reference clips on the cloud default moves to H3 at its 768P.+ const clips = res({ resolution: "720p", videos: ["/api/files/ref.mp4"], audios: ["/api/files/ref.mp3"] });+ expect(clips.model.id).toBe("minimax-h3");+ expect(clips.steps[0].request.params?.resolution).toBe("768P");+ // On the GPU, H3 renders 768p.+ const open = planCinema(input({ modelId: "oss-minimax-h3", resolution: "720p" }), ctx);+ expect(open.steps[0].request.params?.resolution).toBe("768p");+ expect(open.notes.join(" ")).toMatch(/MiniMax H3 renders at 768p here/);+ // Every cloud choice has a price.+ for (const id of CINEMA_MODELS.video.cloud) expect(res({ modelId: id, resolution: "720p" }).costUsd, id).not.toBeNull();+ });+it("stills: the open menu is Soul Cinema, Ideogram 4, Qwen-Image 2.1, Krea 2 Realism and MOSS-Image", () => {expect(CINEMA_MODELS.image.open).toEqual(["fuobe-soul-cinema", "oss-ideogram-4", "oss-qwen-image-21", "oss-krea2-realism", "oss-moss-image"]);for (const id of CINEMA_MODELS.image.open) expect(getModel(id), id).toBeTruthy();diff --git a/tests/cinema-refs.test.ts b/tests/cinema-refs.test.tsindex 50c5ed41..95a0f789 100644--- a/tests/cinema-refs.test.ts+++ b/tests/cinema-refs.test.ts@@ -44,7 +44,7 @@ describe("reference clips", () => {const plan = planCinema({ ...VIDEO, ...CLIPS, modelId: "kling-3" }, ctx);expect(plan.model.id).toBe("kling-3");expect(plan.steps[0].request.inputs).toBeUndefined();- expect(plan.notes.join(" ")).toMatch(/Kling 3\.0 doesn't take reference videos and reference audio — MiniMax H3 or Seedance 2\.5 or MiniMax H3 Max or Wan 3\.0 do/);+ expect(plan.notes.join(" ")).toMatch(/Kling 3\.0 doesn't take reference videos and reference audio — MiniMax H3 or Seedance 2\.5 or MiniMax H3 Max do/);// Fuobe Cinema picked from the menu takes none yet: the partners that do are named.const original = planCinema({ ...VIDEO, ...CLIPS, modelId: "fuobe-cinema" }, ctx);expect(original.model.id).toBe("fuobe-cinema");diff --git a/tests/faceless.test.ts b/tests/faceless.test.tsindex 7f1a8f59..45e93b05 100644--- a/tests/faceless.test.ts+++ b/tests/faceless.test.ts@@ -143,16 +143,17 @@ describe("blocks", () => {expect(blockShots(10, getModel("gemini-omni-flash"))).toEqual([10]);});- it("lands MiniMax H3's shots on the 5, 10 and 15 s it is trained for (on your GPU), any 5–15 s hosted", () => {+ it("cuts MiniMax H3's shots to the block, any 3–15 s on your GPU, any 5–15 s hosted", () => {const h3 = getModel("oss-minimax-h3")!;- // The catalog also lists 3 s (the presets made at that length); a planned block never asks for it.- expect(h3.options.durations).toContain(3);- for (let s = 1; s <= 40; s++) for (const shot of blockShots(s, h3)) expect([5, 10, 15]).toContain(shot);- expect(blockShots(3, h3)).toEqual([5]);- expect(blockShots(7, h3)).toEqual([10]);- expect(blockShots(12, h3)).toEqual([15]);+ // The open graph renders any length on its 17n + 5 frame grid.+ for (let s = 1; s <= 40; s++) for (const shot of blockShots(s, h3)) expect(shot >= 3 && shot <= 15, `${s}: ${shot}`).toBe(true);+ expect(blockShots(2, h3)).toEqual([3]);+ expect(blockShots(4, h3)).toEqual([4]);+ expect(blockShots(7, h3)).toEqual([7]);+ expect(blockShots(12, h3)).toEqual([12]);expect(blockShots(20, h3)).toEqual([10, 10]);- expect(filmSeconds(9, h3)).toBe(10);+ expect(blockShots(40, h3)).toEqual([14, 13, 13]);+ expect(filmSeconds(9, h3)).toBe(9);// Hosted H3 takes any whole second from 5 to 15 (fal's schema).expect(blockShots(7, getModel("minimax-h3"))).toEqual([7]);expect(blockShots(3, getModel("minimax-h3"))).toEqual([5]);@@ -245,25 +246,25 @@ describe("render graph", () => {expect(long.filter((s) => s.part === "join").map((j) => j.after!.length)).toEqual([24, 24, 12, 3]);});- it("open: MiniMax H3 in 5, 10 or 15 s shots, joins folded 4 at a time, Chatterbox, music under the voice, Qwen3-ASR timed burn-in", () => {+ it("open: MiniMax H3 shots as long as the block, one copy join, Chatterbox, music under the voice, Qwen3-ASR timed burn-in", () => {const g = graphFor({ engine: "open", animation: "animated", music: true, voice: null }, six);const stills = g.filter((s) => s.part === "still");expect(stills[0].request).toMatchObject({ modelId: "oss-qwen-image-21", params: { aspectRatio: "16:9", numOutputs: 1 } });expect(stills[0].request.op).toBeUndefined();expect(stills[0].request.inputs).toBeUndefined();const clips = g.filter((s) => s.part === "clip");- // Each 9 s block is one 10 s H3 clip at 768p; H3 always makes sound, so no audio switch is sent.+ // Each 9 s block is one 9 s H3 clip at 768p; H3 always makes sound, so no audio switch is sent.expect(clips).toHaveLength(6);- expect(clips[0].request).toMatchObject({ modelId: "oss-minimax-h3", op: "i2v", params: { duration: 10, resolution: "768p" } });+ expect(clips[0].request).toMatchObject({ modelId: "oss-minimax-h3", op: "i2v", params: { duration: 9, resolution: "768p" } });expect(clips.every((c) => c.request.params?.generateAudio === undefined)).toBe(true);const joins = g.filter((s) => s.part === "join");- // 6 clips → joins of 4 and 2 → the final join of both.- expect(joins.map((j) => j.after!.length)).toEqual([4, 2, 2]);- expect(joins.every((j) => j.request.modelId === "oss-join-clips")).toBe(true);+ // The clips share one canvas and 24 fps: one copy join of all 6, which never decodes them (flat memory).+ expect(joins.map((j) => j.after!.length)).toEqual([6]);+ expect(joins.every((j) => j.request.modelId === "oss-join-encoded")).toBe(true);const narration = g.find((s) => s.key === "narration")!;expect(narration.request).toMatchObject({ modelId: "oss-chatterbox", inputs: { voiceAudio: "/api/files/uploads/demo-voice.wav" } });- // The bed is as long as the film (six 10 s shots) plus a second.- expect(g.find((s) => s.key === "music")!.request).toMatchObject({ modelId: "oss-ace-step", op: "music", params: { duration: 61, extra: { lyrics: "[Instrumental]" } } });+ // The bed is as long as the film (six 9 s shots) plus a second.+ expect(g.find((s) => s.key === "music")!.request).toMatchObject({ modelId: "oss-ace-step", op: "music", params: { duration: 55, extra: { lyrics: "[Instrumental]" } } });const mix = g.find((s) => s.key === "mix")!;expect(mix).toMatchObject({ after: ["join", "narration", "music"], chain: [{ slot: "video" }, { slot: "audio" }, { slot: "audio2" }] });expect(mix.request).toMatchObject({ modelId: "oss-mux", params: { extra: { backgroundVolumeDb: -14 } } });@@ -592,8 +593,27 @@ describe("timing: every scene cut to its spoken lines", () => {expect(plannedTiming(six, wan)).toEqual(Object.fromEntries(six.map((b) => [b.id, 10])));});+ it("keeps each scene on its lines with MiniMax H3 on your GPU, short lines too", () => {+ const h3 = getModel("oss-minimax-h3")!;+ // Eight short lines of 9 words, about 3.6 s each when spoken.+ const eight = Array.from({ length: 8 }, (_, i) => block(i, 9));+ const t = spokenTimes(eight, aligned(eight, 0.36))!;+ const timing = sceneTiming(eight, t, h3);+ let film = 0;+ eight.forEach((b, i) => {+ if (i > 0) expect(Math.abs(film - t.starts[i]!), `scene ${i + 1}`).toBeLessThan(1);+ film += timing[b.id];+ });+ expect(film).toBeGreaterThanOrEqual(t.end);+ expect(film).toBeLessThan(t.end + 2);+ // The graph makes those lengths, each scene one H3 clip.+ const g = graphFor({ engine: "open", music: false, voice: null }, withTiming(eight, timing));+ expect(sceneSpans(g, 8).map((s) => s.seconds)).toEqual(eight.map((b) => timing[b.id]));+ expect(g.filter((s) => s.part === "clip")).toHaveLength(8);+ });+it("gives a block the same shots planned or timed (the graph derives them from its length)", () => {- for (const m of [gemini, wan, getModel("seedance-2-5")]) {+ for (const m of [gemini, wan, getModel("seedance-2-5"), getModel("oss-minimax-h3")]) {for (let s = 3; s <= 25; s++) expect(blockShots(filmSeconds(s, m), m)).toEqual(blockShots(s, m));}});diff --git a/tests/marketing-api.test.ts b/tests/marketing-api.test.tsindex 493ac26e..5be6cccd 100644--- a/tests/marketing-api.test.ts+++ b/tests/marketing-api.test.ts@@ -456,6 +456,41 @@ describe("Click to Ad", () => {expect(openPresenter.steps.find((s) => s.key === "film")!.request.modelId).toBe("oss-join-sound1");});+ it("grows a photo of another shape to the ad's before MiniMax H3 animates it on your GPU", async () => {+ const { encodePng } = await import("@/server/png");+ const photo = (w: number, h: number) => saveFile({ data: encodePng({ width: w, height: h, data: Buffer.alloc(w * h * 4, 200) }), contentType: "image/png", name: `p${w}x${h}.png`, source: "upload" }).url;+ expect(mk.padsTo({ width: 1000, height: 1000 }, "9:16")).toEqual({ padLeft: 0, padTop: 392, padRight: 0, padBottom: 392 });+ expect(mk.padsTo({ width: 1600, height: 900 }, "9:16")).toEqual({ padLeft: 0, padTop: 976, padRight: 0, padBottom: 976 });+ expect(mk.padsTo({ width: 720, height: 1280 }, "9:16")).toBeNull();+ expect(mk.padsTo({ width: 900, height: 1600 }, "16:9")).toEqual({ padLeft: 976, padTop: 0, padRight: 976, padBottom: 0 });+ const square = photo(64, 64);+ const product = { ...brand.listProducts()[0], images: [square] };+ // Product motion, 9:16: the square photo is grown to 9:16 on Qwen-Image 2.1, then H3 starts on that picture.+ const motion = mk.planMarketing({ engine: "open", format: "motion-hyper", duration: 7 }, { product });+ expect(motion.steps.map((s) => s.key)).toEqual(["fit1", "shot1"]);+ expect(motion.steps[0].request).toMatchObject({ modelId: "oss-qwen-image-21", op: "outpaint", inputs: { images: [square] }, params: { extra: { padTop: 24, padBottom: 24, padLeft: 0, padRight: 0 } } });+ expect(motion.steps[1]).toMatchObject({ after: ["fit1"], request: { modelId: "oss-minimax-h3", op: "i2v", chain: [{ slot: "images", position: "first" }], params: { aspectRatio: "9:16", duration: 7 } } });+ expect(motion.steps[1].request.inputs).toBeUndefined();+ expect(motion.finals).toEqual(["shot1"]);+ // A photo already in the ad's shape, or Wan 2.2 (it crops to the ratio itself), starts on the photo.+ const tall = photo(72, 128);+ const inShape = mk.planMarketing({ engine: "open", format: "motion-hyper", duration: 7 }, { product: { ...product, images: [tall] } });+ expect(inShape.steps.map((s) => s.key)).toEqual(["shot1"]);+ expect(inShape.steps[0].request.inputs).toEqual({ images: [tall] });+ const wan = mk.planMarketing({ engine: "open", format: "motion-hyper", duration: 5, modelId: "oss-wan22-14b-fast" }, { product });+ expect(wan.steps.map((s) => s.key)).toEqual(["shot1"]);+ // Click to Ad: each photo grown once, every shot starting on its grown picture.+ const script = "Three reasons I keep this in my bag. It is light, it is tough, and it looks great.";+ const ad = mk.planClickToAd({ engine: "open", productId: product.id, styleId: "luxury", voiceSample: upload("v.png") }, { product, script });+ expect(ad.steps.filter((s) => s.key.startsWith("fit")).map((s) => s.request.inputs?.images)).toEqual([[square]]);+ for (const s of ad.steps.filter((x) => x.key.startsWith("shot"))) expect(s).toMatchObject({ after: ["fit1"], request: { modelId: "oss-minimax-h3", chain: [{ slot: "images", position: "first" }] } });+ // The UGC close-up of the product, too.+ const ugc = mk.planClickToAd({ engine: "open", productId: product.id, styleId: "simple-ugc", voiceSample: upload("w.png") }, { product, script });+ expect(ugc.steps.find((s) => s.key === "broll")).toMatchObject({ after: ["fit1"], request: { modelId: "oss-minimax-h3", op: "i2v" } });+ // The cloud keeps the photo as it is.+ expect(mk.planClickToAd({ engine: "cloud", productId: product.id, styleId: "luxury" }, { product, script }).steps.some((s) => s.key.startsWith("fit"))).toBe(false);+ });+it("writes a script offline within the word budget", async () => {const product = brand.listProducts()[0];const s = await mk.clickToAdScript({ engine: "cloud", productId: product.id, styleId: "simple-ugc" });