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.

Faceless: no loop for a bed that already covers the film

Claude44a4c1b0d33f
diff --git a/src/lib/catalog/faceless.ts b/src/lib/catalog/faceless.ts
index b69dd409..8a161528 100644
--- a/src/lib/catalog/faceless.ts
+++ b/src/lib/catalog/faceless.ts
@@ -883,8 +883,10 @@ export interface MusicPlan {
*/
export function musicPlan(music: ModelDef | undefined, loop: ModelDef | undefined, seconds: number): MusicPlan {
const bed = musicLength(music, seconds);
+ // The bed runs a second past the film when it can; one that only misses that second needs no loop (a whole
+ // second play of Sonilo's 600 s for a 600 s film would be a call for nothing).
+ if (bed >= seconds || !loop) return { bed, loop: null, short: Math.max(0, Math.ceil(seconds - bed)) };
const need = Math.ceil(seconds) + 1;
- if (bed >= need || !loop) return { bed, loop: null, short: Math.max(0, Math.ceil(seconds - bed)) };
const duration = Math.min(LOOP_MAX[loop.id] ?? Infinity, need);
// A route that only repeats the clip (fal merge-audios) plays it whole; ComfyUI crossfades each seam.
const repeats = loop.routes.some((r) => r.op === "audio-loop" && !!r.map?.loop);
diff --git a/tests/faceless.test.ts b/tests/faceless.test.ts
index 134f3169..b6a67294 100644
--- a/tests/faceless.test.ts
+++ b/tests/faceless.test.ts
@@ -570,6 +570,10 @@ describe("pictures from sources, style references, music length, frame pricing",
expect(musicPlan(sonilo, cloudLoop, 300)).toEqual({ bed: 301, loop: null, short: 0 });
expect(musicPlan(sonilo, cloudLoop, 650)).toEqual({ bed: 600, loop: { duration: 651, plays: 2 }, short: 0 });
expect(musicPlan(ace, undefined, 300)).toEqual({ bed: 240, loop: null, short: 60 });
+ // A bed that covers the film but not the second after it is not looped.
+ expect(musicPlan(sonilo, cloudLoop, 600)).toEqual({ bed: 600, loop: null, short: 0 });
+ expect(musicPlan(ace, openLoop, 240)).toEqual({ bed: 240, loop: null, short: 0 });
+ expect(musicPlan(ace, openLoop, 240.4)).toEqual({ bed: 240, loop: { duration: 242, crossfade: 3 }, short: 0 });
// A five-minute open episode: ACE-Step's 240 s bed, looped to the film with 3 s crossfades, under the voice.
const open = graphFor({ engine: "open", music: true, voice: null }, placeholderBlocks(300));