Nodes/comfyui-mixlab-nodes/VAE Encode For Inpaint Frames ♾️Mixlab
ComfyUI Node Runs on cloud

VAE Encode For Inpaint Frames ♾️Mixlab

Batch inpaint-encoding for video

By MixLabPro·Created 3 years ago·Updated 2 months ago· 1,859
VAE Encode For Inpaint Frames ♾️Mixlab
  • vae
  • images
  • masks
  • LATENT
grow_mask_by6

This is the video-batch version of ComfyUI's built-in VAE Encode (for Inpainting). Core ComfyUI has a node that encodes one image + one mask into an inpaint-ready latent; this one does the same job across a stack of frames with their per-frame masks, so you can prep a whole clip for masked inpainting in one go instead of wiring the single-frame node in a loop. If you're inpainting video - removing or regenerating a region across many frames - this is the encode step.

To place it: masked inpainting works by handing the sampler a latent where the masked region is marked for regeneration and the rest is left as context. The VAE encode is what turns your image + mask into that latent. For a single still you'd use the core node; for a frame sequence, this batches it.

How it works

For each frame it VAE-encodes the image into latent space and marks the masked area so the sampler knows to regenerate there, keeping the unmasked latent as fixed context. The grow_mask_by step expands each mask outward by a few pixels before encoding - this is the same trick the core node uses, and it matters: a mask that hugs the edit too tightly leaves a hard seam, so growing it gives the denoiser a small blend margin. The output is a list of latents, one per frame, ready to feed a sampler.

Inputs and outputs

  • vae (VAE, required) - the VAE that matches your model. Use the one for whatever base you're sampling with; a mismatched VAE gives you color/detail garbage.
  • images (IMAGE, required) - the frames to encode.
  • masks (MASK, required) - the per-frame inpaint masks (white = regenerate).
  • grow_mask_by (INT, default 6, range 064) - how many pixels to expand each mask before encoding. The default 6 is a sane starting point; nudge it up if you see seams at the mask boundary, down if the edit bleeds too far past where you wanted.

The output is LATENT (a list) - the inpaint-ready latents, one per frame, which you send into your KSampler (with the inpaint conditioning wired the way your model expects).

How to install it

Ships with the Mixlab pack.

  • ComfyUI Manager: search comfyui-mixlab-nodes, install, restart.
  • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/shadowcz007/comfyui-mixlab-nodes.git, install requirements (install.bat on Windows or ../../../python_embeded/python.exe -s -m pip install -r requirements.txt), restart.

Common issues

Frame count vs mask count mismatch: the images and masks need to line up frame-for-frame. If you have N frames but a different number of masks (or a single mask you meant to apply to all), the batch won't pair correctly. Make sure your upstream produces matching counts, or broadcast one mask across the stack deliberately.

Seams at the mask edge: raise grow_mask_by. The whole reason that parameter exists is to give the boundary a blend margin. The inpainting KB has more on mask feathering if you want the full picture, but for this node, grow_mask_by is your lever.

Modern edit models don't behave with a plain inpaint latent: worth knowing that the newer Flux/Qwen-style edit models often want InpaintModelConditioning and a reference latent rather than a vanilla VAE-encode-for-inpaint - the KB covers that 2026 hybrid recipe. This node is the classic-style encode; it's a great fit for SD1.5/SDXL-era inpainting across frames, less so for the instruction-editing models that expect a different setup.

VRAM on long clips: encoding a big frame stack at once is memory-hungry. If you OOM, process the clip in smaller segments (the pack's list-split and video-segment nodes are handy for exactly this) rather than feeding hundreds of frames in one shot.

Category♾️Mixlab/Video

Inputs (4)

NameTypeDefaultDescription
vaeVAE
imagesIMAGE
masksMASK
grow_mask_byINT60–64

Outputs (1)

NameTypeDescription
LATENTLATENT