Generated reference · ComfyUI workflow · motion

BiRefNet Video Matte

Per-frame BiRefNet HR matting over a clip, optionally restricted to a tracked region from sam3-video-track. Writes an RGBA WebM that keeps the alpha channel and a grayscale matte mp4.

motion7nodesGPU H100out unspecified~150sv1.0.0

On this page
7Graph nodes
7Node classes
7Inputs
1Models

Tags: motionbirefnetmattingalpharunpod-serverlessvolume-backed

Inputs (7)#

The typed parameter surface callers bind when they request this workflow. Enum options and numeric bounds are the values the workflow document declares.

source_videovideorequired
The clip to matte.
mask_videovideo
Optional grayscale mask clip from sam3-video-track. Supplying one restricts the matte to that region (refine_within_mask): BiRefNet's soft edge is kept, but only inside what SAM 3 tracked.
edge_featherintegerdefault 0min 0max 64
Gaussian blur radius on the matte edge, in pixels. Hair and sheer fabric want a little; a hard-edged product shot wants none.
edge_erodeintegerdefault 0min -20max 20
Grow (positive) or shrink (negative) the matte boundary, in dilation passes. Shrinking pulls a halo of background off the edge.
sensitivityfloatdefault 1.0min 0.0max 1.0
Detection strength. Below 1.0 the mask is scaled up before clamping, which admits more of the borderline pixels.
output_fpsfloatdefault 16.0min 1.0max 60.0
Frame rate written into both outputs. It should match the source: these are frame-for-frame companions to it.
crffloatdefault 20.0min 0.0max 63.0
VP9 quality for the RGBA WebM. Lower is better and larger; alpha survives at any value, but compression artefacts on the alpha plane read as fringing.

ComfyUI node graph (7)#

The executable ComfyUI prompt graph: 7 nodes across 7 distinct node classes, wired by 6 data dependencies. Nodes tinted green come from a custom node pack this workflow declares; the rest are ComfyUI core / baked-community classes.

flowchart TD n0["1: LoadVideo"] n1["2: GetVideoComponents"] n2["3: BiRefNetRMBG"] n3["4: SaveWEBM"] n4["5: MaskToImage"] n5["6: CreateVideo"] n6["7: SaveVideo"] n0 -->|video| n1 n1 -->|image| n2 n2 -->|images| n3 n2 -->|mask| n4 n4 -->|images| n5 n5 -->|video| n6
Data-flow DAG — scroll to zoom, drag to pan.

Nodes (7)#

1LoadVideocore
file = {{source_video}} tmpl
outputs: VIDEO
2GetVideoComponentscore
video = ◂ node 1 · out[0]
outputs: IMAGEAUDIOFLOATCOMBOCOMBO
3BiRefNetRMBGcore
image = ◂ node 2 · out[0]model = BiRefNet-HR-mattingsensitivity = {{sensitivity}} tmplmask_blur = {{edge_feather}} tmplmask_offset = {{edge_erode}} tmplinvert_output = falserefine_foreground = truebackground = Alpha
outputs: IMAGEMASKIMAGE
4SaveWEBMcore
images = ◂ node 3 · out[0]filename_prefix = birefnet-rgbacodec = vp9fps = {{output_fps}} tmplcrf = {{crf}} tmpl
5MaskToImagecore
mask = ◂ node 3 · out[1]
outputs: IMAGE
6CreateVideocore
images = ◂ node 5 · out[0]fps = {{output_fps}} tmpl
outputs: VIDEO
7SaveVideocore
video = ◂ node 6 · out[0]filename_prefix = birefnet-matteformat = mp4

Parameter banks (2)#

The prompt / configuration lookup tables this workflow keys into from its inputs — the vocabulary that turns a style / palette / preset selection into graph parameters.

post_render (1)#

mask_restrict
{"input": "mask_video", "source_class": "BiRefNetRMBG", "matte_output": 1, "rgba_output": 0, "matte_consumer_class": "MaskToImage", "matte_consumer_input": "mask", "rgba_consumer_class": "SaveWEBM", "rgba_consumer_input": "images"}

requires_families (1)#

birefnet

Models & dependencies#

Custom node packs (1)#

The non-core ComfyUI node classes this graph requires; the RunPod worker image the workflow runs on must bake or install a pack that provides every one of them.

ComfyUI-RMBG

Models required (1)#

BiRefNet-HR-matting.safetensors

Output contract#

What a successful run of this workflow returns.

primary
{"type": "video", "format": "webm", "codec": "vp9", "fps_source": "declared", "audio": false, "alpha": true, "description": "RGBA clip with the matted subject over transparency."}
secondary
{"type": "video", "format": "mp4", "codec": "h264", "fps_source": "declared", "audio": false, "alpha": false, "description": "Grayscale matte, one frame per source frame."}

Taxonomy & routing#

How the control plane classifies this workflow — from the committed workflow-taxonomy-registry.json. It drives the consistency / control surface the agentic director can exercise over the workflow.

assetFamily
film-vfx-element-library
outputPackageProfile
video-master-profile
controlModalities
model-locktemporal-lockcontrolnet-segmentation
consistencyDimensions
identitymotion
notes
BiRefNet HR matting per frame. Filed under film-vfx-element-library because an RGBA element over transparency is what it produces -- it is a plate for compositing, not a finished clip. The optional restrict branch intersects the matte with a SAM 3 track, which is why controlnet-segmentation appears.