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.

Docs: Split soundtrack under main's 4 MB proxy limit and scoped file reads

Claude505b253da2a8
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 29a9141b..4e1fddb2 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -382,7 +382,7 @@ Each studio keeps its data and pure planner in `src/lib/`, its server module in
| **Genjutsu** (`/genjutsu`, `?mode=character`) | `catalog/genjutsu.ts`: modes Motion transfer, Character swap (round 4 part 4), Object swap, Restyle, Insert; the models per engine (`MAKERS`, `chooseMaker`: since round 4 part 4 the mode's Fuobe Original first, then other open weights, then partners; the alternatives include SCAIL-2, Wan Motion, Wan 2.2 Animate Replace, H3 Max Recast, Kling O3 and P-Video Replace in the cloud and H3 Character Swap · Relay 2.0 on the GPU; no Higgsfield model; see Fuobe Originals), `LEGACY_MAKERS` (since round 4 part 5 built from `REPLACED_BY`), list prices (`MAKER_USD`), `swapTarget`, `makerPrompt`, `planGenjutsu` (reuses Remove object's pieces, windows and `joinWithSound`; Restyle runs Shorts' planner with `keepShape`, or in the cloud the Original's own plan; Character swap is `planCharacterSwap` with `catalog/character-swap.ts`; every step names its engine, which since round 5 part 1 includes the Original restyle steps of `planFuobeRestyle`, the Soul-look first frame and the partner cloud restyle steps), Copy / Paste setup codes (`encodeSetup` / `decodeSetup`, `gj1.` + base64url JSON, `/api/files/` URLs only; old codes open the replacing Original) | `genjutsu.ts`: `estimateGenjutsu` (since round 4 part 4 with each model's `source`, the anchors, the Character swap's limits and the GPU it was tested on), `createGenjutsu` (one `createPipeline`: `genjutsu`, `genjutsu-step`), `characterSwitches` (the Character swap's settings for the chosen model, with notes), `describeCharacter`, `transcribeClip`; `mixProblem` refuses a run that would mix paid and demo steps before anything starts. No table | `/api/genjutsu[/estimate]` (`once()` on `requestId`; since round 4 part 4 mode `character` with a `character` object and the part's `cuts`, and look kind `soul` instead of `higgsfield`), `POST /api/genjutsu/describe` and `/transcribe` (round 4 part 4) | `components/genjutsu/*` (`genjutsu-studio.tsx` with source badges and licence lines in the picker, `character-panel.tsx`, `look-picker.tsx` with Fuobe Soul's 139 looks, `use-cuts.ts`, `setup-code.tsx`); "Use in Genjutsu" / "Animate with Genjutsu" result actions; `StudioConfig.related` links from Motion control (to the Character swap) and Edit video; since round 4 part 5 the Character swap's "Open in Character Swap Studio" (`CharacterFacts`) makes a studio project on the same engine with the clip and the character's picture and description (`openInStudio`, `studioHandOff`), and is a plain link to `/character-swap` before a clip is loaded |
| **Character Swap Studio** (`/character-swap`, `/character-swap/[id]`; round 4 part 5) | `catalog/swap-studio.ts`: Akatz Labs' H3 Character Swap workbench for whole clips (`docs/research/openjutsu-6.md` §4.2) as one project document (`SwapProject`: one character, a picture and a description, and up to 20 clips of .mp4, .mov, .mkv, .webm or .avi, each at most 3,592 frames at 24 fps, 149.66 s, and 200 MB; `SWAP_STUDIO`). A clip holds its cuts and shots (`shotsFromCuts`; each shot Replace character or Keep original), its transcript and voices; a shot holds who to swap, mask versions (`MaskVersion`: Track shot or Update frame, made and approved on one engine), anchor variants and segments (`applyLayout`: 5, 10 or 15 s layouts, split, merge, moved boundaries; each segment Starts fresh or Continues previous, with its own words, speaker, prompt, seed and anchor). A take is frozen as queued (`freezeTake`: settings, who, anchor, mask, history), waits for the takes it continues from (`planQueue`, `dependencies`) and carries its review (favourite, Keep / Maybe / Skip, notes; `exportDecisions`); `masterKeep` is how many last frames a GPU take's master keeps for the next segment; `assemblyPieces` lays the chosen takes over the timeline, kept shots as filmed, and names out-of-date takes (`stale`) instead of refusing them; also `maskMemoryProblem` and `studioHandOff`. `swap-studio-plan.ts`: every job as `PlanStep`s per engine (`STUDIO_MODELS`): the GPU's 24 fps copy (`planNormalize`, `oss-fit-clip`) or the cloud's browser copy of a clip the page can't play (`planPreview`, fal `scale-video`); words (`planTranscribe`: `oss-qwen3-asr` or `scribe-v2`); masks (`planMask`: `oss-h3-person-mask`, or fal's SAM 3.1 video with `frame_index`, for review only; `cloudMaskCut`); anchors (`planAnchor`: Qwen-Image-Edit 2511, or GPT Image 2.5 Sunburst or Nano Banana Pro); a take (`planSegmentTake`: on the GPU one `video-swap` on `oss-h3-swap-segment` with the approved mask, the anchor and the previous take's master as history; in the cloud the segment cut with `trim-video`, the previous take's last frame (`extract-frame`), `fuobe-character-swap` on whole seconds (`cloudCallSeconds`, 5–15) and a `fit` trim back to the segment); `frozenTakePlan`; and the assembly (`planAssembly`: on the GPU every piece fitted at 24 fps, `oss-join-encoded` up to 100 a join, `oss-mux`; in the cloud pieces cut, scaled to one size with `scale-video` (`cloudFilmSize`), joined with `join-clips` up to 24 a join at `target_fps` 24, then `merge-audio-video` with the clip's sound or silence). `swap-studio-edit.ts`: `applyEdit`, the page's edits (refused while a shot's takes run: `shotBusy`, `EditError`). `src/lib/av/scene-cuts.ts`: Detect edits' maths (FFmpeg's scene score at 0.32; a coarse 64 px pass at 0.18, then a fine pass at the clip's width, up to 1280 px). `src/lib/swap-studio-graphs.ts`: the per-job graph rewrites (see Providers) | `swap-studio.ts`: projects in `swap_projects`, changed in one synchronous read-modify-write (`mutate`; `revision`, `waiting`). Every job is a `createPipeline` (helper feature `swap-studio-step`; the assembled clip is `swap-studio` and lands in the Library). Reading a project (`advanceProject`: the view, the estimate and the decisions) fills in finished jobs and launches waiting takes, which can be paid fal calls; `ensureSwapStudioRunner`, started by `src/instrumentation.ts`, does the same every 3 s for projects with `waiting > 0`, with the page closed too, in every Fuobe server on the same data folder. `queueTakes` checks and prices every take first (`price`: no demo and real steps mixed); `mustOffer` and `loraFor` apply Settings → Models & licences (the GPU refuses to run without the Turbo LoRA and runs without a switched-off swap LoRA, with a note; fal's route needs a swap LoRA); `editProject` stops the jobs an edit leaves nothing pointing at; `estimateProject` prices segments, shots, the project, masks, anchors, words and the assembly (Sunburst anchors are billed by tokens and left out, as is a cloud browser copy, billed by compute seconds); `studioNotes`, `decisions` | `GET` / `POST /api/swap-studio/projects`; `GET` / `PATCH` / `DELETE …/[id]`; `POST …/[id]/clips`, `/prepare`, `/transcribe`, `/masks`, `/anchors`, `/queue` (mode `segment`, `from` or `all`), `/stop`, `/takes/stop`, `/assemble`; `GET …/[id]/estimate`, `/decisions` (the Export decisions JSON) | `components/swap-studio/*`: `home.tsx` (the projects; New project on your GPU or the cloud), `workbench.tsx` with seven stages (Shots, Words, Who to swap, Scene anchors, Segments, Takes & review, Assemble; `stage-*.tsx`), `use-scene-cuts.ts` (Detect edits in the browser), `hooks.ts` (`openInStudio`); the Finish stage (a clean background plate, cut-outs) shows as not available (`FINISH_UNAVAILABLE`). Checked: unit and API tests (`swap-studio`, `swap-studio-edit`, `swap-studio-api` with the demo provider on both engines, `comfy-swap-studio` through the real provider on the library graphs, `avi-probe`) and a browser check of the whole flow in demo mode on the cloud engine (`tests/e2e/character-swap-studio.mjs`); nothing has run on a GPU or with a fal key |
| **Upscale hub: FPS Boost, SDR to HDR, Export** (`/upscale/fps`, `/upscale/hdr`, `/upscale/export`) | composer studios `FPS_BOOST_STUDIO`, `SDR_TO_HDR_STUDIO`, `VIDEO_EXPORT_STUDIO` (`StudioConfig.comfyOnly`: Export runs on ComfyUI only and says so); `lib/av/fps.ts` (`fpsPlan`: interpolate by m, keep every n-th frame), `upscale.ts` (`upscaleTier`, `upscaleFactorFor`: a target size, as a factor of the clip's shorter edge for APIs that take one), `formats.ts` (`FORMAT_INFO`), `video-finish.ts` (open export values, HDR colour space, passes, the whole-clip RAM budget); since round 5 part 1 SDR to HDR (`ltx-2-3-hdr`) switches to `fal-ai/ltx-2.3-quality/hdr/lora` when the run carries LoRAs (up to 3) | ordinary generations; on submit the input clip's header fills `sourceSize` / `sourceFps` / `sourceDuration`, and an upscale tier that wouldn't enlarge the clip moves up (or is refused when picked) | `POST /api/media/probe` (a stored clip's length, size, fps and sound, from its header); `GET /api/status` reports ComfyUI's `ramBytes` | the composer's clip-facts line, format picker and no-ComfyUI notice; `VideoFileCard` in `result-media.tsx` for ProRes / FFV1 and clips the browser can't play; "Download EXR frames (.zip)" |
-| **Audio hub: Loop / extend, Join, Split soundtrack** (`/audio/loop`, `/audio/join`, since round 5 part 2 `/audio/split`) | `lib/av/audio-tools.ts` (`planLoop`, `planJoin`: up to 600 s, 2–10 clips; the open engine crossfades in one job, the cloud chains `join-audio` calls of whole plays and hard cuts), `lib/av/crossfade.ts` (`fadeCurveWav`, `crossfadeProblem`, cloud play counts); since round 5 part 2 (DBS D1) `lib/av/split.ts`: `planSplit` (one job on `oss-dbs-separate`, open engine only: DBS is hosted nowhere and the owner chose no stand-in model, so the cloud engine says so, `CLOUD_SPLIT_PROBLEM`), `planRemux` (a mix put back on its video: `oss-mux`, or fal's `merge-audio-video` in the cloud), the host's pick and time (`hostPick`, `splitTime` from measured CPU speeds), the mixer's maths (Dialogue, Music, Effects and Music & effects; levels −24 to +6 dB, solo, mute, five `PRESETS`) and Export mix's 16-bit WAV in 16 MB parts up to 2 GiB (`mixPlan`, `mixPart`) | `audio-tools.ts`: each clip's length read from its own header, the plan priced step by step, one `createPipeline` run; since round 5 part 2 the tools `split` (refused on an install set to paid APIs only, and for a file whose header says it has no sound; its preview adds the host's device, the DBS models on its disk, its pick and the time, and refuses a model the host doesn't have) and `remux`, with headers read in ranges, never whole (`fileInfo` in `media-facts.ts`), so files over 2 GiB work; `mix-export.ts` (`receiveMixPart`) appends Export mix's parts to a scratch file without holding the mix in memory and turns the last part into an upload in the Library | `POST /api/audio-tools` (`?preview=1` plans and prices; tools `split` and `remux` since round 5 part 2), `POST /api/audio-tools/export` (round 5 part 2: a part as the body, `?offset=`, `&id=` from the first part's answer, `&last=1&name=` on the last, which answers 201 with the asset) | `components/audio-tools/*` (since round 5 part 2 `split-tool.tsx`: the split, the mixer, Your splits, Export mix, Put back on the video); any audio result gets "Loop / extend" and, since round 5 part 2, "Split soundtrack", as does a clip, and a clip made with its sound (`v2a`, `mux`, `lipsync`, `trim`, `captions`) offers Split soundtrack instead of Add sound as a next step (`SOUNDED_VIDEO_OPS` in `output-actions.ts`) |
+| **Audio hub: Loop / extend, Join, Split soundtrack** (`/audio/loop`, `/audio/join`, since round 5 part 2 `/audio/split`) | `lib/av/audio-tools.ts` (`planLoop`, `planJoin`: up to 600 s, 2–10 clips; the open engine crossfades in one job, the cloud chains `join-audio` calls of whole plays and hard cuts), `lib/av/crossfade.ts` (`fadeCurveWav`, `crossfadeProblem`, cloud play counts); since round 5 part 2 (DBS D1) `lib/av/split.ts`: `planSplit` (one job on `oss-dbs-separate`, open engine only: DBS is hosted nowhere and the owner chose no stand-in model, so the cloud engine says so, `CLOUD_SPLIT_PROBLEM`), `planRemux` (a mix put back on its video: `oss-mux`, or fal's `merge-audio-video` in the cloud), the host's pick and time (`hostPick`, `splitTime` from measured CPU speeds), the mixer's maths (Dialogue, Music, Effects and Music & effects; levels −24 to +6 dB, solo, mute, five `PRESETS`) and Export mix's 16-bit WAV in 16 MB parts up to 2 GiB (`mixPlan`, `mixPart`) | `audio-tools.ts`: each clip's length read from its own header, the plan priced step by step, one `createPipeline` run; since round 5 part 2 the tools `split` (refused on an install set to paid APIs only, and for a file whose header says it has no sound; its preview adds the host's device, the DBS models on its disk, its pick and the time, and refuses a model the host doesn't have) and `remux`, with headers read through main's `storedMedia` (`storage.ts`: only the header, cached by the file, and in a visitor's price check only the visitor's own files; Split soundtrack also asks it for WebM and AVI headers, `otherHeaderInfo` in `media-facts.ts`), never whole, so files over 2 GiB work; `mix-export.ts` (`receiveMixPart`) appends Export mix's parts to a scratch file without holding the mix in memory and turns the last part into an upload in the Library. The export route skips the sign-in proxy, which holds 4 MB of a body at most: like main's routes that take a file, it runs the proxy's checks itself (`gateAsProxy`) and reads no more than a part (`readBodyWithin`) | `POST /api/audio-tools` (`?preview=1` plans and prices; tools `split` and `remux` since round 5 part 2), `POST /api/audio-tools/export` (round 5 part 2: a part as the body, `?offset=`, `&id=` from the first part's answer, `&last=1&name=` on the last, which answers 201 with the asset) | `components/audio-tools/*` (since round 5 part 2 `split-tool.tsx`: the split, the mixer, Your splits, Export mix, Put back on the video); any audio result gets "Loop / extend" and, since round 5 part 2, "Split soundtrack", as does a clip, and a clip made with its sound (`v2a`, `mux`, `lipsync`, `trim`, `captions`) offers Split soundtrack instead of Add sound as a next step (`SOUNDED_VIDEO_OPS` in `output-actions.ts`) |
| **Video studio · Frames mode** (`/video`) | `catalog/keyframes.ts` (above); `framesRequest` and the strip helpers in `src/lib/composer.ts` | cloud: FLUX 3 Max's keyframes route; start + end frame models get the first and last frame; open: `createKeyframeFilm` (Pipelines; since round 4 part 3 Fuobe DoP films keyframes this way, on the GPU only; since round 5 part 2 its frames can come from earlier steps, as the turnaround's drawn sides do) | `POST /api/generations` with op `keyframes` and `params.keyframeTimes` | `StudioConfig.frames` on `VIDEO_STUDIO`; `components/studio/frames-strip.tsx` (up to 10 stills on a time ruler, keyboard-movable markers) |
| **Turnaround video** (on a Character Sheet result, Cinema's Soul Cast results and a character's page; round 5 part 2, N7-6) | `catalog/turnaround.ts` (see Catalog): `planTurnaround` draws the sides nobody has a picture of first, from the front, with the Angles app's route (and a front from a sheet that has none), then films: on the GPU Frames mode's Wan 2.2 14B chain with the views at 0, ¼, ½, ¾ and the end of the clip (the drawn sides placed with `ChainSlot.at`) and joined; in the cloud H3 Max reference to video (the views as Image 1…n, starting and ending on the front; the default with 2 or more views or a sheet), FLUX 3 Max keyframes, or H3 Max camera controls from the front alone (`cameraWords`) | `turnaround.ts`: `TurnaroundSchema` and `TurnaroundBodySchema`, `turnaroundRun` (a character is a person whatever the client says: its run needs Soul ID's consent line unless its training recorded one, `consentOnFile` in `training.ts`), `previewTurnaround` (each step checked on this install: keys, demo, Settings → Models & licences, the engine mode; the GPU it needs), `createTurnaround` (a real person's steps all carry `GenerationRequest.consentAt`; one batch through `runTurnaroundSteps`; the answer names the film as `final`). No table: history is the feed | `POST /api/turnaround` (`?preview=1` plans and prices; `once()` on `requestId`), `POST /api/turnaround/estimate` (the evaluation harness's path); Cinema's generate with action `turnaround` | `components/turnaround/turnaround-dialog.tsx` (`TurnaroundButton`: five picture slots, "Draw the missing sides", route, length, shape, price and consent) on a finished sheet (`fashion/character-sheet.tsx`), Soul Cast results (`cinema/soul-builders.tsx`) and as Fly around on a character's page (`element-studio.tsx`) |
| **Storyboard** (`/storyboard`; Popcorn looks and prices since round 5 part 1, O13) | `catalog/storyboard.ts` (above: `planStoryboard`, `STORYBOARD_MODELS`, `STORYBOARD_PARTNERS`, the look and the 21:9 crop); `src/lib/storyboard-board.ts` (`filmReady`: "Make the film" waits until the browser has graded and cropped a look board's frames, or gave up, `finishGaveUp` in `soul-finish.ts`) | `storyboard.ts`: `StoryboardBodySchema` (shared by the run and its estimate: `look`, `lookStrength`, `partner`), `estimateStoryboard` (each frame priced on its own model, which Assist's `create_storyboard` now uses too), the film's shape from `frame.crop`; `pollOne` writes the look's finish meta on every frame (see Structured outputs) | `POST /api/storyboards` (`look`, `lookStrength`, `partner: "nano-banana-pro"`), `POST /api/storyboards/estimate` (`{costUsd, demo, frames, models}`) | `storyboard-view.tsx`: the Look chip with a "No look" state (`look-chip.tsx`'s `none`), the price and frame count next to Generate (disabled while the estimate errs), and in the cloud a "Frames made on" choice of Fuobe or Nano Banana Pro. A 4-frame cloud board is priced under $0.20 in the tests (Nano Banana Pro: about $0.60) |
diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md
index 143742e7..efe509cd 100644
--- a/docs/HANDOFF.md
+++ b/docs/HANDOFF.md
@@ -72,7 +72,8 @@ The owner's own words on engines, SAM Audio, accounts and the PR #14 calls are i
- price checks (estimate routes, `?preview=1` on run routes) go in `ESTIMATES` or `PREVIEWS` and run through `priceAs` (`src/server/visitor.ts`), so a visitor is priced for its own GPU, never a demo
- changes to the library or projects go in `LIBRARY_CHANGES` (403 `code: "library"` for an account). Settings, keys and tokens stay the owner's. The owner's lists come back empty for a visitor, and a visitor is never told whether one of the owner's records exists.
- only the owner's runs reach the install's keys or GPU. An account's studio generations run on its own ComfyUI through `POST /api/generations`; other runs answer `connect-gpu`, then `own-gpu-tool`. An account's run reads only its own files (`src/server/tenant.ts`, `src/server/account-inputs.ts`).
- - a request body over 66 MB doesn't get through the sign-in proxy: a route that takes a large file takes an uploaded file's reference
+ - the sign-in proxy holds at most 4 MB of a request body (main, 10-31; `next.config.ts`), and a bigger one reaches the route cut short: a route that takes a large file takes an uploaded file's reference. A route that must take a file itself skips the proxy the way main's do (the matcher in `src/proxy.ts`, then `gateAsProxy` and `readBodyWithin` or `readFormWithin` from `src/server/direct-gate.ts`, and a row in `tests/request-body-limits.test.ts`), as Split soundtrack's Export mix does
+ - a price check reads a stored file only through `storedMedia` (`src/server/storage.ts`): only its header, and in a visitor's price check only the visitor's own files
- add new routes to those rules, and test them in the style of `tests/public-signup.test.ts`, `tests/public-signup-tools.test.ts` and `tests/account-*.test.ts`
- new ComfyUI workflows and node packs go into the pre-flight's requirement index (`packs.json`, `model-pins.json`, then `node scripts/comfy/build-requirements.mjs`), and new studios and tools get a row on the `/connect` board (`STUDIO_ROWS` in `src/server/gpu/tools.ts`)