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.

Original sound: the studios' notes keep dB in their words, API tests, and a browser check of every studio

Claudea2c30834ff44
diff --git a/src/lib/av/original-sound.ts b/src/lib/av/original-sound.ts
index f841c70a..3b03e42a 100644
--- a/src/lib/av/original-sound.ts
+++ b/src/lib/av/original-sound.ts
@@ -74,6 +74,12 @@ export function soundSummary(c?: SoundChoice | null): string {
return originalSoundLabel(s);
}
+/** The same, lower-cased for the middle of a sentence ("music & effects only"; dB keeps its case). */
+export const soundLine = (c?: SoundChoice | null): string => {
+ const s = soundSummary(c);
+ return s[0].toLowerCase() + s.slice(1);
+};
+
/** The mux's sound: what it waits on (after/chain), the file it reads (inputs.audio) and its extra settings. */
export interface SoundBack {
after: string[];
diff --git a/src/server/genjutsu.ts b/src/server/genjutsu.ts
index 92ee8273..870ec4bd 100644
--- a/src/server/genjutsu.ts
+++ b/src/server/genjutsu.ts
@@ -1,5 +1,5 @@
import "server-only";
-import { originalSoundProblem, separates, soundSummary, type SoundChoice } from "@/lib/av/original-sound";
+import { originalSoundProblem, separates, soundLine, type SoundChoice } from "@/lib/av/original-sound";
import { SoundChoiceSchema } from "./shorts-schemas";
import { z } from "zod";
import { getModel } from "@/lib/catalog";
@@ -225,7 +225,7 @@ async function planInput(body: GenjutsuBody, opts: { probe: boolean }): Promise<
const notes = [...switched.notes, ...notesFor({ ...body, character: switched.character }, maker, source, range, n, references.length)];
const split = separates(maker.engine, body.sound) && source.hasAudio;
- if (split) notes.push(`Original sound: ${soundSummary(body.sound).toLowerCase()} — your GPU splits the clip's sound first (free)`);
+ if (split) notes.push(`Original sound: ${soundLine(body.sound)} — your GPU splits the clip's sound first (free)`);
const name = (body.source.name ?? "").replace(/\.[a-z0-9]{2,4}$/i, "").trim().slice(0, 40);
const title = genjutsuTitle({ mode: body.mode, subject: body.subject, look: body.look });
return {
diff --git a/src/server/mixed-media.ts b/src/server/mixed-media.ts
index d2b1d0db..4d6fe6ed 100644
--- a/src/server/mixed-media.ts
+++ b/src/server/mixed-media.ts
@@ -1,5 +1,5 @@
import "server-only";
-import { originalSoundProblem, separates, soundSummary, type SoundChoice } from "@/lib/av/original-sound";
+import { originalSoundProblem, separates, soundLine, type SoundChoice } from "@/lib/av/original-sound";
import { getModel } from "@/lib/catalog";
import {
clampFps,
@@ -179,7 +179,7 @@ async function planInput(body: MixedBody, opts: { probe: boolean }): Promise<{ i
const soundProblem = originalSoundProblem(body.engine, body.sound);
if (soundProblem) throw new ShortsError(soundProblem, 422);
const split = separates(body.engine, body.sound) && info.hasAudio !== false;
- if (split) notes.push(`Original sound: ${soundSummary(body.sound).toLowerCase()} — your GPU splits the clip's sound first (free)`);
+ if (split) notes.push(`Original sound: ${soundLine(body.sound)} — your GPU splits the clip's sound first (free)`);
const name = (body.source.name ?? "").replace(/\.[a-z0-9]{2,4}$/i, "").trim().slice(0, 40);
return {
frames,
diff --git a/src/server/remove-object.ts b/src/server/remove-object.ts
index b6e4fdfa..71b135ed 100644
--- a/src/server/remove-object.ts
+++ b/src/server/remove-object.ts
@@ -1,5 +1,5 @@
import "server-only";
-import { originalSoundProblem, separates, soundSummary, type SoundChoice } from "@/lib/av/original-sound";
+import { originalSoundProblem, separates, soundLine, type SoundChoice } from "@/lib/av/original-sound";
import { SoundChoiceSchema } from "./shorts-schemas";
import { z } from "zod";
import { getModel } from "@/lib/catalog";
@@ -228,7 +228,7 @@ async function planInput(body: RemovalBody, opts: { probe: boolean; preview?: bo
const soundProblem = originalSoundProblem(eraser.engine, body.sound);
if (soundProblem) throw new ShortsError(soundProblem, 422);
const split = separates(eraser.engine, body.sound) && !!source.hasAudio;
- if (split) notes.push(`Original sound: ${soundSummary(body.sound).toLowerCase()} — your GPU splits the clip's sound first (free)`);
+ if (split) notes.push(`Original sound: ${soundLine(body.sound)} — your GPU splits the clip's sound first (free)`);
const name = (body.source.name ?? "").replace(/\.[a-z0-9]{2,4}$/i, "").trim().slice(0, 40);
const title = removalTitle({ mode: body.mode, prompt: body.prompt, everyone: eraser.everyone });
diff --git a/src/server/shorts.ts b/src/server/shorts.ts
index 018ed32e..599049e8 100644
--- a/src/server/shorts.ts
+++ b/src/server/shorts.ts
@@ -35,7 +35,7 @@ import {
type TakeKeys,
} from "@/lib/catalog/shorts";
import type { Engine, Generation } from "@/lib/catalog/types";
-import { originalSoundProblem, separates, soundSummary, type SoundChoice } from "@/lib/av/original-sound";
+import { originalSoundProblem, separates, soundLine, type SoundChoice } from "@/lib/av/original-sound";
import { createPipeline } from "./chains";
import { db } from "./db";
import { getGeneration, previewChained } from "./generations";
@@ -336,7 +336,7 @@ function notesFor(input: ShortsPlanInput, segments: number): string[] {
if (vaceDownsample(fps)) notes.push(`Wan 2.2 Fun VACE works this ${Math.round(fps!)} fps clip at ${Math.round(fps! / (vaceDownsample(fps) + 1))} fps and brings it back to its own rate`);
} else notes.push("Fuobe Shorts on your GPU renders 480p at 16 fps, 5 s a segment");
}
- if (separates(input.engine, input.sound) && input.source.hasAudio !== false) notes.push(`Original sound: ${soundSummary(input.sound).toLowerCase()} — your GPU splits the clip's sound first (DBS, free)`);
+ if (separates(input.engine, input.sound)) notes.push(`Original sound: ${soundLine(input.sound)} — your GPU splits the clip's sound first (free)`);
if (input.engine === "cloud") {
const { width: w, height: h } = input.source;
if (!input.reframes && w && h && needsFit(input.source, input.aspectRatio)) notes.push(`Your ${w}×${h} clip is centre-cropped to ${input.aspectRatio} before the restyle`);
diff --git a/tests/e2e/original-sound.mjs b/tests/e2e/original-sound.mjs
new file mode 100644
index 00000000..757ce4bc
--- /dev/null
+++ b/tests/e2e/original-sound.mjs
@@ -0,0 +1,210 @@
+// Browser check of the "Original sound" choice (DBS D7) in Shorts, Mixed Media, Genjutsu and Remove object, and
+// Faceless's "Use a clip's soundtrack as the bed".
+// Usage: node tests/e2e/original-sound.mjs [appUrl] [outDir] (the app in demo mode: no keys, no ComfyUI)
+// Character Swap Studio's Assemble stage too.
+// Checks, at 1440 px and 390 px in light and dark: on the open engine the setting lists Everything, Music & effects only,
+// Dialogue only and Lower the music (with its level slider), and Genjutsu's Character swap suggests Music & effects
+// only; on the cloud it reads Everything with the line that the other choices run on your GPU; no sideways scroll and
+// no console errors. Screenshots go to outDir.
+import { spawnSync } from "node:child_process";
+import fs from "node:fs";
+import path from "node:path";
+import { DESKTOP, PHONE, launch, openRoute } from "./_browser.mjs";
+
+const args = process.argv.slice(2).filter((a) => !a.startsWith("--"));
+const app = args[0] ?? "http://localhost:3000";
+const out = args[1] ?? fs.mkdtempSync("/tmp/fuobe-original-sound-");
+fs.mkdirSync(out, { recursive: true });
+
+// An 8 s 9:16 video with a tone as its soundtrack.
+const mp4 = path.join(out, "sound-source.mp4");
+const r = spawnSync("ffmpeg", ["-hide_banner", "-loglevel", "error", "-y", "-f", "lavfi", "-i", "testsrc2=s=360x640:r=24:d=8", "-f", "lavfi", "-i", "sine=f=330:d=8", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", "-shortest", mp4]);
+if (r.status !== 0) throw new Error(`ffmpeg failed: ${r.stderr}`);
+
+const failures = [];
+const check = (ok, what) => {
+ console.log(`${ok ? "✓" : "✗"} ${what}`);
+ if (!ok) failures.push(what);
+};
+const noSideScroll = async (page, label) => {
+ const over = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
+ check(over <= 0, `${label}: no horizontal scroll (${over}px)`);
+};
+const setup = async (browser, device, theme, engine) => {
+ const ctx = await browser.newContext({ ...device, colorScheme: theme });
+ await ctx.addInitScript(([e]) => localStorage.setItem("fuobe.engine", e), [engine]);
+ await ctx.route((u) => u.origin !== new URL(app).origin && /^https?:$/.test(u.protocol), (rt) => rt.abort());
+ return ctx;
+};
+const watchErrors = (page, label) => {
+ page.on("console", (m) => {
+ if (m.type() === "error" && !/Failed to load resource/.test(m.text())) check(false, `${label}: console error: ${m.text().slice(0, 200)}`);
+ });
+ page.on("pageerror", (e) => check(false, `${label}: page error: ${e.message.slice(0, 200)}`));
+};
+
+const ONLY = process.env.ONLY;
+const STUDIOS = [
+ { name: "shorts", url: "/shorts", upload: true },
+ { name: "mixed-media", url: "/mixed-media", upload: true },
+ { name: "genjutsu", url: "/genjutsu", upload: true },
+ { name: "remove-object", url: "/video-tools/remove-object", upload: true },
+];
+
+const field = (page) => page.getByTestId("original-sound");
+
+const browser = await launch();
+try {
+ for (const [dname, device] of [
+ ["1440", DESKTOP],
+ ["390", PHONE],
+ ]) {
+ for (const theme of ["light", "dark"]) {
+ for (const s of STUDIOS.filter((x) => !ONLY || ONLY === x.name)) {
+ for (const engine of ["open", "cloud"]) {
+ const label = `${s.name} ${engine} ${dname} ${theme}`;
+ const ctx = await setup(browser, device, theme, engine);
+ const page = await ctx.newPage();
+ watchErrors(page, label);
+ await openRoute(page, `${app}${s.url}`);
+ if (s.upload) await page.locator('input[type="file"][accept*="video"], input[type="file"]').first().setInputFiles(mp4);
+ const f = field(page);
+ try {
+ await f.waitFor({ timeout: 30_000 });
+ } catch {
+ check(false, `${label}: the Original sound setting shows`);
+ await page.screenshot({ path: path.join(out, `${s.name}-${engine}-${dname}-${theme}-missing.png`), fullPage: true });
+ await ctx.close();
+ continue;
+ }
+ await f.scrollIntoViewIfNeeded();
+ const combo = f.getByRole("combobox");
+ check((await combo.innerText()).includes("Everything"), `${label}: starts on Everything`);
+ if (engine === "cloud") {
+ check(await f.getByText(/run on your GPU \(open source\)\. The cloud puts the whole sound back\./).isVisible(), `${label}: the cloud says the other choices run on your GPU`);
+ await combo.click();
+ const off = page.getByRole("option", { name: /Dialogue only/ });
+ check((await off.getAttribute("aria-disabled")) === "true" || (await off.getAttribute("data-disabled")) !== null, `${label}: Dialogue only is turned off on the cloud`);
+ await page.keyboard.press("Escape");
+ } else {
+ await combo.click();
+ for (const o of ["Everything", "Music & effects only", "Dialogue only", "Lower the music"]) check(await page.getByRole("option", { name: new RegExp(o) }).isVisible(), `${label}: offers ${o}`);
+ await page.getByRole("option", { name: /Lower the music/ }).click();
+ check(await f.getByRole("slider", { name: "Music and effects level" }).isVisible(), `${label}: Lower the music shows its level`);
+ check(await f.getByText("−12 dB").isVisible(), `${label}: the level starts at −12 dB`);
+ }
+ await page.waitForTimeout(400);
+ await f.screenshot({ path: path.join(out, `${s.name}-${engine}-${dname}-${theme}.png`) });
+ await noSideScroll(page, label);
+ await ctx.close();
+ }
+ }
+ // Genjutsu's Character swap suggests Music & effects only on your GPU.
+ {
+ const label = `genjutsu character open ${dname} ${theme}`;
+ const ctx = await setup(browser, device, theme, "open");
+ const page = await ctx.newPage();
+ watchErrors(page, label);
+ await openRoute(page, `${app}/genjutsu?mode=character`);
+ const tab = page.getByRole("tab", { name: /Character swap/ }).or(page.getByRole("radio", { name: /Character swap/ })).or(page.getByRole("button", { name: /^Character swap/ }));
+ if (await tab.count()) await tab.first().click();
+ await page.locator('input[type="file"]').first().setInputFiles(mp4);
+ const f = field(page);
+ await f.waitFor({ timeout: 30_000 }).catch(() => {});
+ if (await f.count()) {
+ check((await f.getByRole("combobox").innerText()).includes("Music & effects only"), `${label}: suggests Music & effects only`);
+ await f.screenshot({ path: path.join(out, `genjutsu-character-${dname}-${theme}.png`) });
+ } else check(false, `${label}: the Original sound setting shows`);
+ await noSideScroll(page, label);
+ await ctx.close();
+ }
+ }
+ }
+ // Faceless: "Use a clip's soundtrack as the bed" under Background music (a channel per engine, made through the API).
+ for (const engine of ["open", "cloud"]) {
+ const res = await fetch(`${app}/api/faceless/channels`, { method: "POST", headers: { "content-type": "application/json", origin: app }, body: JSON.stringify({ idea: "Tides explained", genre: "education", engine, name: `Tides ${engine}` }) });
+ const channel = await res.json();
+ if (!res.ok) {
+ check(false, `faceless ${engine}: channel made (${res.status} ${channel.error ?? ""})`);
+ continue;
+ }
+ for (const [dname, device] of [
+ ["1440", DESKTOP],
+ ["390", PHONE],
+ ]) {
+ for (const theme of ["light", "dark"]) {
+ const label = `faceless ${engine} ${dname} ${theme}`;
+ const ctx = await setup(browser, device, theme, engine);
+ const page = await ctx.newPage();
+ watchErrors(page, label);
+ await openRoute(page, `${app}/faceless/${channel.id}/new`);
+ const bed = page.getByTestId("music-clip");
+ if (!(await bed.isVisible().catch(() => false))) {
+ const own = page.getByRole("textbox").first();
+ await own.fill("Why the sea has two tides a day");
+ await page.getByRole("button", { name: /^Next/ }).first().click();
+ }
+ try {
+ await bed.waitFor({ timeout: 20_000 });
+ } catch {
+ check(false, `${label}: the clip bed setting shows`);
+ await page.screenshot({ path: path.join(out, `faceless-${engine}-${dname}-${theme}-missing.png`), fullPage: true });
+ await ctx.close();
+ continue;
+ }
+ await bed.scrollIntoViewIfNeeded();
+ check(await bed.getByText("Use a clip's soundtrack as the bed").isVisible(), `${label}: names the clip bed`);
+ if (engine === "open") {
+ check(await bed.getByText(/talking taken out, looped under the voice/).isVisible(), `${label}: says what it does`);
+ await bed.locator('input[type="file"]').setInputFiles(mp4).catch(() => {});
+ await page.waitForTimeout(3000);
+ check(await bed.getByText(/8 s · loops with a soft crossfade/).isVisible().catch(() => false), `${label}: reads the clip's length`);
+ } else check(await bed.getByText(/Runs on your GPU \(open source\)/).isVisible(), `${label}: the cloud says it runs on your GPU`);
+ await bed.screenshot({ path: path.join(out, `faceless-${engine}-${dname}-${theme}.png`) });
+ await noSideScroll(page, label);
+ await ctx.close();
+ }
+ }
+ }
+ // Character Swap Studio: Assemble suggests Music & effects only on your GPU; the cloud puts back everything.
+ for (const engine of ["open", "cloud"]) {
+ const created = await (await fetch(`${app}/api/swap-studio/projects`, { method: "POST", headers: { "Content-Type": "application/json", origin: app }, body: JSON.stringify({ name: `Sound ${engine}`, engine }) })).json();
+ const form = new FormData();
+ form.append("file", new Blob([fs.readFileSync(mp4)], { type: "video/mp4" }), "walk.mp4");
+ const up = await (await fetch(`${app}/api/uploads`, { method: "POST", body: form, headers: { origin: app } })).json();
+ await fetch(`${app}/api/swap-studio/projects/${created.id}/clips`, { method: "POST", headers: { "Content-Type": "application/json", origin: app }, body: JSON.stringify({ url: up.url, name: "walk.mp4" }) });
+ for (const [dname, device] of [
+ ["1440", DESKTOP],
+ ["390", PHONE],
+ ]) {
+ for (const theme of ["light", "dark"]) {
+ const label = `swap-studio ${engine} ${dname} ${theme}`;
+ const ctx = await setup(browser, device, theme, engine);
+ const page = await ctx.newPage();
+ watchErrors(page, label);
+ await openRoute(page, `${app}/character-swap/${created.id}`);
+ await page.getByRole("tab", { name: "Assemble" }).click();
+ const f = field(page);
+ try {
+ await f.waitFor({ timeout: 30_000 });
+ } catch {
+ check(false, `${label}: the Original sound setting shows`);
+ await page.screenshot({ path: path.join(out, `swap-${engine}-${dname}-${theme}-missing.png`), fullPage: true });
+ await ctx.close();
+ continue;
+ }
+ await f.scrollIntoViewIfNeeded();
+ const shown = await f.getByRole("combobox").innerText();
+ check(shown.includes(engine === "open" ? "Music & effects only" : "Everything"), `${label}: starts on ${engine === "open" ? "Music & effects only (suggested)" : "Everything"}`);
+ await f.screenshot({ path: path.join(out, `swap-${engine}-${dname}-${theme}.png`) });
+ await noSideScroll(page, label);
+ await ctx.close();
+ }
+ }
+ await fetch(`${app}/api/swap-studio/projects/${created.id}`, { method: "DELETE", headers: { origin: app } });
+ }
+} finally {
+ await browser.close();
+}
+console.log(failures.length ? `\n${failures.length} failed` : "\nAll checks passed");
+process.exit(failures.length ? 1 : 0);
diff --git a/tests/shorts-api.test.ts b/tests/shorts-api.test.ts
index 8d1ea892..ced9e2aa 100644
--- a/tests/shorts-api.test.ts
+++ b/tests/shorts-api.test.ts
@@ -247,6 +247,32 @@ describe("Shorts sessions", () => {
expect(await settle(final.id)).toMatchObject({ status: "succeeded" });
});
+ it("Original sound: the cloud refuses a split in words; your GPU splits the cut and keeps the choice for Stitch again", async () => {
+ const cloud = await estimateRoute.POST(json("POST", body({ sound: { sound: "no-dialogue" } })));
+ expect(cloud.status).toBe(422);
+ expect((await cloud.json()).error).toMatch(/Music & effects only runs on your GPU \(open source\)/);
+ const bad = await estimateRoute.POST(json("POST", body({ engine: "open", sound: { sound: "louder" } })));
+ expect(bad.status).toBe(400);
+ const est = await (await estimateRoute.POST(json("POST", body({ engine: "open", source: { url: "/api/files/placeholder.mp4", duration: 12 }, sound: { sound: "lower-music", musicDb: -20 } })))).json();
+ expect(est.notes.join(" ")).toMatch(/Original sound: dialogue, with the music and effects 20 dB lower/);
+ const res = await sessionsRoute.POST(json("POST", body({ engine: "open", range: { start: 1.5, end: 9.5 }, sound: { sound: "no-dialogue" } })));
+ expect(res.status).toBe(201);
+ const s = await res.json();
+ expect(s.settings.sound).toEqual({ sound: "no-dialogue" });
+ const stitch = s.stitches[0];
+ const split = stitch.ids.map((id: string) => gens.getGeneration(id)!).find((g: { op: string }) => g.op === "separate-audio");
+ expect(split).toMatchObject({ modelId: "oss-dbs-separate", feature: "shorts-step" });
+ const final = gens.getGeneration(stitch.final)!;
+ expect(final.request.chain).toEqual([{ slot: "video" }, { slot: "audio", stem: "background" }]);
+ expect(dependsOn(final.id)).toContain(split.id);
+ expect(await settle(final.id)).toMatchObject({ status: "succeeded" });
+ // Stitch again with Dialogue only: kept on the session for the stitches after it.
+ const again = await (await stitchRoute.POST(json("POST", { sound: { sound: "dialogue-only" } }), params({ id: s.id }))).json();
+ expect(again.settings.sound).toEqual({ sound: "dialogue-only" });
+ expect(gens.getGeneration(again.stitches[1].final)!.request.chain).toEqual([{ slot: "video" }, { slot: "audio", stem: "voice" }]);
+ expect(shorts.getSession(s.id).settings.sound).toEqual({ sound: "dialogue-only" });
+ });
+
it("runs the open engine: segment (+ first frame) → Qwen first-frame restyle → Wan VACE → join → soundtrack", async () => {
const s = await shorts.createSession(body({ engine: "open" }) as never);
// Fuobe Shorts is the open engine's restyle model (the same graph oss-wan22-vace-restyle ran), on the GPU.
@@ -401,6 +427,17 @@ describe("Mixed Media renders", () => {
expect(est).toMatchObject({ frames: 80, fps: 16, demo: true, costUsd: 0, previewUsd: 0 });
});
+ it("Original sound on your GPU: the render, the cut's split and a mux of the chosen stem; the cloud says it runs on your GPU", async () => {
+ const res = await mixedRoute.POST(json("POST", mm({ sound: { sound: "dialogue-only" } })));
+ expect(res.status).toBe(201);
+ const { final, items } = await res.json();
+ expect(items.map((g: { op: string }) => g.op)).toEqual(["v2v", "trim", "separate-audio", "mux"]);
+ expect(final).toMatchObject({ modelId: "oss-mux", feature: "mixed-media", request: { title: "Sketch · skate", chain: [{ slot: "video" }, { slot: "audio", stem: "voice" }] } });
+ expect(await settle(final.id)).toMatchObject({ status: "succeeded" });
+ const cloud = await mixedEstimateRoute.POST(json("POST", mm({ engine: "cloud", sound: { sound: "dialogue-only" } })));
+ expect(cloud.status).toBe(422);
+ });
+
it("renders on the open engine in one per-frame job", async () => {
const res = await mixedRoute.POST(json("POST", mm()));
expect(res.status).toBe(201);