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.

ComfyUI: Ken Burns moves, crossfaded loops and joins of any number of clips, and a join that copies packets

Claude7ad4c0fd4ef2
diff --git a/scripts/comfy/hand-built/video-concat-encoded.json b/scripts/comfy/hand-built/video-concat-encoded.json
new file mode 100644
index 00000000..5dcedbe3
--- /dev/null
+++ b/scripts/comfy/hand-built/video-concat-encoded.json
@@ -0,0 +1,53 @@
+{
+ "1": {
+ "class_type": "LoadVideo",
+ "inputs": {
+ "file": "clip1.mp4"
+ },
+ "_meta": {
+ "title": "Clip 1 (video; copied, not decoded, when the clips match)"
+ }
+ },
+ "2": {
+ "class_type": "LoadVideo",
+ "inputs": {
+ "file": "clip2.mp4"
+ },
+ "_meta": {
+ "title": "Clip 2 (the provider adds one loader per further clip)"
+ }
+ },
+ "3": {
+ "class_type": "ConcatenateVideo",
+ "inputs": {
+ "videos.video0": [
+ "1",
+ 0
+ ],
+ "videos.video1": [
+ "2",
+ 0
+ ],
+ "codec": "auto"
+ },
+ "_meta": {
+ "title": "Concatenate Video (packet copy for matching clips, else one clip at a time is re-encoded)"
+ }
+ },
+ "4": {
+ "class_type": "SaveVideo",
+ "inputs": {
+ "video": [
+ "3",
+ 0
+ ],
+ "filename_prefix": "fuobe/video-concat-encoded",
+ "format": "auto",
+ "format.codec": "auto",
+ "codec": "auto"
+ },
+ "_meta": {
+ "title": "Save Video"
+ }
+ }
+}
diff --git a/scripts/comfy/library.spec.mjs b/scripts/comfy/library.spec.mjs
index 49119d64..8f10fec4 100644
--- a/scripts/comfy/library.spec.mjs
+++ b/scripts/comfy/library.spec.mjs
@@ -76,7 +76,7 @@
// Output fields beyond {node, kind}: stem ("voice" | "background"), role ("cues" | "transcript" | "language" |
// "sheet" | "tiles" | "layers" | "first-frame" | "turntable" | "lines" | "frame" | "frames" | "scene" | "depth" | "splat" |
// "brief"). Entry fields: worker "isolated" (needs its own ComfyUI, see README), expand "captions" (the provider writes one
-// segment per caption cue before submitting).
+// segment per caption cue before submitting), "timeline", "videos" / "audios" (one loader per clip in inputs.videos / audios).
import fs from 'node:fs';
@@ -2655,6 +2655,25 @@ export const SPEC = [
'the two match at the first, middle and last frame and differ in between, and the eased one barely moves over its first and last frames. ' +
'Crops are whole pixels, so a tiny still steps visibly (the first frame after zoom 1 jumps by one source pixel); supersample and a still larger than the output hide it.',
},
+ {
+ id: 'video-concat-encoded',
+ title: 'Join clips the open engine encoded, packet by packet in constant memory (core ConcatenateVideo, no decode)',
+ capability: 'concat',
+ handBuilt: 'hand-built/video-concat-encoded.json',
+ bindings: { video: [b('1', 'file')], video2: [b('2', 'file')] },
+ outputs: [{ node: '4', kind: 'video' }],
+ expand: 'videos',
+ limits: { maxClips: 100 },
+ vramGb: 0,
+ license: 'n/a (no model; ComfyUI core)',
+ notes:
+ 'The Faceless / Explainer "Frame by frame" join (r4/faceless-plus): the Ken Burns scenes (kenburns-still, and the pieces of scenes over 10 s), and joins of those joins, one after another in input order. ' +
+ 'The template joins two clips (video, video2); the provider rewrites it per request (expand "videos", expandVideoJoinWorkflow): one LoadVideo per inputs.videos entry, wired to ConcatenateVideo videos.video0..N-1 (at most 100). ' +
+ 'ConcatenateVideo copies the encoded packets when every clip has the same codec, extradata, size, bit depth, colour space and sound layout (clips ComfyUI\'s CreateVideo / SaveVideo made at one size and fps), ' +
+ 'so RAM stays flat however long the film is (video-concat-{2,3,4} decode every frame as float32: about 11 MB a frame at 720p, 20 GB for a 60 s film at 30 fps); otherwise it re-encodes one clip at a time to the first clip\'s settings ' +
+ '(still constant memory), and clips of different sizes fail with "could not be encoded compatibly". Unlike video-concat-{2,3,4} it neither scales, crops nor retimes: the clips must share one size and frame rate. ' +
+ 'Sound tracks are kept as they are (the Ken Burns clips have none; the mux adds the voice and the bed).',
+ },
// ---- Music beds and audio joins --------------------------------------------------------
{
@@ -2687,11 +2706,14 @@ export const SPEC = [
handBuilt: 'hand-built/audio-join-crossfade.json',
bindings: { audio: [b('1', 'audio')], audio2: [b('2', 'audio')], fadeCurve: [b('3', 'audio')], crossfade: [b('5', 'value')] },
outputs: [{ node: '17', kind: 'audio' }],
+ expand: 'audios',
vramGb: 0,
license: 'n/a (no model; ComfyUI core audio nodes; VideoHelperSuite loader, GPL-3.0 code)',
notes:
'audio then audio2, overlapped by crossfade seconds (params.crossfade, > 0; 0.02 gives a click-free hard join). fadeCurve = the same curve WAV as audio-loop-crossfade, crossfade seconds long, written by the provider. ' +
- 'More clips (params.audios in order): fold, i.e. join 1+2, then that result + 3, and so on. The output runs at the higher sample rate of the two (AudioConcat resamples) and is saved as FLAC. ' +
+ 'More clips (params.audios in order): the provider rewrites the graph for all of them in one prompt (expand "audios", expandAudioJoinWorkflow, r4/faceless-plus): every clip but the last is read by a VHS loader ' +
+ '(for its length), the first gives its body, each middle clip its head, middle and tail, the last its head and the rest, and each seam is tail x fade-out + next head x fade-in, all concatenated in order; ' +
+ 'middle clips must be longer than 2 x crossfade. The output runs at the highest sample rate of the clips (AudioConcat resamples) and is saved as FLAC. ' +
'Clips placed at exact times are audio-timeline\'s job. ' +
'Ran here (CPU, two sessions): 3 s 44.1 kHz tones + 2 s 48 kHz noise, crossfade 0.5 s -> FLAC 4.500 s at 48 kHz stereo in 0.2-2.1 s; the tones keep their level (-9.0 dB RMS) up to 2.5 s, ' +
'the overlap ramps over 0.5 s and the noise follows at its own level (-15.2 dB): no headroom is taken off here.',
diff --git a/scripts/comfy/validation-state.json b/scripts/comfy/validation-state.json
index 042e2067..619fdec7 100644
--- a/scripts/comfy/validation-state.json
+++ b/scripts/comfy/validation-state.json
@@ -545,6 +545,12 @@
"error": null,
"at": "2026-10-16T23:33:20.703Z"
},
+ "video-concat-encoded": {
+ "sha256": "0d99102a6a9bbbc2150ee23ae8d2ac3bbcd5f30903bb374082da2b7a04c51988",
+ "validated": true,
+ "error": null,
+ "at": "2026-10-23T01:05:19.050Z"
+ },
"video-concat-sound1-2": {
"sha256": "70ed1a9d7d25e3022e0289e8c1c4db3a6471e616201e3c1575150ce68cfef108",
"validated": true,
diff --git a/src/lib/av/crossfade.ts b/src/lib/av/crossfade.ts
new file mode 100644
index 00000000..2d40bfcd
--- /dev/null
+++ b/src/lib/av/crossfade.ts
@@ -0,0 +1,113 @@
+/**
+ * Crossfades for audio loops and joins (docs/research/comfyui-oss-4.md §e). Core ComfyUI has no gain-ramp
+ * node, so the provider writes the fade as a tiny WAV that the audio-loop-crossfade and audio-join-crossfade
+ * graphs multiply the music with: stereo, exactly `crossfade` seconds long, left channel = the fade-in, right
+ * channel = the fade-out, at 8 kHz (AudioMerge resamples the curve up to the music's rate, never the music
+ * down). The length math mirrors the graphs, so a planner knows what a job will make before it runs.
+ *
+ * The cloud has no crossfade: fal's merge-audios plays whole copies one after another (2–5 per call), so a
+ * long loop runs as a chain of calls (cloudLoopPasses) and comes out a little longer than asked.
+ */
+
+export const CURVE_RATE = 8000;
+
+/** Equal power keeps unrelated material at one loudness through a seam; linear avoids the +3 dB bump on near-identical material. */
+export type CurveShape = "equal-power" | "linear";
+
+/** The fade-in and fade-out gains at t (0 = the seam starts, 1 = it ends). */
+export function fadeGains(t: number, shape: CurveShape = "equal-power"): [fadeIn: number, fadeOut: number] {
+ const x = Math.max(0, Math.min(1, t));
+ return shape === "linear" ? [x, 1 - x] : [Math.sin((Math.PI / 2) * x), Math.cos((Math.PI / 2) * x)];
+}
+
+/**
+ * The crossfade curve as a 16-bit stereo PCM WAV, exactly `seconds` long: left = the fade-in from 0 to 1,
+ * right = the fade-out from 1 to 0. The first and last samples are exact, so the music around a seam joins it
+ * at full level.
+ */
+export function fadeCurveWav(seconds: number, shape: CurveShape = "equal-power", rate = CURVE_RATE): Uint8Array {
+ if (!(seconds > 0)) throw new Error("A crossfade needs a length above 0 s");
+ const n = Math.max(2, Math.round(seconds * rate));
+ const bytes = new Uint8Array(44 + n * 4);
+ const v = new DataView(bytes.buffer);
+ const text = (o: number, s: string) => [...s].forEach((c, i) => v.setUint8(o + i, c.charCodeAt(0)));
+ text(0, "RIFF");
+ v.setUint32(4, 36 + n * 4, true);
+ text(8, "WAVE");
+ text(12, "fmt ");
+ v.setUint32(16, 16, true);
+ v.setUint16(20, 1, true); // PCM
+ v.setUint16(22, 2, true); // stereo
+ v.setUint32(24, rate, true);
+ v.setUint32(28, rate * 4, true);
+ v.setUint16(32, 4, true);
+ v.setUint16(34, 16, true);
+ text(36, "data");
+ v.setUint32(40, n * 4, true);
+ for (let i = 0; i < n; i++) {
+ const [fadeIn, fadeOut] = fadeGains(i / (n - 1), shape);
+ v.setInt16(44 + i * 4, Math.round(fadeIn * 32767), true);
+ v.setInt16(46 + i * 4, Math.round(fadeOut * 32767), true);
+ }
+ return bytes;
+}
+
+const round3 = (n: number) => Math.round(n * 1000) / 1000;
+
+/** How many times the loop graph appends the clip's body and seam: ceil((duration − X) / (clip − X)), at least 1. */
+export function loopRepeats(clip: number, duration: number, crossfade: number): number {
+ return Math.max(1, Math.ceil((duration - crossfade) / (clip - crossfade)));
+}
+
+/** Where the seams of a crossfaded loop start (each is `crossfade` seconds long), up to the bed's length. */
+export function loopSeams(clip: number, duration: number, crossfade: number): number[] {
+ const step = clip - crossfade;
+ const out: number[] = [];
+ for (let t = step; t < duration - crossfade; t += step) out.push(round3(t));
+ return out;
+}
+
+/** Clips joined with a crossfade at each seam: every seam overlaps the two clips by `crossfade` seconds. */
+export const joinedLength = (lengths: number[], crossfade: number): number => round3(lengths.reduce((a, b) => a + b, 0) - Math.max(0, lengths.length - 1) * crossfade);
+
+/** What stops a crossfade on these clips (null when it can run): a loop needs a clip longer than two crossfades; a join, middle clips that long and end clips longer than one. */
+export function crossfadeProblem(lengths: number[], crossfade: number, mode: "loop" | "join"): string | null {
+ if (!(crossfade > 0)) return "The crossfade needs to be longer than 0 s";
+ const s = (n: number) => `${round3(n)} s`;
+ if (mode === "loop") {
+ const [clip] = lengths;
+ return clip !== undefined && clip <= 2 * crossfade ? `A ${s(crossfade)} crossfade needs a clip longer than ${s(2 * crossfade)} (this one is ${s(clip)}) — shorten the crossfade` : null;
+ }
+ const i = lengths.findIndex((l, k) => l <= (k === 0 || k === lengths.length - 1 ? crossfade : 2 * crossfade));
+ if (i < 0) return null;
+ const need = i === 0 || i === lengths.length - 1 ? crossfade : 2 * crossfade;
+ return `Clip ${i + 1} is ${s(lengths[i])}, too short for a ${s(crossfade)} crossfade (it needs more than ${s(need)}) — shorten the crossfade`;
+}
+
+/**
+ * Whole plays for a cloud loop (fal merge-audios lists the clip 2–`maxPlays` times per call; each call's
+ * result is the next one's clip): the fewest plays that reach `duration`, made of passes of at most
+ * `maxPlays`, then the fewest passes. 60 plays → [5, 4, 3]; 7 plays (prime) → [4, 2] = 8. Empty when one play
+ * is already long enough.
+ */
+export function cloudLoopPasses(clip: number, duration: number, maxPlays = 5): number[] {
+ if (!(clip > 0) || duration <= clip) return [];
+ const need = Math.ceil(duration / clip - 1e-9);
+ // Plays per pass multiply: the smallest product ≥ need, made of factors 2..maxPlays (largest first).
+ const best = { plays: [] as number[], product: Infinity };
+ const walk = (left: number, product: number, picked: number[]) => {
+ if (product >= need) {
+ if (product < best.product || (product === best.product && picked.length < best.plays.length)) Object.assign(best, { plays: [...picked], product });
+ return;
+ }
+ if (!left || product * maxPlays ** left < need) return;
+ for (let f = maxPlays; f >= 2; f--) if (!picked.length || f <= picked[picked.length - 1]) walk(left - 1, product * f, [...picked, f]);
+ };
+ for (let passes = 1; passes <= 8 && !best.plays.length; passes++) walk(passes, 1, []);
+ // One pass more can cut the overshoot (101 plays: 5 × 5 × 5 = 125 at three passes, 4 × 3 × 3 × 3 = 108 at four).
+ if (best.plays.length) walk(best.plays.length + 1, 1, []);
+ return best.plays;
+}
+
+/** How long a chain of cloud loop passes comes out: the clip times every pass's plays. */
+export const cloudLoopLength = (clip: number, passes: number[]): number => round3(passes.reduce((n, p) => n * p, clip));
diff --git a/src/lib/av/joins.ts b/src/lib/av/joins.ts
new file mode 100644
index 00000000..bd578c43
--- /dev/null
+++ b/src/lib/av/joins.ts
@@ -0,0 +1,105 @@
+import type { ComfyNode, ComfyWorkflow } from "@/lib/comfy";
+
+/**
+ * Open-engine joins of any number of clips in one ComfyUI prompt (r4/faceless-plus). The library's graphs
+ * join two; the provider rewrites them per request (manifest `expand`):
+ * - "videos" (video-concat-encoded): one LoadVideo per clip into ConcatenateVideo, which copies the encoded
+ * packets of clips ComfyUI made (Faceless "Frame by frame": no decode, flat memory);
+ * - "audios" (audio-join-crossfade): every clip in order with an equal-power crossfade at each seam.
+ * Pure (no I/O), like expandTimelineWorkflow.
+ */
+
+/** ConcatenateVideo's autogrow input takes at most 100 clips. */
+export const MAX_VIDEO_JOIN = 100;
+/** Seams in one audio prompt: plenty for a Join of a few clips (each seam is about a dozen nodes). */
+export const MAX_AUDIO_JOIN = 50;
+/** "To the end" for a trim (TrimAudioDuration stops at the clip's end), as the template's last clip does. */
+const REST = 100000;
+
+const ids = (wf: ComfyWorkflow, cls: string) => Object.keys(wf).filter((id) => wf[id].class_type === cls);
+const linkFrom = (v: unknown): string | undefined => (Array.isArray(v) && typeof v[0] === "string" ? v[0] : undefined);
+
+/** The video join for every clip: one loader per clip, in order, into the one ConcatenateVideo. */
+export function expandVideoJoinWorkflow(wf: ComfyWorkflow, names: string[]): ComfyWorkflow {
+ if (names.length < 2) throw new Error("Add at least two clips to join");
+ if (names.length > MAX_VIDEO_JOIN) throw new Error(`One join takes up to ${MAX_VIDEO_JOIN} clips`);
+ const [join] = ids(wf, "ConcatenateVideo");
+ const [loader] = ids(wf, "LoadVideo");
+ if (!join || !loader) throw new Error("Not a video join workflow (needs LoadVideo → ConcatenateVideo)");
+ const out: ComfyWorkflow = {};
+ for (const [id, n] of Object.entries(wf)) if (n.class_type !== "LoadVideo") out[id] = structuredClone(n);
+ const inputs: ComfyNode["inputs"] = Object.fromEntries(Object.entries(wf[join].inputs).filter(([k]) => !k.startsWith("videos.")));
+ names.forEach((file, i) => {
+ const id = `clip${i + 1}`;
+ out[id] = { class_type: "LoadVideo", inputs: { ...wf[loader].inputs, file }, _meta: { title: `Clip ${i + 1}` } };
+ inputs[`videos.video${i}`] = [id, 0];
+ });
+ out[join].inputs = inputs;
+ return out;
+}
+
+/**
+ * The crossfaded audio join for every clip, from the two-clip template (VHS loader → body + tail; LoadAudio →
+ * head + rest; the curve split into fade-in / fade-out; AudioMerge multiply and add; AudioConcat):
+ *
+ * clip 1: body (all but the last X s) + tail · clip k: head, middle (all but the first and last X s), tail ·
+ * last clip: head + the rest · seam k = tail k × fade-out + head k+1 × fade-in
+ * → body 1, seam 1, middle 2, seam 2, …, rest
+ *
+ * Every clip but the last is read by the VHS loader, whose second output is its length. The middle clips must
+ * be longer than two crossfades (the graph stops on a trim that ends before it starts).
+ */
+export function expandAudioJoinWorkflow(wf: ComfyWorkflow, names: string[]): ComfyWorkflow {
+ if (names.length < 2) throw new Error("Add at least two clips to join");
+ if (names.length > MAX_AUDIO_JOIN) throw new Error(`One join takes up to ${MAX_AUDIO_JOIN} clips`);
+ const [vhs] = ids(wf, "VHS_LoadAudioUpload");
+ const [split] = ids(wf, "SplitAudioChannels");
+ const curve = split ? linkFrom(wf[split].inputs.audio) : undefined;
+ const [clip2] = ids(wf, "LoadAudio").filter((id) => id !== curve);
+ const [x] = ids(wf, "PrimitiveFloat");
+ const negX = ids(wf, "ComfyMathExpression").find((id) => String(wf[id].inputs.expression).replace(/\s/g, "") === "0-a");
+ const [trim] = ids(wf, "TrimAudioDuration");
+ const [merge] = ids(wf, "AudioMerge");
+ const [concat] = ids(wf, "AudioConcat");
+ const [save] = Object.keys(wf).filter((id) => /^SaveAudio/.test(wf[id].class_type));
+ if (!vhs || !split || !curve || !clip2 || !x || !negX || !trim || !merge || !concat || !save) {
+ throw new Error("Not an audio join workflow (needs a VHS loader, a LoadAudio, the fade curve split in two, trims, merges and concats)");
+ }
+ const out: ComfyWorkflow = {};
+ for (const id of [curve, split, x, negX, save]) out[id] = structuredClone(wf[id]);
+ const [fadeIn, fadeOut] = [[split, 0], [split, 1]];
+ const X = [x, 0];
+ const add = (id: string, node: ComfyNode) => ((out[id] = node), id);
+ const cut = (id: string, from: string, start: unknown, duration: unknown) =>
+ add(id, { class_type: wf[trim].class_type, inputs: { ...wf[trim].inputs, audio: [from, 0], start_index: start, duration } });
+ const math = (id: string, expression: string, a: unknown, b: unknown) => add(id, { class_type: "ComfyMathExpression", inputs: { expression, "values.a": a, "values.b": b } });
+ const mix = (id: string, a: string, b: unknown, method: string) => add(id, { class_type: wf[merge].class_type, inputs: { ...wf[merge].inputs, audio1: [a, 0], audio2: b, merge_method: method } });
+ const join = (id: string, a: string, b: string) => add(id, { class_type: wf[concat].class_type, inputs: { ...wf[concat].inputs, audio1: [a, 0], audio2: [b, 0], direction: "after" } });
+
+ const n = names.length;
+ const heads: string[] = [];
+ const tails: string[] = [];
+ const mids: string[] = [];
+ names.forEach((audio, i) => {
+ const k = i + 1;
+ const last = i === n - 1;
+ const load = add(
+ `a${k}_load`,
+ last ? { class_type: "LoadAudio", inputs: { ...wf[clip2].inputs, audio }, _meta: { title: `Clip ${k}` } } : { class_type: wf[vhs].class_type, inputs: { ...wf[vhs].inputs, audio }, _meta: { title: `Clip ${k}` } },
+ );
+ if (i > 0) heads[i] = cut(`a${k}_head`, load, 0, X);
+ if (i === 0) mids[i] = cut(`a${k}_body`, load, 0, [math(`a${k}_len`, "a - b", [load, 1], X), 0]);
+ else if (!last) mids[i] = cut(`a${k}_mid`, load, X, [math(`a${k}_len`, "a - 2 * b", [load, 1], X), 0]);
+ else mids[i] = cut(`a${k}_rest`, load, X, REST);
+ if (!last) tails[i] = cut(`a${k}_tail`, load, [negX, 0], X);
+ });
+ let acc = mids[0];
+ for (let i = 0; i < n - 1; i++) {
+ const k = i + 1;
+ const seam = mix(`s${k}_seam`, mix(`s${k}_out`, tails[i], fadeOut, "multiply"), [mix(`s${k}_in`, heads[i + 1], fadeIn, "multiply"), 0], "add");
+ acc = join(`s${k}_join`, acc, seam);
+ acc = join(`s${k}_next`, acc, mids[i + 1]);
+ }
+ out[save].inputs.audio = [acc, 0];
+ return out;
+}
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index dc7abc9f..9dc62868 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -1013,6 +1013,52 @@ const open: ModelDef[] = [
options: {},
hidden: true,
}),
+ // Faceless / Explainer "Frame by frame" and the Audio hub's Loop / extend and Join (r4/faceless-plus): core nodes, no model.
+ o({
+ id: "oss-ken-burns",
+ name: "Ken Burns",
+ vendor: "ComfyUI",
+ family: "utility",
+ kind: "video",
+ tagline: "A slow pan and zoom over a still, up to 10 s a clip · no model, runs on CPU",
+ routes: [comfy("still-motion", "kenburns-still", "zoom + pan, eased or linear; 10 s per job, longer scenes are split and joined")],
+ options: { aspectRatios: VID_AR, resolutions: ["480p", "720p", "1080p"], maxImages: 1, promptless: true },
+ defaults: { aspectRatio: "16:9", resolution: "720p" },
+ hidden: true,
+ }),
+ o({
+ id: "oss-join-encoded",
+ name: "Join clips (copy)",
+ vendor: "ComfyUI",
+ family: "utility",
+ kind: "video",
+ tagline: "Joins clips the open engine made, packet by packet: no decode, flat memory · CPU",
+ routes: [comfy("concat", "video-concat-encoded", "one loader per clip; the clips share one size and frame rate")],
+ options: {},
+ hidden: true,
+ }),
+ o({
+ id: "oss-audio-loop",
+ name: "Loop audio",
+ vendor: "ComfyUI",
+ family: "utility",
+ kind: "audio",
+ tagline: "Extends a clip to any length up to 10 minutes, crossfading every seam and fading out at the end · CPU",
+ routes: [comfy("audio-loop", "audio-loop-crossfade", "equal-power seams; the fade curve is written per job")],
+ options: { promptless: true },
+ hidden: true,
+ }),
+ o({
+ id: "oss-audio-join",
+ name: "Join audio",
+ vendor: "ComfyUI",
+ family: "utility",
+ kind: "audio",
+ tagline: "Clips one after another with a crossfade at every seam · CPU",
+ routes: [comfy("audio-join", "audio-join-crossfade", "every clip in one job")],
+ options: { maxAudios: 10, promptless: true },
+ hidden: true,
+ }),
// Product 3D, try-on
o({
id: "oss-trellis2",
diff --git a/src/lib/comfy.ts b/src/lib/comfy.ts
index 0c4f585b..e88adeb1 100644
--- a/src/lib/comfy.ts
+++ b/src/lib/comfy.ts
@@ -99,9 +99,10 @@ export interface ManifestWorkflow {
worker?: "isolated";
/**
* The provider rewrites the graph before submitting ("captions": one segment per caption cue;
- * "timeline": one loader per audio clip, each placed at its start time).
+ * "timeline": one loader per audio clip, each placed at its start time; "videos" / "audios": one loader
+ * per clip of a join, src/lib/av/joins.ts).
*/
- expand?: "captions" | "timeline";
+ expand?: "captions" | "timeline" | "videos" | "audios";
validated: boolean;
notes?: string;
}
diff --git a/src/server/providers/comfyui.ts b/src/server/providers/comfyui.ts
index 5d58d128..42c795ae 100644
--- a/src/server/providers/comfyui.ts
+++ b/src/server/providers/comfyui.ts
@@ -28,6 +28,8 @@ import {
type ManifestOutput,
type ManifestWorkflow,
} from "@/lib/comfy";
+import { crossfadeProblem, fadeCurveWav } from "@/lib/av/crossfade";
+import { expandAudioJoinWorkflow, expandVideoJoinWorkflow } from "@/lib/av/joins";
import { expandTimelineWorkflow, readTimeline } from "@/lib/av/timeline";
import { guessKind } from "@/lib/catalog/payload";
import type { GenInput, MediaKind, Operation } from "@/lib/catalog/types";
@@ -406,6 +408,12 @@ function captionCues(input: GenInput, extra: Record<string, unknown>): CaptionCu
const seconds = (n: number) => (n >= 10 ? String(Math.round(n)) : String(Math.round(n * 10) / 10));
const GB = 2 ** 30;
+/** Per-job length limits a graph enforces (manifest limits.maxDurationSec), in words. */
+const OVER_LIMIT: Record<string, (s: number) => string> = {
+ "still-motion": (s) => `Ken Burns on the open engine makes up to ${s} s per clip — split a longer move into pieces`,
+ "audio-loop": (s) => `Loops on the open engine run up to ${s / 60} minutes (${s} s)`,
+};
+
/**
* Turn a canonical request into the exact ComfyUI prompt: picks the workflow variant, maps Fuobe's inputs
* onto the workflow's bindings (sizes, frames, trim times, languages, palettes, layers…), uploads files the
@@ -464,6 +472,12 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,
values.prompt = (input.dialogue ?? []).filter((l) => l.text.trim()).map((l) => `SPEAKER ${l.voice === "B" ? "B" : "A"}: ${l.text.trim()}`).join("\n");
}
if (ctx.op === "voice-change") values.audio2 = input.voiceAudio;
+ // A join of audio clips takes them in order: the graph binds the first two, expandAudioJoinWorkflow the rest.
+ const audios = input.audios ?? [];
+ if (manifest.expand === "audios" && audios.length) {
+ values.audio = audios[0];
+ values.audio2 = audios[1];
+ }
// A voice track on the video's timeline: the clips are the spoken lines (the template binds the first).
if (ctx.op === "timeline") values.audio = input.audios?.[0] ?? input.audio;
// Speech workflows read the soundtrack with LoadAudio, which also takes a video upload.
@@ -544,6 +558,29 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,
if (b.description && !extra.description) values.description = input.prompt;
if (b.numLayers && input.numLayers) values.numLayers = Math.max(1, Math.min(Number(manifest.limits?.maxLayers ?? 10), Math.round(input.numLayers)));
+ // Ken Burns (kenburns-still): the move's zoom, crop centre and easing.
+ if (b.zoomStart && input.zoomFrom !== undefined) values.zoomStart = input.zoomFrom;
+ if (b.zoomEnd && input.zoomTo !== undefined) values.zoomEnd = input.zoomTo;
+ if (b.panStartX && input.panFrom) Object.assign(values, { panStartX: input.panFrom.x, panStartY: input.panFrom.y });
+ if (b.panEndX && input.panTo) Object.assign(values, { panEndX: input.panTo.x, panEndY: input.panTo.y });
+ if (b.easeInOut && input.easing) values.easeInOut = input.easing === "linear" ? 0 : 1;
+ const maxSeconds = Number(manifest.limits?.maxDurationSec ?? 0);
+ if (maxSeconds && b.duration && Number(values.duration ?? d.duration ?? 0) > maxSeconds + 0.001) {
+ throw new ProviderError(OVER_LIMIT[manifest.capability]?.(maxSeconds) ?? `This workflow makes up to ${maxSeconds} s per job`);
+ }
+ // Loops and joins with a crossfade: core ComfyUI has no gain ramp, so the curve is a tiny WAV written here
+ // (left = fade-in, right = fade-out, exactly the crossfade long). Clips too short for it are refused up front.
+ if (b.fadeCurve) {
+ const fade = Math.max(0.02, Number(input.crossfade ?? d.crossfade ?? 1));
+ if (b.crossfade) values.crossfade = fade;
+ const loop = manifest.capability === "audio-loop";
+ const lengths = (loop ? [values.audio] : audios.length ? audios : [values.audio, values.audio2 ?? extra.audio2]).map((name) => ctx.media?.(String(name ?? ""))?.duration);
+ const problem = lengths.every((l): l is number => typeof l === "number") ? crossfadeProblem(lengths, fade, loop ? "loop" : "join") : null;
+ if (problem) throw new ProviderError(problem);
+ if (extra.fadeCurve === undefined) values.fadeCurve = await ctx.upload(Buffer.from(fadeCurveWav(fade, extra.curve === "linear" ? "linear" : "equal-power")), "audio/wav", "fade_curve.wav");
+ }
+ delete extra.curve;
+
// Soul HEX: the hex list as words, plus a swatch the ColorTransfer lock matches.
const palette = (input.palette ?? []).filter((p) => typeof p === "string" && p.trim());
if (palette.length) {
@@ -634,6 +671,13 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,
throw new ProviderError((e as Error).message);
}
}
+ // Joins of more clips than the template binds: one loader per clip, in one prompt.
+ try {
+ if (manifest.expand === "videos" && clips.length > 2) wf = expandVideoJoinWorkflow(wf, clips);
+ if (manifest.expand === "audios" && audios.length > 2) wf = expandAudioJoinWorkflow(wf, audios);
+ } catch (e) {
+ throw new ProviderError((e as Error).message);
+ }
if (input.loras?.length) wf = injectLoras(wf, input.loras);
const metaBatch = Object.values(wf).some((n) => n.class_type === "VHS_BatchManager");
return {
diff --git a/tests/av-crossfade.test.ts b/tests/av-crossfade.test.ts
new file mode 100644
index 00000000..25da8378
--- /dev/null
+++ b/tests/av-crossfade.test.ts
@@ -0,0 +1,79 @@
+import { describe, expect, it } from "vitest";
+import { cloudLoopLength, cloudLoopPasses, crossfadeProblem, CURVE_RATE, fadeCurveWav, fadeGains, joinedLength, loopRepeats, loopSeams } from "@/lib/av/crossfade";
+import { probeMedia } from "@/lib/media-probe";
+
+/** The samples of a 16-bit stereo WAV as [left, right] pairs in −1…1. */
+function samples(wav: Uint8Array): [number, number][] {
+ const v = new DataView(wav.buffer, wav.byteOffset, wav.byteLength);
+ const n = v.getUint32(40, true) / 4;
+ return Array.from({ length: n }, (_, i) => [v.getInt16(44 + i * 4, true) / 32767, v.getInt16(46 + i * 4, true) / 32767]);
+}
+
+describe("the crossfade curve the provider writes", () => {
+ it("is a stereo 16-bit 8 kHz WAV exactly the crossfade long: left fades in, right fades out", () => {
+ const wav = fadeCurveWav(1.5);
+ const info = probeMedia(wav)!;
+ expect(info).toMatchObject({ container: "wav", hasAudio: true });
+ expect(info.duration).toBeCloseTo(1.5, 6);
+ const v = new DataView(wav.buffer);
+ expect([v.getUint16(22, true), v.getUint32(24, true), v.getUint16(34, true)]).toEqual([2, CURVE_RATE, 16]);
+ const s = samples(wav);
+ expect(s).toHaveLength(12_000);
+ expect(s[0]).toEqual([0, 1]);
+ expect(s[s.length - 1][0]).toBe(1);
+ expect(s[s.length - 1][1]).toBeCloseTo(0, 4);
+ // Equal power: sin² + cos² = 1 all the way through, and the fade-in only ever rises.
+ for (const [a, b] of s) expect(a * a + b * b).toBeCloseTo(1, 3);
+ expect(s.every((x, i) => i === 0 || x[0] >= s[i - 1][0])).toBe(true);
+ const mid = s[Math.round((s.length - 1) / 2)];
+ expect(mid[0]).toBeCloseTo(Math.SQRT1_2, 3);
+ });
+
+ it("writes a linear curve for near-identical material, and refuses a zero-length fade", () => {
+ const s = samples(fadeCurveWav(0.5, "linear"));
+ expect(s).toHaveLength(4000);
+ for (const [a, b] of s) expect(a + b).toBeCloseTo(1, 3);
+ expect(fadeGains(0.25, "linear")).toEqual([0.25, 0.75]);
+ expect(() => fadeCurveWav(0)).toThrow(/above 0 s/);
+ });
+});
+
+describe("loop and join lengths (the graphs' own math)", () => {
+ it("repeats the body as audio-loop-crossfade does, with seams every clip − crossfade", () => {
+ // The research run: a 6 s clip with a 1 s crossfade became a 20 s bed with seams at 5, 10 and 15 s.
+ expect(loopRepeats(6, 20, 1)).toBe(4);
+ expect(loopSeams(6, 20, 1)).toEqual([5, 10, 15]);
+ // ACE-Step's 240 s bed looped to a 301 s episode: one seam, 3 s long.
+ expect(loopRepeats(240, 301, 3)).toBe(2);
+ expect(loopSeams(240, 301, 3)).toEqual([237]);
+ expect(loopRepeats(240, 200, 3)).toBe(1);
+ });
+
+ it("overlaps every join by the crossfade, and says which clip is too short for it", () => {
+ expect(joinedLength([3, 2], 0.5)).toBe(4.5); // the research run: 3 s + 2 s → 4.5 s
+ expect(joinedLength([10, 8, 12, 6], 1)).toBe(33);
+ expect(joinedLength([7], 1)).toBe(7);
+ expect(crossfadeProblem([10, 8, 12], 1, "join")).toBeNull();
+ expect(crossfadeProblem([10, 1.5, 12], 1, "join")).toMatch(/^Clip 2 is 1.5 s, too short for a 1 s crossfade \(it needs more than 2 s\)/);
+ expect(crossfadeProblem([0.8, 5], 1, "join")).toMatch(/^Clip 1 is 0.8 s/);
+ expect(crossfadeProblem([3], 2, "loop")).toMatch(/needs a clip longer than 4 s \(this one is 3 s\)/);
+ expect(crossfadeProblem([30], 2, "loop")).toBeNull();
+ expect(crossfadeProblem([30], 0, "loop")).toMatch(/longer than 0 s/);
+ });
+
+ it("plans cloud loops as whole plays, 2–5 per call, with the least overshoot", () => {
+ expect(cloudLoopPasses(30, 100)).toEqual([4]);
+ expect(cloudLoopLength(30, [4])).toBe(120);
+ expect(cloudLoopPasses(600, 601)).toEqual([2]);
+ expect(cloudLoopPasses(10, 600)).toEqual([5, 4, 3]); // exactly 600 s in three calls
+ expect(cloudLoopPasses(10, 70)).toEqual([4, 2]); // 7 plays can't be made of 2–5: 8
+ expect(cloudLoopPasses(10, 1010)).toEqual([4, 3, 3, 3]); // 108 plays beat 5 × 5 × 5 = 125
+ expect(cloudLoopPasses(60, 60)).toEqual([]);
+ expect(cloudLoopPasses(60, 61)).toEqual([2]);
+ for (const [clip, want] of [[7, 95], [13, 600], [45, 480], [2, 600]] as const) {
+ const passes = cloudLoopPasses(clip, want);
+ expect(passes.every((p) => p >= 2 && p <= 5), `${clip} → ${want}`).toBe(true);
+ expect(cloudLoopLength(clip, passes)).toBeGreaterThanOrEqual(want);
+ }
+ });
+});
diff --git a/tests/comfy-faceless-plus.test.ts b/tests/comfy-faceless-plus.test.ts
new file mode 100644
index 00000000..99f0c0b3
--- /dev/null
+++ b/tests/comfy-faceless-plus.test.ts
@@ -0,0 +1,187 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, describe, expect, it } from "vitest";
+import type { GenInput, Operation } from "@/lib/catalog/types";
+import type { ComfyWorkflow, ManifestWorkflow } from "@/lib/comfy";
+import type { MediaInfo } from "@/lib/media-probe";
+import { expandAudioJoinWorkflow, expandVideoJoinWorkflow } from "@/lib/av/joins";
+import { probeMedia } from "@/lib/media-probe";
+
+// The open engine's Ken Burns, loops and joins through the provider (r4/faceless-plus): canonical params →
+// kenburns-still / audio-loop-crossfade / audio-join-crossfade / video-concat-encoded bindings, the crossfade
+// curve the provider writes, and the joins of more clips than the templates bind.
+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-comfy-faceless-plus-"));
+process.env.FUOBE_DATA_DIR = tmp;
+process.env.COMFYUI_URL = "http://comfy.test:8188";
+const { prepareWorkflow, getWorkflow } = await import("@/server/providers/comfyui");
+const { getModel } = await import("@/lib/catalog");
+afterAll(() => fs.rmSync(tmp, { recursive: true, force: true }));
+
+interface Upload {
+ name: string;
+ type: string;
+ data: Buffer;
+}
+
+async function prepare(id: string, input: GenInput, op: Operation, media: Record<string, MediaInfo> = {}) {
+ const uploads: Upload[] = [];
+ const res = await prepareWorkflow(id, { seed: 7, ...input }, {
+ generationId: "gen1",
+ op,
+ upload: async (data, type, name) => {
+ uploads.push({ name, type, data });
+ return `up_${name}`;
+ },
+ media: (name) => media[name],
+ serverRam: async () => undefined,
+ });
+ return { ...res, uploads };
+}
+const at = (wf: ComfyWorkflow, m: ManifestWorkflow, key: string) => (m.bindings[key] ?? []).map((t) => wf[t.node].inputs[t.input]);
+const wav = (duration: number): MediaInfo => ({ container: "wav", hasVideo: false, hasAudio: true, duration });
+
+/** Every link in the graph points at a node that exists, and every node but the save feeds another one. */
+function wellFormed(wf: ComfyWorkflow) {
+ const used = new Set<string>();
+ for (const [id, n] of Object.entries(wf)) {
+ for (const v of Object.values(n.inputs)) {
+ if (Array.isArray(v) && typeof v[0] === "string") {
+ expect(wf[v[0]], `${id} → ${v[0]}`).toBeDefined();
+ used.add(v[0]);
+ }
+ }
+ }
+ const orphans = Object.keys(wf).filter((id) => !used.has(id) && !/^Save/.test(wf[id].class_type));
+ expect(orphans).toEqual([]);
+}
+
+describe("Ken Burns on the open engine (kenburns-still)", () => {
+ it("is the open model's still-motion route", () => {
+ expect(getModel("oss-ken-burns")!.routes).toEqual([expect.objectContaining({ op: "still-motion", provider: "comfyui", endpoint: "kenburns-still" })]);
+ });
+
+ it("maps the move: zoom, crop centre, easing, length, frame rate and the output size", async () => {
+ const { workflow: wf, manifest: m } = await prepare(
+ "kenburns-still",
+ { images: ["still.png"], aspectRatio: "16:9", resolution: "720p", duration: 6, fps: 24, zoomFrom: 1, zoomTo: 1.15, panFrom: { x: 0.5, y: 0.5 }, panTo: { x: 0.435, y: 0.44 }, easing: "ease-in-out" },
+ "still-motion",
+ );
+ const get = (k: string) => at(wf, m, k)[0];
+ expect(get("image")).toBe("still.png");
+ expect([get("zoomStart"), get("zoomEnd"), get("panStartX"), get("panStartY"), get("panEndX"), get("panEndY")]).toEqual([1, 1.15, 0.5, 0.5, 0.435, 0.44]);
+ expect([get("easeInOut"), get("duration"), get("fps"), get("width"), get("height")]).toEqual([1, 6, 24, 1280, 720]);
+ expect(get("filenamePrefix")).toBe("fuobe/gen1");
+ const piece = await prepare("kenburns-still", { images: ["still.png"], aspectRatio: "9:16", resolution: "480p", duration: 7, easing: "linear" }, "still-motion");
+ expect(at(piece.workflow, piece.manifest, "easeInOut")).toEqual([0]);
+ expect([at(piece.workflow, piece.manifest, "width")[0], at(piece.workflow, piece.manifest, "height")[0]]).toEqual([480, 854]);
+ // Without a move the graph's own preset (push in to 1.25) stays.
+ const plain = await prepare("kenburns-still", { images: ["still.png"], duration: 3 }, "still-motion");
+ expect(at(plain.workflow, plain.manifest, "zoomEnd")).toEqual([1.25]);
+ });
+
+ it("refuses more than 10 s in one job (scenes are split before they get here)", async () => {
+ await expect(prepare("kenburns-still", { images: ["still.png"], duration: 12 }, "still-motion")).rejects.toThrow("Ken Burns on the open engine makes up to 10 s per clip — split a longer move into pieces");
+ });
+});
+
+describe("the crossfade curve the provider writes", () => {
+ it("uploads a stereo 16-bit 8 kHz WAV exactly the crossfade long, and binds the crossfade and the bed's length", async () => {
+ const { workflow: wf, manifest: m, uploads } = await prepare("audio-loop-crossfade", { audio: "bed.flac", duration: 301, crossfade: 3 }, "audio-loop", { "bed.flac": wav(240) });
+ expect(uploads.map((u) => [u.name, u.type])).toEqual([["fade_curve.wav", "audio/wav"]]);
+ const curve = uploads[0].data;
+ expect(probeMedia(curve)).toMatchObject({ container: "wav", duration: 3 });
+ const v = new DataView(curve.buffer, curve.byteOffset, curve.byteLength);
+ expect([v.getUint16(22, true), v.getUint32(24, true), v.getUint16(34, true), v.getUint32(40, true)]).toEqual([2, 8000, 16, 24_000 * 4]);
+ // Left fades in from 0, right fades out from full.
+ expect([v.getInt16(44, true), v.getInt16(46, true)]).toEqual([0, 32767]);
+ expect([v.getInt16(44 + 23_999 * 4, true), v.getInt16(46 + 23_999 * 4, true)]).toEqual([32767, 0]);
+ expect(at(wf, m, "fadeCurve")).toEqual(["up_fade_curve.wav"]);
+ expect([at(wf, m, "audio")[0], at(wf, m, "crossfade")[0], at(wf, m, "duration")[0], at(wf, m, "headroomDb")[0]]).toEqual(["bed.flac", 3, 301, -3]);
+ });
+
+ it("writes a linear curve on request, and keeps a curve given in params.extra", async () => {
+ const lin = await prepare("audio-loop-crossfade", { audio: "bed.flac", duration: 30, crossfade: 0.5, extra: { curve: "linear" } }, "audio-loop");
+ const d = lin.uploads[0].data;
+ const v = new DataView(d.buffer, d.byteOffset, d.byteLength);
+ const mid = 2000;
+ expect(v.getInt16(44 + mid * 4, true) + v.getInt16(46 + mid * 4, true)).toBeGreaterThanOrEqual(32766);
+ expect(Object.values(lin.workflow).some((n) => "curve" in n.inputs)).toBe(false);
+ const given = await prepare("audio-loop-crossfade", { audio: "bed.flac", duration: 30, extra: { fadeCurve: "mine.wav" } }, "audio-loop");
+ expect(given.uploads).toEqual([]);
+ expect(at(given.workflow, given.manifest, "fadeCurve")).toEqual(["mine.wav"]);
+ });
+
+ it("refuses a clip too short for the crossfade, and beds over 10 minutes", async () => {
+ await expect(prepare("audio-loop-crossfade", { audio: "a.wav", duration: 30, crossfade: 2 }, "audio-loop", { "a.wav": wav(3) })).rejects.toThrow(/needs a clip longer than 4 s \(this one is 3 s\)/);
+ await expect(prepare("audio-loop-crossfade", { audio: "a.wav", duration: 700, crossfade: 2 }, "audio-loop")).rejects.toThrow("Loops on the open engine run up to 10 minutes (600 s)");
+ });
+});
+
+describe("joins of any number of clips in one prompt", () => {
+ it("joins two audio clips with the template as it is", async () => {
+ const { workflow: wf, manifest: m } = await prepare("audio-join-crossfade", { audios: ["a.wav", "b.wav"], crossfade: 1 }, "audio-join");
+ expect([at(wf, m, "audio")[0], at(wf, m, "audio2")[0], at(wf, m, "crossfade")[0]]).toEqual(["a.wav", "b.wav", 1]);
+ expect(Object.keys(wf)).toEqual(Object.keys(getWorkflow("audio-join-crossfade").workflow));
+ });
+
+ it("folds four clips into one graph: body, seam, middle, seam, middle, seam, rest", async () => {
+ const names = ["a.wav", "b.mp3", "c.flac", "d.wav"];
+ const { workflow: wf } = await prepare("audio-join-crossfade", { audios: names, crossfade: 1.5 }, "audio-join", { "a.wav": wav(10), "b.mp3": wav(8), "c.flac": wav(12), "d.wav": wav(6) });
+ wellFormed(wf);
+ const loaders = Object.entries(wf).filter(([, n]) => /LoadAudio/.test(n.class_type) && n.inputs.audio !== "up_fade_curve.wav");
+ expect(loaders.map(([, n]) => [n.class_type, n.inputs.audio])).toEqual([
+ ["VHS_LoadAudioUpload", "a.wav"],
+ ["VHS_LoadAudioUpload", "b.mp3"],
+ ["VHS_LoadAudioUpload", "c.flac"],
+ ["LoadAudio", "d.wav"],
+ ]);
+ // The concat chain from the save back to the first clip's body.
+ const order: string[] = [];
+ const walk = (id: string) => {
+ const n = wf[id];
+ if (n.class_type !== "AudioConcat") return void order.push(id);
+ walk((n.inputs.audio1 as [string, number])[0]);
+ walk((n.inputs.audio2 as [string, number])[0]);
+ };
+ const save = Object.keys(wf).find((id) => wf[id].class_type === "SaveAudio")!;
+ walk((wf[save].inputs.audio as [string, number])[0]);
+ expect(order).toEqual(["a1_body", "s1_seam", "a2_mid", "s2_seam", "a3_mid", "s3_seam", "a4_rest"]);
+ // A middle clip: from X, as long as the clip minus two crossfades (its length from the VHS loader).
+ expect(wf.a2_mid.inputs.start_index).toEqual(wf.a2_head.inputs.duration);
+ expect(wf[(wf.a2_mid.inputs.duration as [string])[0]].inputs).toMatchObject({ expression: "a - 2 * b", "values.a": ["a2_load", 1] });
+ // A seam: the tail fading out (the curve's right channel) plus the next head fading in (left).
+ expect(wf.s2_out.inputs).toMatchObject({ audio1: ["a2_tail", 0], merge_method: "multiply" });
+ expect(wf.s2_in.inputs).toMatchObject({ audio1: ["a3_head", 0], merge_method: "multiply" });
+ expect([(wf.s2_out.inputs.audio2 as [string, number])[1], (wf.s2_in.inputs.audio2 as [string, number])[1]]).toEqual([1, 0]);
+ expect(wf.s2_seam.inputs).toMatchObject({ audio1: ["s2_out", 0], audio2: ["s2_in", 0], merge_method: "add" });
+ });
+
+ it("refuses a middle clip too short for its two crossfades", async () => {
+ await expect(prepare("audio-join-crossfade", { audios: ["a.wav", "b.wav", "c.wav"], crossfade: 2 }, "audio-join", { "a.wav": wav(10), "b.wav": wav(3), "c.wav": wav(9) })).rejects.toThrow(
+ /^Clip 2 is 3 s, too short for a 2 s crossfade/,
+ );
+ });
+
+ it("joins encoded clips with one loader each, in order, into one ConcatenateVideo", async () => {
+ expect(getModel("oss-join-encoded")!.routes[0]).toMatchObject({ op: "concat", endpoint: "video-concat-encoded" });
+ const two = await prepare("video-concat-encoded", { videos: ["s1.mp4", "s2.mp4"] }, "concat");
+ expect(Object.keys(two.workflow)).toEqual(["1", "2", "3", "4"]);
+ expect([two.workflow["1"].inputs.file, two.workflow["2"].inputs.file]).toEqual(["s1.mp4", "s2.mp4"]);
+ const names = Array.from({ length: 7 }, (_, i) => `s${i + 1}.mp4`);
+ const { workflow: wf } = await prepare("video-concat-encoded", { videos: names }, "concat");
+ wellFormed(wf);
+ const join = Object.values(wf).find((n) => n.class_type === "ConcatenateVideo")!;
+ const wired = Object.entries(join.inputs).filter(([k]) => k.startsWith("videos.")).map(([, v]) => wf[(v as [string])[0]].inputs.file);
+ expect(wired).toEqual(names);
+ expect(join.inputs.codec).toBe("auto");
+ expect(Object.values(wf).find((n) => n.class_type === "SaveVideo")!.inputs.filename_prefix).toBe("fuobe/gen1");
+ await expect(prepare("video-concat-encoded", { videos: ["s1.mp4"] }, "concat")).rejects.toThrow("Add a second clip");
+ });
+
+ it("refuses graphs that aren't joins", () => {
+ expect(() => expandVideoJoinWorkflow(getWorkflow("audio-join-crossfade").workflow, ["a", "b", "c"])).toThrow(/Not a video join workflow/);
+ expect(() => expandAudioJoinWorkflow(getWorkflow("video-concat-encoded").workflow, ["a", "b", "c"])).toThrow(/Not an audio join workflow/);
+ expect(() => expandVideoJoinWorkflow(getWorkflow("video-concat-encoded").workflow, Array.from({ length: 101 }, (_, i) => `${i}`))).toThrow(/up to 100 clips/);
+ });
+});
diff --git a/tests/e2e/comfyui-faceless-plus.mjs b/tests/e2e/comfyui-faceless-plus.mjs
new file mode 100644
index 00000000..e04eef80
--- /dev/null
+++ b/tests/e2e/comfyui-faceless-plus.mjs
@@ -0,0 +1,239 @@
+// End-to-end check of the open engine's Ken Burns, joins and audio loops against a live ComfyUI (r4/faceless-plus).
+// Usage: node tests/e2e/comfyui-faceless-plus.mjs [appUrl] (app running with ComfyUI reachable, demo mode off or nothing else configured)
+// Through Fuobe's own API (/api/uploads → POST /api/generations → poll → download), every graph model-free on CPU:
+// - Ken Burns (oss-ken-burns → kenburns-still): one eased push-in, then one move split into two linear pieces;
+// - the "Frame by frame" join (oss-join-encoded → video-concat-encoded, expanded to three clips): packets copied,
+// the frame count the sum of the clips', and the split move continuous through its seam;
+// - a music bed looped with crossfades (oss-audio-loop → audio-loop-crossfade, the fade curve written by the provider);
+// - three clips joined with crossfades (oss-audio-join → audio-join-crossfade, expanded in one prompt).
+// Every output is probed with ffprobe / ffmpeg; the ComfyUI process's RSS is sampled around the join (local server only).
+import { spawnSync } from "node:child_process";
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import zlib from "node:zlib";
+
+const app = process.argv[2] ?? "http://localhost:3000";
+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-faceless-plus-"));
+for (const tool of ["ffprobe", "ffmpeg"]) if (spawnSync(tool, ["-version"]).status !== 0) throw new Error(`${tool} is needed on PATH`);
+
+function comfyPid() {
+ if (process.env.COMFYUI_PID) return Number(process.env.COMFYUI_PID);
+ const r = spawnSync("pgrep", ["-f", `main.py.*--port ${process.env.COMFYUI_PORT ?? "8188"}`], { encoding: "utf8" });
+ const pid = Number(r.stdout?.split("\n")[0]);
+ return pid && fs.existsSync(`/proc/${pid}/status`) ? pid : null;
+}
+const rssOf = (pid) => Number(/VmRSS:\s+(\d+)/.exec(fs.readFileSync(`/proc/${pid}/status`, "utf8"))?.[1] ?? 0) * 1024;
+async function watchMemory(fn) {
+ const pid = comfyPid();
+ if (!pid) return { result: await fn(), peakGb: null };
+ const base = rssOf(pid);
+ let peak = base;
+ const timer = setInterval(() => {
+ try {
+ peak = Math.max(peak, rssOf(pid));
+ } catch {}
+ }, 50);
+ try {
+ return { result: await fn(), peakGb: (peak - base) / 2 ** 30 };
+ } finally {
+ clearInterval(timer);
+ }
+}
+
+/** A 640x360 still with detail to see a move in: a gradient, a grid and a bright disc right of centre. */
+function still(w = 640, h = 360) {
+ const crcTable = Array.from({ length: 256 }, (_, n) => {
+ let c = n;
+ for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
+ return c >>> 0;
+ });
+ const crc = (buf) => {
+ let c = 0xffffffff;
+ for (const b of buf) c = crcTable[(c ^ b) & 0xff] ^ (c >>> 8);
+ return (c ^ 0xffffffff) >>> 0;
+ };
+ const chunk = (type, data) => {
+ const len = Buffer.alloc(4);
+ len.writeUInt32BE(data.length);
+ const td = Buffer.concat([Buffer.from(type), data]);
+ const c = Buffer.alloc(4);
+ c.writeUInt32BE(crc(td));
+ return Buffer.concat([len, td, c]);
+ };
+ const ihdr = Buffer.alloc(13);
+ ihdr.writeUInt32BE(w, 0);
+ ihdr.writeUInt32BE(h, 4);
+ ihdr[8] = 8;
+ ihdr[9] = 2;
+ const rows = [];
+ for (let y = 0; y < h; y++) {
+ const row = [0];
+ for (let x = 0; x < w; x++) {
+ const grid = x % 40 < 2 || y % 40 < 2;
+ const disc = (x - w * 0.62) ** 2 + (y - h * 0.4) ** 2 < (h * 0.12) ** 2;
+ row.push(disc ? 250 : grid ? 30 : (x * 255) / w, disc ? 220 : grid ? 30 : (y * 255) / h, disc ? 40 : 150);
+ }
+ rows.push(Buffer.from(row));
+ }
+ return Buffer.concat([Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]), chunk("IHDR", ihdr), chunk("IDAT", zlib.deflateSync(Buffer.concat(rows))), chunk("IEND", Buffer.alloc(0))]);
+}
+
+/** Stereo 16-bit PCM WAV: a tone (or noise with freq 0) at 44.1 kHz. */
+function wav(seconds, freq, rate = 44100) {
+ const n = Math.round(seconds * rate);
+ const data = Buffer.alloc(n * 4);
+ for (let i = 0; i < n; i++) {
+ const v = freq ? Math.sin((2 * Math.PI * freq * i) / rate) * 0.3 : (Math.random() * 2 - 1) * 0.2;
+ data.writeInt16LE(Math.round(v * 32767), i * 4);
+ data.writeInt16LE(Math.round(v * 32767), i * 4 + 2);
+ }
+ const h = Buffer.alloc(44);
+ h.write("RIFF", 0);
+ h.writeUInt32LE(36 + data.length, 4);
+ h.write("WAVEfmt ", 8);
+ h.writeUInt32LE(16, 16);
+ h.writeUInt16LE(1, 20);
+ h.writeUInt16LE(2, 22);
+ h.writeUInt32LE(rate, 24);
+ h.writeUInt32LE(rate * 4, 28);
+ h.writeUInt16LE(4, 32);
+ h.writeUInt16LE(16, 34);
+ h.write("data", 36);
+ h.writeUInt32LE(data.length, 40);
+ return Buffer.concat([h, data]);
+}
+
+async function upload(buf, type, name) {
+ const form = new FormData();
+ form.append("file", new Blob([buf], { type }), name);
+ const res = await fetch(`${app}/api/uploads`, { method: "POST", body: form });
+ const up = await res.json();
+ if (!res.ok) throw new Error(`upload ${name}: ${up.error}`);
+ return up.url;
+}
+
+async function generate(label, body, kind) {
+ const res = await fetch(`${app}/api/generations`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ feature: "selftest", ...body }) });
+ const created = await res.json();
+ if (!res.ok) throw new Error(`${label}: ${created.error}`);
+ const id = created.items[0].id;
+ const t0 = Date.now();
+ for (;;) {
+ const g = await (await fetch(`${app}/api/generations/${id}`)).json();
+ if (g.status === "succeeded") {
+ if (g.provider !== "comfyui") throw new Error(`${label} ran on ${g.provider}, not ComfyUI`);
+ const out = g.outputs.find((o) => o.kind === kind);
+ if (!out) throw new Error(`${label}: no ${kind} output (${g.outputs.map((o) => o.kind)})`);
+ const bytes = Buffer.from(await (await fetch(`${app}${out.url}`)).arrayBuffer());
+ const local = path.join(tmp, `${label}${path.extname(new URL(out.url, app).pathname)}`);
+ fs.writeFileSync(local, bytes);
+ console.log(`✓ ${label} (${body.modelId}): ${kind} ${bytes.length} B in ${Date.now() - t0} ms`);
+ return { url: out.url, local, ms: Date.now() - t0 };
+ }
+ if (g.status === "failed" || g.status === "canceled") throw new Error(`${label}: ${g.status} — ${g.error}`);
+ if (Date.now() - t0 > 600_000) throw new Error(`${label}: timed out (${g.status} ${g.message ?? ""})`);
+ await new Promise((r) => setTimeout(r, 1000));
+ }
+}
+
+function probe(file) {
+ const r = spawnSync("ffprobe", ["-v", "error", "-count_frames", "-show_entries", "stream=codec_type,codec_name,width,height,r_frame_rate,nb_read_frames,sample_rate,channels:format=duration", "-of", "json", file], { encoding: "utf8" });
+ if (r.status !== 0) throw new Error(`ffprobe ${file}: ${r.stderr}`);
+ const j = JSON.parse(r.stdout);
+ const v = j.streams.find((s) => s.codec_type === "video");
+ const a = j.streams.find((s) => s.codec_type === "audio");
+ const [num, den] = (v?.r_frame_rate ?? "0/1").split("/").map(Number);
+ return {
+ duration: Number(j.format?.duration ?? 0),
+ video: v ? { codec: v.codec_name, width: v.width, height: v.height, fps: num / (den || 1), frames: Number(v.nb_read_frames) } : null,
+ audio: a ? { codec: a.codec_name, rate: Number(a.sample_rate), channels: a.channels } : null,
+ };
+}
+
+function check(label, cond, detail) {
+ if (!cond) throw new Error(`${label}: ${detail}`);
+ console.log(` ${label}: ${detail}`);
+}
+
+/** Gray pixels of frame `n` (0-based). */
+function frame(file, n) {
+ const r = spawnSync("ffmpeg", ["-v", "error", "-i", file, "-vf", `select=eq(n\\,${n})`, "-frames:v", "1", "-f", "rawvideo", "-pix_fmt", "gray", "-"], { maxBuffer: 64 * 2 ** 20 });
+ if (r.status !== 0) throw new Error(`ffmpeg frame ${n} of ${file}: ${r.stderr}`);
+ return r.stdout;
+}
+const meanDiff = (a, b) => a.reduce((n, v, i) => n + Math.abs(v - b[i]), 0) / a.length;
+
+/** RMS level (dB) of a stretch of an audio file, and the largest sample-to-sample step in it. */
+function level(file, start, seconds) {
+ const r = spawnSync("ffmpeg", ["-v", "error", "-ss", String(start), "-t", String(seconds), "-i", file, "-ac", "1", "-f", "f32le", "-"], { maxBuffer: 256 * 2 ** 20 });
+ if (r.status !== 0) throw new Error(`ffmpeg audio ${file}: ${r.stderr}`);
+ const s = new Float32Array(r.stdout.buffer, r.stdout.byteOffset, r.stdout.length / 4);
+ let sum = 0;
+ let step = 0;
+ for (let i = 0; i < s.length; i++) {
+ sum += s[i] * s[i];
+ if (i) step = Math.max(step, Math.abs(s[i] - s[i - 1]));
+ }
+ return { db: 10 * Math.log10(sum / Math.max(1, s.length) + 1e-12), step };
+}
+
+async function kenBurnsAndJoin() {
+ const image = await upload(still(), "image/png", "kenburns-still.png");
+ const base = { op: "still-motion", modelId: "oss-ken-burns", inputs: { images: [image] }, params: { aspectRatio: "16:9", resolution: "480p", fps: 24 } };
+ // A 2 s eased push-in toward the disc, then a 3 s pan split into 2 s + 1 s linear pieces of one move.
+ const push = await generate("ken-burns push-in", { ...base, params: { ...base.params, duration: 2, zoomFrom: 1, zoomTo: 1.2, panFrom: { x: 0.5, y: 0.5 }, panTo: { x: 0.583, y: 0.417 }, easing: "ease-in-out" } }, "video");
+ // As splitMove cuts it (src/lib/av/ken-burns.ts): 72 frames, piece 1 shows frames 0–47 of the move, piece 2 frames 48–71.
+ const pan = { zoom: 1.2, from: 0.417, to: 0.583 };
+ const x = (frame) => Math.round((pan.from + ((pan.to - pan.from) * frame) / 71) * 1e5) / 1e5;
+ const a = await generate("ken-burns piece 1", { ...base, params: { ...base.params, duration: 2, zoomFrom: pan.zoom, zoomTo: pan.zoom, panFrom: { x: x(0), y: 0.5 }, panTo: { x: x(47), y: 0.5 }, easing: "linear" } }, "video");
+ const b = await generate("ken-burns piece 2", { ...base, params: { ...base.params, duration: 1, zoomFrom: pan.zoom, zoomTo: pan.zoom, panFrom: { x: x(48), y: 0.5 }, panTo: { x: x(71), y: 0.5 }, easing: "linear" } }, "video");
+ const pp = probe(push.local);
+ check("push-in", pp.video?.width === 854 && pp.video.height === 480 && pp.video.frames === 48 && Math.abs(pp.video.fps - 24) < 0.01, JSON.stringify(pp));
+ // The eased move barely moves at its ends and moves most in the middle.
+ const f = (n) => frame(push.local, n);
+ const [start, early, centre, late, end] = [f(0), f(2), f(23), f(25), f(47)];
+ check("eased push-in", meanDiff(start, early) < meanDiff(centre, late), `start step ${meanDiff(start, early).toFixed(2)} < middle step ${meanDiff(centre, late).toFixed(2)}; first vs last ${meanDiff(start, end).toFixed(1)}`);
+
+ const { result: joined, peakGb } = await watchMemory(() => generate("join (3 clips, packet copy)", { modelId: "oss-join-encoded", op: "concat", inputs: { videos: [push.url, a.url, b.url] } }, "video"));
+ const pj = probe(joined.local);
+ check("join", pj.video?.frames === 48 + 48 + 24 && pj.video.width === 854 && Math.abs(pj.duration - 5) < 0.1, `${pj.video?.frames} frames, ${pj.duration.toFixed(3)} s, ${pj.video?.codec}${peakGb === null ? "" : `, ComfyUI RSS +${peakGb.toFixed(2)} GB`}`);
+ // Packet copy: the joined frames are the clips' own frames.
+ check("frames copied", meanDiff(frame(joined.local, 50), frame(a.local, 2)) < 0.5 && meanDiff(frame(joined.local, 100), frame(b.local, 4)) < 0.5, "frames 50 and 100 of the join equal frames 2 and 4 of the pieces");
+ // The split move goes on at the same speed through the seam between its pieces (frames 95 | 96).
+ const steps = [93, 94, 95, 96, 97].map((n) => meanDiff(frame(joined.local, n), frame(joined.local, n + 1)));
+ const spread = Math.max(...steps) / Math.max(1e-6, Math.min(...steps));
+ check("split move", spread < 3, `frame-to-frame change around the seam ${steps.map((s) => s.toFixed(2)).join(", ")}`);
+}
+
+async function audio() {
+ const bed = await upload(wav(6, 220), "audio/wav", "bed.wav");
+ const loop = await generate("loop 6 s → 20 s, 1 s crossfades", { modelId: "oss-audio-loop", op: "audio-loop", inputs: { audio: bed }, params: { duration: 20, crossfade: 1 } }, "audio");
+ const pl = probe(loop.local);
+ check("loop", Math.abs(pl.duration - 20) < 0.05 && pl.audio?.rate === 44100 && pl.audio.channels === 2, `${pl.audio?.codec} ${pl.duration.toFixed(3)} s ${pl.audio?.rate} Hz`);
+ const seam = level(loop.local, 4.8, 1.4);
+ const body = level(loop.local, 2, 2);
+ check("loop seams", seam.step < body.step * 2 && Math.abs(seam.db - body.db) < 4, `seam ${seam.db.toFixed(1)} dB / step ${seam.step.toFixed(3)}; body ${body.db.toFixed(1)} dB / step ${body.step.toFixed(3)}`);
+ const tail = level(loop.local, 19.9, 0.1);
+ check("loop fade-out", tail.db < body.db - 12, `last 0.1 s at ${tail.db.toFixed(1)} dB`);
+
+ const clips = await Promise.all([
+ upload(wav(4, 330), "audio/wav", "one.wav"),
+ upload(wav(3, 0), "audio/wav", "two.wav"),
+ upload(wav(5, 550, 48000), "audio/wav", "three.wav"),
+ ]);
+ const joined = await generate("join 4 s + 3 s + 5 s, 0.5 s crossfades", { modelId: "oss-audio-join", op: "audio-join", inputs: { audios: clips }, params: { crossfade: 0.5 } }, "audio");
+ const pj = probe(joined.local);
+ check("audio join", Math.abs(pj.duration - 11) < 0.05 && pj.audio?.rate === 48000, `${pj.audio?.codec} ${pj.duration.toFixed(3)} s at ${pj.audio?.rate} Hz (4 + 3 + 5 − 2 × 0.5)`);
+ const [one, two, three] = [level(joined.local, 1, 2), level(joined.local, 4.6, 1.5), level(joined.local, 8, 2)];
+ check("audio join order", one.db > two.db && three.db > two.db, `tone ${one.db.toFixed(1)} dB, noise ${two.db.toFixed(1)} dB, tone ${three.db.toFixed(1)} dB`);
+}
+
+try {
+ await kenBurnsAndJoin();
+ await audio();
+ console.log(`\nAll Faceless+ open-engine checks passed (files in ${tmp}).`);
+} catch (e) {
+ console.error(`✗ ${e.message}`);
+ process.exitCode = 1;
+}
diff --git a/workflows/comfyui/manifest.json b/workflows/comfyui/manifest.json
index 56b441d5..ccc9f42b 100644
--- a/workflows/comfyui/manifest.json
+++ b/workflows/comfyui/manifest.json
@@ -1,6 +1,6 @@
{
"version": 1,
- "generatedAt": "2026-10-23T00:20:02.191Z",
+ "generatedAt": "2026-10-23T01:05:11.311Z",
"comfyuiCommit": "fc04da91b2ab12f99e4716371a7e4f98ac982597",
"comfyuiVersion": "0.41.0",
"workflowTemplatesVersion": "0.11.86",
@@ -12555,6 +12555,50 @@
"validated": true,
"notes": "The still-motion operation: params.zoomFrom / zoomTo -> zoomStart / zoomEnd (1 = the widest crop with the output's shape, 1.25 = 25 % closer), params.panFrom / panTo {x, y} -> panStartX/Y and panEndX/Y (the crop centre, 0-1 of the still, clamped so the crop stays inside), params.easing \"ease-in-out\" -> easeInOut 1 ((1 - cos(pi t)) / 2), \"linear\" -> 0; duration, fps and width x height (the output size) as usual. Presets (app side): push in zoom 1 -> 1.2; pull out 1.2 -> 1; pan left zoom 1.15, x 0.6 -> 0.4; pan up zoom 1.15, y 0.6 -> 0.4; a gentle end-card push-in 1 -> 1.05. Core loops (StartLoop/EndLoop, ComfyUI 2026-09-15): the outer loop runs one pass per chunk of chunkFrames frames, the inner loop crops each frame (ImageCrop) and scales it (lanczos) to width x height, each chunk is encoded at once (CreateVideo h264) and ConcatenateVideo joins them, so finished chunks can leave memory. supersample upsizes the still once so crop steps are half a source pixel. At most 10 s per job: RAM still grows by about one output frame per frame (~11 MB at 720p) until ComfyUI's RAM-pressure cache evicts chunks; split longer scenes. Changed from the research graph: easeInOut (node 19) blends linear and eased progress (the research graph was always eased). Research runs (4-core CPU): 2 s 640x360 25 fps 17.9 s; 5 s 1280x720 30 fps 75.6 s (+2.6 GB RSS); 10 s 1280x720 30 fps 142.1 s (+3.7 GB RSS, both under RAM pressure). Ran here (shared CPU server, two sessions, 64x64 still, 2 s 320x180 25 fps, chunks of 20): 50 frames, 2.000 s H.264 in 8.5-9.3 s (easeInOut 1) and 7.6-11.2 s (0); the two match at the first, middle and last frame and differ in between, and the eased one barely moves over its first and last frames. Crops are whole pixels, so a tiny still steps visibly (the first frame after zoom 1 jumps by one source pixel); supersample and a still larger than the output hide it."
},
+ {
+ "id": "video-concat-encoded",
+ "title": "Join clips the open engine encoded, packet by packet in constant memory (core ConcatenateVideo, no decode)",
+ "capability": "concat",
+ "file": "video-concat-encoded.json",
+ "source": "hand-built (scripts/comfy/hand-built/video-concat-encoded.json)",
+ "bindings": {
+ "video": [
+ {
+ "node": "1",
+ "input": "file"
+ }
+ ],
+ "video2": [
+ {
+ "node": "2",
+ "input": "file"
+ }
+ ],
+ "filenamePrefix": [
+ {
+ "node": "4",
+ "input": "filename_prefix"
+ }
+ ]
+ },
+ "outputs": [
+ {
+ "node": "4",
+ "kind": "video"
+ }
+ ],
+ "defaults": {},
+ "limits": {
+ "maxClips": 100
+ },
+ "models": [],
+ "customNodes": [],
+ "vramGb": 0,
+ "license": "n/a (no model; ComfyUI core)",
+ "validated": true,
+ "notes": "The Faceless / Explainer \"Frame by frame\" join (r4/faceless-plus): the Ken Burns scenes (kenburns-still, and the pieces of scenes over 10 s), and joins of those joins, one after another in input order. The template joins two clips (video, video2); the provider rewrites it per request (expand \"videos\", expandVideoJoinWorkflow): one LoadVideo per inputs.videos entry, wired to ConcatenateVideo videos.video0..N-1 (at most 100). ConcatenateVideo copies the encoded packets when every clip has the same codec, extradata, size, bit depth, colour space and sound layout (clips ComfyUI's CreateVideo / SaveVideo made at one size and fps), so RAM stays flat however long the film is (video-concat-{2,3,4} decode every frame as float32: about 11 MB a frame at 720p, 20 GB for a 60 s film at 30 fps); otherwise it re-encodes one clip at a time to the first clip's settings (still constant memory), and clips of different sizes fail with \"could not be encoded compatibly\". Unlike video-concat-{2,3,4} it neither scales, crops nor retimes: the clips must share one size and frame rate. Sound tracks are kept as they are (the Ken Burns clips have none; the mux adds the voice and the bed).",
+ "expand": "videos"
+ },
{
"id": "audio-loop-crossfade",
"title": "Music bed of any length: loop a clip with equal-power crossfades and a fade-out (core audio nodes + core loop)",
@@ -12683,7 +12727,8 @@
"vramGb": 0,
"license": "n/a (no model; ComfyUI core audio nodes; VideoHelperSuite loader, GPL-3.0 code)",
"validated": true,
- "notes": "audio then audio2, overlapped by crossfade seconds (params.crossfade, > 0; 0.02 gives a click-free hard join). fadeCurve = the same curve WAV as audio-loop-crossfade, crossfade seconds long, written by the provider. More clips (params.audios in order): fold, i.e. join 1+2, then that result + 3, and so on. The output runs at the higher sample rate of the two (AudioConcat resamples) and is saved as FLAC. Clips placed at exact times are audio-timeline's job. Ran here (CPU, two sessions): 3 s 44.1 kHz tones + 2 s 48 kHz noise, crossfade 0.5 s -> FLAC 4.500 s at 48 kHz stereo in 0.2-2.1 s; the tones keep their level (-9.0 dB RMS) up to 2.5 s, the overlap ramps over 0.5 s and the noise follows at its own level (-15.2 dB): no headroom is taken off here."
+ "notes": "audio then audio2, overlapped by crossfade seconds (params.crossfade, > 0; 0.02 gives a click-free hard join). fadeCurve = the same curve WAV as audio-loop-crossfade, crossfade seconds long, written by the provider. More clips (params.audios in order): the provider rewrites the graph for all of them in one prompt (expand \"audios\", expandAudioJoinWorkflow, r4/faceless-plus): every clip but the last is read by a VHS loader (for its length), the first gives its body, each middle clip its head, middle and tail, the last its head and the rest, and each seam is tail x fade-out + next head x fade-in, all concatenated in order; middle clips must be longer than 2 x crossfade. The output runs at the highest sample rate of the clips (AudioConcat resamples) and is saved as FLAC. Clips placed at exact times are audio-timeline's job. Ran here (CPU, two sessions): 3 s 44.1 kHz tones + 2 s 48 kHz noise, crossfade 0.5 s -> FLAC 4.500 s at 48 kHz stereo in 0.2-2.1 s; the tones keep their level (-9.0 dB RMS) up to 2.5 s, the overlap ramps over 0.5 s and the noise follows at its own level (-15.2 dB): no headroom is taken off here.",
+ "expand": "audios"
},
{
"id": "video-export-pro",
diff --git a/workflows/comfyui/video-concat-encoded.json b/workflows/comfyui/video-concat-encoded.json
new file mode 100644
index 00000000..5dcedbe3
--- /dev/null
+++ b/workflows/comfyui/video-concat-encoded.json
@@ -0,0 +1,53 @@
+{
+ "1": {
+ "class_type": "LoadVideo",
+ "inputs": {
+ "file": "clip1.mp4"
+ },
+ "_meta": {
+ "title": "Clip 1 (video; copied, not decoded, when the clips match)"
+ }
+ },
+ "2": {
+ "class_type": "LoadVideo",
+ "inputs": {
+ "file": "clip2.mp4"
+ },
+ "_meta": {
+ "title": "Clip 2 (the provider adds one loader per further clip)"
+ }
+ },
+ "3": {
+ "class_type": "ConcatenateVideo",
+ "inputs": {
+ "videos.video0": [
+ "1",
+ 0
+ ],
+ "videos.video1": [
+ "2",
+ 0
+ ],
+ "codec": "auto"
+ },
+ "_meta": {
+ "title": "Concatenate Video (packet copy for matching clips, else one clip at a time is re-encoded)"
+ }
+ },
+ "4": {
+ "class_type": "SaveVideo",
+ "inputs": {
+ "video": [
+ "3",
+ 0
+ ],
+ "filename_prefix": "fuobe/video-concat-encoded",
+ "format": "auto",
+ "format.codec": "auto",
+ "codec": "auto"
+ },
+ "_meta": {
+ "title": "Save Video"
+ }
+ }
+}