The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Remove background: the job makes the file the picker shows; the matte notes name params.matteOutput
Claude578139edd04b
diff --git a/scripts/comfy/library.spec.mjs b/scripts/comfy/library.spec.mjsindex eeb8d0d7..6098be33 100644--- a/scripts/comfy/library.spec.mjs+++ b/scripts/comfy/library.spec.mjs@@ -79,7 +79,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" | "mask" (a painted eraser's last tracked frame, white = the object) | "cutout" | "matte" (a matte graph's transparent-// and black-and-white videos: params.extra.keepOutput keeps one)). Entry fields: worker "isolated" (needs its own ComfyUI, see README), expand "captions" (the provider writes one+// and black-and-white videos: params.matteOutput keeps one)). Entry fields: worker "isolated" (needs its own ComfyUI, see README), expand "captions" (the provider writes one// segment per caption cue before submitting).import fs from 'node:fs';@@ -1704,7 +1704,7 @@ export const SPEC = ['Core RemoveBackground on every frame -> InvertMask -> JoinImageWithAlpha (it stores 1-mask as alpha, like bg-remove-birefnet) -> SaveWEBM (vp9, crf 24, fps = source fps): an RGBA .webm with real transparency (yuva420p). ' +'Second output (node 10) = black/white matte .mp4 for compositing. SaveWEBM reports its file under history outputs "images" (animated: true), not "videos": classify by the .webm extension / the declared kind. ' +'Per-frame model, so hair edges may flicker (inferred). Source audio is dropped. For "keep only X" use video-bg-remove-sam3. ' +- 'Roles: node 7 "cutout", node 10 "matte"; params.extra.keepOutput ("cutout" | "matte") makes the provider drop the other save node (Video tools → Remove background: Cutout video / Alpha mask).',+ 'Roles: node 7 "cutout", node 10 "matte"; params.matteOutput ("cutout" | "matte", on a Remove background job: op bg-remove-video) makes the provider drop the other save node (Video tools → Remove background: Cutout video / Alpha mask).',},{id: 'video-bg-remove-sam3',@@ -1726,7 +1726,7 @@ export const SPEC = ['prompt = what to KEEP ("person", "red car"). SAM3_VideoTrack (detection_threshold 0.5, max_objects 4, detect_interval 1) -> SAM3_TrackToMask (object_indices "" = all tracked objects) -> InvertMask -> JoinImageWithAlpha -> SaveWEBM (vp9, fps = source). ' +'Masks are hard-edged; multiply with the BiRefNet matte for hair. Output under history "images" (animated .webm). Template utility_video_segment_sam3 runs SAM3_Detect per frame instead. ' +'Second output (node 12, role "matte", added by the remove-object package) = the black-and-white matte .mp4 of what was kept (MaskToImage -> CreateVideo at the source fps); ' +- 'params.extra.keepOutput ("cutout" | "matte") makes the provider drop the other save node, so only the chosen one is encoded.',+ 'params.matteOutput ("cutout" | "matte", on a Remove background job: op bg-remove-video) makes the provider drop the other save node, so only the chosen one is encoded.',},{id: 'video-depth-da3',diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.tsindex 2c608d7d..f5e2e698 100644--- a/src/lib/catalog/plan.ts+++ b/src/lib/catalog/plan.ts@@ -239,6 +239,10 @@ export function planGeneration(if (requires?.mask && !req.inputs?.mask) throw new Error(requires.msg);if (requires?.points && !params.points?.length) throw new Error(requires.msg);if (op === "bg-remove-video" || op === "depth-video") checkVideoToolOptions(model, op, prompt, params);+ // Remove background on a model that makes both files: the picker's default (the cut-out) unless asked, so the job+ // makes the one file the picker showed, not both.+ const matteOutputs = model.options.matteOutputs;+ if (op === "bg-remove-video" && !params.matteOutput && matteOutputs && matteOutputs.length > 1) params = { ...params, matteOutput: matteOutputs[0] };if (!prompt && !promptOptional(model, op) && !markedTarget(model, op, req, params)) {throw new Error(op === "remove-object" ? "Say what to remove, e.g. “the coffee cup in her hand”" : "Write a prompt first");}diff --git a/tests/video-tool-options.test.ts b/tests/video-tool-options.test.tsindex cdff75b9..d7ceb967 100644--- a/tests/video-tool-options.test.ts+++ b/tests/video-tool-options.test.ts@@ -32,6 +32,16 @@ describe("Remove background: what to keep, cut-out or alpha mask", () => {expect(model("oss-video-matte-sam3").options).toMatchObject({ keepsNamed: true, matteOutputs: ["cutout", "matte"] });});+ it("a model that makes both files makes the picker's default (the cut-out) unless asked", () => {+ const video = { video: "/api/files/clip.mp4" };+ expect(plan({ modelId: "oss-video-matte-birefnet", op: "bg-remove-video", inputs: video }).params.matteOutput).toBe("cutout");+ expect(plan({ modelId: "birefnet-video", op: "bg-remove-video", inputs: video }).params.matteOutput).toBe("cutout");+ expect(plan({ modelId: "oss-video-matte-sam3", op: "bg-remove-video", prompt: "the dog", inputs: video, params: { matteOutput: "matte" } }).params.matteOutput).toBe("matte");+ // One file only: nothing to choose.+ expect(plan({ modelId: "bria-video-bg", op: "bg-remove-video", inputs: video }).params.matteOutput).toBeUndefined();+ expect(plan({ modelId: "sam-3-1-video-mask", op: "bg-remove-video", prompt: "the dog", inputs: video }).params.matteOutput).toBeUndefined();+ });+it("BiRefNet's alpha mask is its output_mask switch; Bria has none", () => {expect(buildPayload(map("birefnet-video"), { ...clip, matteOutput: "matte" })).toMatchObject({ video_url: clip.video, output_mask: true, video_output_type: "VP9 (.webm)" });expect(buildPayload(map("birefnet-video"), { ...clip, matteOutput: "cutout" })).toMatchObject({ output_mask: false });diff --git a/workflows/comfyui/manifest.json b/workflows/comfyui/manifest.jsonindex 5359855f..a5001c9c 100644--- a/workflows/comfyui/manifest.json+++ b/workflows/comfyui/manifest.json@@ -7678,7 +7678,7 @@"vramGb": 4,"license": "MIT (BiRefNet)","validated": true,- "notes": "Core RemoveBackground on every frame -> InvertMask -> JoinImageWithAlpha (it stores 1-mask as alpha, like bg-remove-birefnet) -> SaveWEBM (vp9, crf 24, fps = source fps): an RGBA .webm with real transparency (yuva420p). Second output (node 10) = black/white matte .mp4 for compositing. SaveWEBM reports its file under history outputs \"images\" (animated: true), not \"videos\": classify by the .webm extension / the declared kind. Per-frame model, so hair edges may flicker (inferred). Source audio is dropped. For \"keep only X\" use video-bg-remove-sam3. Roles: node 7 \"cutout\", node 10 \"matte\"; params.extra.keepOutput (\"cutout\" | \"matte\") makes the provider drop the other save node (Video tools → Remove background: Cutout video / Alpha mask)."+ "notes": "Core RemoveBackground on every frame -> InvertMask -> JoinImageWithAlpha (it stores 1-mask as alpha, like bg-remove-birefnet) -> SaveWEBM (vp9, crf 24, fps = source fps): an RGBA .webm with real transparency (yuva420p). Second output (node 10) = black/white matte .mp4 for compositing. SaveWEBM reports its file under history outputs \"images\" (animated: true), not \"videos\": classify by the .webm extension / the declared kind. Per-frame model, so hair edges may flicker (inferred). Source audio is dropped. For \"keep only X\" use video-bg-remove-sam3. Roles: node 7 \"cutout\", node 10 \"matte\"; params.matteOutput (\"cutout\" | \"matte\", on a Remove background job: op bg-remove-video) makes the provider drop the other save node (Video tools → Remove background: Cutout video / Alpha mask)."},{"id": "video-bg-remove-sam3",@@ -7739,7 +7739,7 @@"vramGb": 6,"license": "Meta SAM License (royalty-free, commercial use allowed; attribution + acceptable-use terms)","validated": true,- "notes": "prompt = what to KEEP (\"person\", \"red car\"). SAM3_VideoTrack (detection_threshold 0.5, max_objects 4, detect_interval 1) -> SAM3_TrackToMask (object_indices \"\" = all tracked objects) -> InvertMask -> JoinImageWithAlpha -> SaveWEBM (vp9, fps = source). Masks are hard-edged; multiply with the BiRefNet matte for hair. Output under history \"images\" (animated .webm). Template utility_video_segment_sam3 runs SAM3_Detect per frame instead. Second output (node 12, role \"matte\", added by the remove-object package) = the black-and-white matte .mp4 of what was kept (MaskToImage -> CreateVideo at the source fps); params.extra.keepOutput (\"cutout\" | \"matte\") makes the provider drop the other save node, so only the chosen one is encoded."+ "notes": "prompt = what to KEEP (\"person\", \"red car\"). SAM3_VideoTrack (detection_threshold 0.5, max_objects 4, detect_interval 1) -> SAM3_TrackToMask (object_indices \"\" = all tracked objects) -> InvertMask -> JoinImageWithAlpha -> SaveWEBM (vp9, fps = source). Masks are hard-edged; multiply with the BiRefNet matte for hair. Output under history \"images\" (animated .webm). Template utility_video_segment_sam3 runs SAM3_Detect per frame instead. Second output (node 12, role \"matte\", added by the remove-object package) = the black-and-white matte .mp4 of what was kept (MaskToImage -> CreateVideo at the source fps); params.matteOutput (\"cutout\" | \"matte\", on a Remove background job: op bg-remove-video) makes the provider drop the other save node, so only the chosen one is encoded."},{"id": "video-depth-da3",