Nodes/VACE Tools/VACE Source Prep
ComfyUI Node

VACE Source Prep

The trim node that keeps long clips from breaking your mask generator

By ethanfel·Created 7 months ago·Updated 6 months ago· 9
VACE Source Prep
  • source_clip
  • source_clip_2
  • inpaint_mask
  • trimmed_clip
  • mode
  • split_index
  • edge_frames
  • inpaint_mask
  • keyframe_positions
  • vace_pipe
modeEnd Extend
split_index0
input_left0
input_right0
edge_frames8
keyframe_positions

Here's the situation that makes VACE Source Prep essential: you have a 274-frame clip and you want to extend it. Your VACE Mask Generator can't take it - for most modes the source must fit within target_frames (default 81), and if it doesn't, the mask generator errors out and tells you to trim first. Source Prep is that trim. It sits before the mask generator, looks at how long your clip is versus how many frames you're actually generating, and cuts the source down to the frames that matter for your chosen mode.

The name undersells it. It's not just a crop - it's a mode-aware parameter machine. It figures out the right trim for each of the eleven modes, recalculates the split_index and edge_frames that go with the trimmed clip, optionally trims your inpaint mask to match, and packages the whole thing plus a vace_pipe that tells the merge-back node exactly where the seams are. You wire its outputs straight into VACE Mask Generator and you can't accidentally hand it stale parameters.

How it works

You give it the full, untrimmed source_clip and the same mode you'll use downstream. The two inputs that do the trimming are input_left and input_right - frames to keep from each side of the split, where 0 means "keep all available." Their meaning shifts per mode: trailing context for End Extend, leading reference for Pre Extend, frames each side of the split for Middle Extend, edge sizes for Edge/Join, context around the region for Replace/Inpaint. Modes that don't trim (Frame Interpolation, Video Inpaint, Keyframe, Upscale) pass the clip through untouched.

Two details are worth knowing before they bite:

  • Edge and Join modes force a symmetric trim - it takes the minimum of the left/right edge sizes, so you can't build an asymmetric loop context by accident.
  • Join Extend takes an optional source_clip_2 to join two separate clips instead of splitting one in half - genuinely useful for stitching two takes together.

There's also per-mode widget hiding: inputs that don't apply to your selected mode disappear from the UI, which keeps a nine-input node from looking like a wall of knobs.

Outputs and the pipe

Seven outputs, and they split into two groups. trimmed_clip, mode, split_index, edge_frames, inpaint_mask, and keyframe_positions all wire into VACE Mask Generator's matching inputs - the adjusted values, not your raw ones. Then there's vace_pipe, a custom VACE_PIPE type carrying mode, trim bounds, and context-frame counts. That one doesn't go to the mask generator at all; it goes to VACE Merge Back, so the splice node knows where your trimmed window sat inside the original video. If you're only generating, you can ignore it. If you're splicing back, don't lose it.

How to install it

One of seven nodes in ethanfel's ComfyUI-VACE-Tools pack:

cd ComfyUI/custom_nodes/
git clone https://github.com/ethanfel/Comfyui-VACE-Tools.git

Restart ComfyUI, or search "VACE Tools" in ComfyUI Manager. Zero declared Python dependencies - just torch and numpy from ComfyUI itself - and no model downloads; the Wan base and VACE extension checkpoints are separate downloads in your WanVideoWrapper setup. The one thing to remember is the mode you select here must match the mask generator's mode. The node outputs mode precisely so you can wire it through instead of trusting yourself to keep two dropdowns in sync.

CategoryVACE Tools

Inputs (9)

NameTypeDefaultDescription
source_clipIMAGE
modeCOMBOEnd Extend11 options: End Extend, Pre Extend, Middle Extend, Edge Extend, Join Extend, Bidirectional Extend, +5
split_indexINT0-10000–10000
input_leftINT00–10000
input_rightINT00–10000
edge_framesINT81–10000
source_clip_2optIMAGEJoin Extend: second source clip to heal/join. Upscale: your reference image(s) at upscaled size — spliced into the clip at keyframe_positions before VACE processing.
inpaint_maskoptMASK
keyframe_positionsoptSTRING

Outputs (7)

NameTypeDescription
trimmed_clipIMAGETrimmed source frames — wire to VACE Mask Generator's trimmed_clip input.
modeEnd Extend,Pre Extend,Middle Extend,Edge Extend,Join Extend,Bidirectional Extend,Frame Interpolation,Replace/Inpaint,Video Inpaint,Keyframe,UpscaleSelected mode — wire to VACE Mask Generator's mode.
split_indexINTAdjusted split_index for the trimmed clip — wire to VACE Mask Generator.
edge_framesINTAdjusted edge_frames — wire to VACE Mask Generator.
inpaint_maskMASKInpaint mask trimmed to match output — wire to VACE Mask Generator.
keyframe_positionsSTRINGKeyframe positions pass-through — wire to VACE Mask Generator.
vace_pipeVACE_PIPEPipe carrying mode, trim bounds, and context counts — wire to VACE Merge Back.