Nodes/XB_ToolBox/XB_WanVaceToVideo
ComfyUI Node

XB_WanVaceToVideo

Region-aware Wan video editing

By wjluoxiao·Created 5 months ago·Updated 6 days ago· 302
XB_WanVaceToVideo
  • positive
  • negative
  • vae
  • control_video
  • control_masks
  • reference_image
  • positive
  • negative
  • latent
  • trim_latent
width832
height480
length81
batch_size1
strength1.00
vae_tile_size64
scale_methodlanczos
crop_modecenter

Wan VACE is the video-editing flavor of Wan: you give it a video plus a mask, and it regenerates only the masked region while keeping everything else untouched. Change an object's look, redraw a character, fix a specific spot - that's what this node is for. It's the conditioning/latent builder for VACE in XB-BOX ("Wan VACE to Video"), and like the pack's other video builders it adds VAE tiling and a reference_image slot so the edit has something to draw from. It doesn't sample; it prepares the conditioning and latent, and a KSampler does the rest.

How it works

The key trick is that it encodes the control video twice - once masked-in and once masked-out - and concatenates the two latents along the channel dimension. That dual-latent setup is how the model learns "this region is protected, this region is editable." Concretely: your control_video gets resized to the target size, split by the control_masks into an "inactive" copy (masked area kept) and a "reactive" copy (masked area to regenerate), both VAE-encoded, and concatenated into a control_video_latent. An optional reference_image is encoded and prepended as extra context (this is what adds frames at the head of the latent - the node returns how many to trim). The mask is also downsampled into latent space so the sampler knows the edit region. strength scales how aggressively the result follows the control video.

The inputs that matter

  • positive / negative / vae - standard.
  • width / height / length / batch_size - dimensions and frame count (defaults 832×480, 81 frames).
  • strength - how hard the control video drives the output; 1.0 = follow it closely.
  • vae_tile_size - tiling for encode/decode.
  • control_video (optional) - the video you're editing. Leave it unwired and it substitutes a mid-gray video, which turns this into a masked inpainting-ish build.
  • control_masks (optional) - the MASK telling the node which pixels are editable. No mask = everything editable.
  • reference_image (optional) - context for the edit region.

Outputs: positive, negative, latent (into a sampler), and trim_latent (INT) - the count of reference-latent frames to chop off the decoded output when a reference_image added extra head frames.

Install

Pack install - ComfyUI Manager search XB_ToolBox, or clone into custom_nodes, restart. You'll also want a Wan VACE-capable setup: the Wan 2.1 edit/VACE model in diffusion_models and masks from a segmenter. This node is generic over the model you feed it, so the heavier lifting is having the right Wan variant and clean masks.

Common issues

If your output has a few extra frames at the head that look like frozen context, that's the reference latent - wire trim_latent into a frame-trim step after decode. Ragged masks give ragged edits, so blur or fill your masks before feeding them. And remember the strength dial: cranking strength too high makes the edit ignore your prompt, too low and the model wanders off the control video.

CategoryXB_ToolBox/Pipeline

Inputs (14)

NameTypeDefaultDescription
positiveCONDITIONING
negativeCONDITIONING
vaeVAE
widthINT83216–8192
heightINT48016–8192
lengthINT811–8192
batch_sizeINT11–4096
strengthFLOAT1.000–1000
vae_tile_sizeINT6464–3840
control_videooptIMAGE
control_masksoptMASK
reference_imageoptIMAGE
scale_methodoptCOMBOlanczos5 options: lanczos, bilinear, bicubic, nearest-exact, area
crop_modeoptCOMBOcenter2 options: center, disabled

Outputs (4)

NameTypeDescription
positiveCONDITIONING
negativeCONDITIONING
latentLATENT
trim_latentINT