Generated reference · ComfyUI workflow · motion

SAM 3 Track then VACE Inpaint

Fix or replace part of an existing video in one pass: SAM 3.1 on ComfyUI's core nodes tracks the thing you name, the mask is grown to cover its edge, and VACE regenerates inside it from a prompt. The mask never leaves the graph, so there …

motion19nodesGPU H100out unspecified~843sv1.0.0

On this page

Fix or replace part of an existing video in one pass: SAM 3.1 on ComfyUI's core nodes tracks the thing you name, the mask is grown to cover its edge, and VACE regenerates inside it from a prompt. The mask never leaves the graph, so there is no intermediate clip to write, upload and read back.

19Graph nodes
17Node classes
19Inputs
4Models

Tags: motionsam3sam3.1vaceinpaintcompositionrunpod-serverlessvolume-backed

Inputs (19)#

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 edit.
track_promptstringrequireddefault person
What SAM 3.1 should track and hand to VACE as the region to replace; its text encoder reads at most 32 tokens per prompt. Comma-separated for several categories.
promptstringrequireddefault the same scene with the tracked subject replaced, cinematic lighting
What should appear inside the tracked region.
negative_promptstringdefault 色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走
Wan's own published negative prompt.
reference_imageimage
Optional still VACE conditions on — what the replacement should look like.
mask_growintegerdefault 12min -64max 64
Pixels to grow the tracked mask by before VACE sees it. A tight track leaves the subject's own edge inside the KEPT region, and the replacement then has to blend against it; growing the mask hands that edge to the generator. Negative shrinks.
track_thresholdfloatdefault 0.5min 0.0max 1.0
SAM 3.1 detection score floor for the track prompt (SAM3_VideoTrack detection_threshold; 0.5 is the node's default).
track_max_objectsintegerdefault 4min 0max 64
Most objects tracked at once (SAM3_VideoTrack max_objects; 0 means the node's internal cap of 64). Every tracked object joins the region VACE replaces.
track_detect_intervalintegerdefault 1min 1max 240
Run text detection every N frames to pick up objects entering the shot; 1 is every frame.
strengthfloatdefault 1.0min 0.0max 2.0
How hard VACE binds to the control track.
resolutionenumdefault 480p_landscape_832x480
Frame size. It should match the source; VACE does not letterbox either.
options: 480p_landscape_832x480480p_portrait_480x832720p_landscape_1280x720720p_portrait_720x1280
lengthintegerdefault 81min 5max 241
Frames to produce. Wan wants 4n+1.
fpsfloatdefault 16.0min 1.0max 30.0
Frame rate written into the output.
stepsintegerdefault 20min 1max 60
Sampling steps.
cfgfloatdefault 5.0min 1.0max 20.0
Classifier-free guidance.
shiftfloatdefault 8.0min 0.0max 20.0
ModelSamplingSD3 shift.
seedintegerdefault 0min 0
Sampler seed.
samplerenumdefault uni_pc
Sampler.
options: uni_pceulerdpmpp_2m
schedulerenumdefault simple
Schedule.
options: simplenormalbetakarras

ComfyUI node graph (19)#

The executable ComfyUI prompt graph: 19 nodes across 17 distinct node classes, wired by 25 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: CheckpointLoaderSimple"] n3["4: CLIPTextEncode"] n4["5: SAM3_VideoTrack"] n5["6: SAM3_TrackToMask"] n6["7: GrowMask"] n7["8: UNETLoader"] n8["9: CLIPLoader"] n9["10: VAELoader"] n10["11: ModelSamplingSD3"] n11["12: CLIPTextEncode"] n12["13: CLIPTextEncode"] n13["14: WanVaceToVideo"] n14["15: KSampler"] n15["16: TrimVideoLatent"] n16["17: VAEDecode"] n17["18: CreateVideo"] n18["19: SaveVideo"] n0 -->|video| n1 n2 -->|clip| n3 n1 -->|images| n4 n2 -->|model| n4 n3 -->|conditioning| n4 n4 -->|track_data| n5 n5 -->|mask| n6 n7 -->|model| n10 n8 -->|clip| n11 n8 -->|clip| n12 n11 -->|positive| n13 n12 -->|negative| n13 n9 -->|vae| n13 n1 -->|control_video| n13 n6 -->|control_masks| n13 n10 -->|model| n14 n13 -->|positive| n14 n13 -->|negative| n14 n13 -->|latent_image| n14 n14 -->|samples| n15 n13 -->|trim_amount| n15 n15 -->|samples| n16 n9 -->|vae| n16 n16 -->|images| n17 n17 -->|video| n18
Data-flow DAG — scroll to zoom, drag to pan.

Nodes (19)#

1LoadVideocore
file = {{source_video}} tmpl
outputs: VIDEO
2GetVideoComponentscore
video = ◂ node 1 · out[0]
outputs: IMAGEAUDIOFLOATCOMBOCOMBO
3CheckpointLoaderSimplecore
ckpt_name = sam3.1_multiplex_fp16.safetensors
outputs: MODELCLIPVAE
4CLIPTextEncodecore
clip = ◂ node 3 · out[1]text = {{track_prompt}} tmpl
outputs: CONDITIONING
5SAM3_VideoTrackcore
images = ◂ node 2 · out[0]model = ◂ node 3 · out[0]conditioning = ◂ node 4 · out[0]detection_threshold = {{track_threshold}} tmplmax_objects = {{track_max_objects}} tmpldetect_interval = {{track_detect_interval}} tmpl
outputs: SAM3_TRACK_DATA
6SAM3_TrackToMaskcore
track_data = ◂ node 5 · out[0]object_indices =
outputs: MASK
7GrowMaskcore
mask = ◂ node 6 · out[0]expand = {{mask_grow}} tmpltapered_corners = true
outputs: MASK
8UNETLoadercore
unet_name = wan2.1_vace_14B_fp16.safetensorsweight_dtype = default
outputs: MODEL
9CLIPLoadercore
clip_name = umt5_xxl_fp16.safetensorstype = wandevice = default
outputs: CLIP
10VAELoadercore
vae_name = wan_2.1_vae.safetensors
outputs: VAE
11ModelSamplingSD3core
model = ◂ node 8 · out[0]shift = {{shift}} tmpl
outputs: MODEL
12CLIPTextEncodecore
clip = ◂ node 9 · out[0]text = {{prompt}} tmpl
outputs: CONDITIONING
13CLIPTextEncodecore
clip = ◂ node 9 · out[0]text = {{negative_prompt}} tmpl
outputs: CONDITIONING
14WanVaceToVideocore
positive = ◂ node 12 · out[0]negative = ◂ node 13 · out[0]vae = ◂ node 10 · out[0]width = {{resolution_map[resolution].width}} tmplheight = {{resolution_map[resolution].height}} tmpllength = {{length}} tmplbatch_size = 1strength = {{strength}} tmplcontrol_video = ◂ node 2 · out[0]control_masks = ◂ node 7 · out[0]
outputs: CONDITIONINGCONDITIONINGLATENTINT
15KSamplercore
model = ◂ node 11 · out[0]positive = ◂ node 14 · out[0]negative = ◂ node 14 · out[1]latent_image = ◂ node 14 · out[2]seed = {{seed}} tmplsteps = {{steps}} tmplcfg = {{cfg}} tmplsampler_name = {{sampler}} tmplscheduler = {{scheduler}} tmpldenoise = 1.0
outputs: LATENT
16TrimVideoLatentcore
samples = ◂ node 15 · out[0]trim_amount = ◂ node 14 · out[3]
outputs: LATENT
17VAEDecodecore
samples = ◂ node 16 · out[0]vae = ◂ node 10 · out[0]
outputs: IMAGE
18CreateVideocore
images = ◂ node 17 · out[0]fps = {{fps}} tmpl
outputs: VIDEO
19SaveVideocore
video = ◂ node 18 · out[0]filename_prefix = sam3-vaceformat = mp4

Parameter banks (3)#

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

resolution_map (4)#

480p_landscape_832x480
{"width": 832, "height": 480}
480p_portrait_480x832
{"width": 480, "height": 832}
720p_landscape_1280x720
{"width": 1280, "height": 720}
720p_portrait_720x1280
{"width": 720, "height": 1280}

post_render (1)#

optional_image_input
{"input": "reference_image", "target_class": "WanVaceToVideo", "target_input": "reference_image"}

requires_families (3)#

sam31wan21-vacewan-shared

Models & dependencies#

Models required (4)#

sam3.1_multiplex_fp16.safetensors
wan2.1_vace_14B_fp16.safetensors
umt5_xxl_fp16.safetensors
wan_2.1_vae.safetensors

Output contract#

What a successful run of this workflow returns.

primary
{"type": "video", "format": "mp4", "codec": "h264", "fps_source": "declared", "audio": false, "alpha": false, "description": "The clip with the tracked region regenerated."}

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
region-edited-video
outputPackageProfile
video-master-profile
controlModalities
model-lockprompt-template-locksampler-scheduler-lockseed-locktemporal-lockcontrolnet-segmentationcontrolnet-inpaintreference-ensemble
consistencyDimensions
identitymotionlightingenvironment
notes
The composition of sam3-video-track and wan21-vace-edit's inpaint mode in ONE graph: the MASK goes straight from SAM3_TrackToMask through GrowMask into WanVaceToVideo, so there is no intermediate mask clip to write, upload and read back.