Nodes/Various ComfyUI Nodes by Type/Apply Mask Sequence to Latent
ComfyUI Node

Apply Mask Sequence to Latent

Attach a per-frame mask to a latent

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Apply Mask Sequence to Latent
  • samples
  • mask_sequence
  • LATENT

JWMaskSequenceApplyToLatent attaches a sequence of masks - one per frame - to a batched latent, so a sampler knows which regions to touch on each individual frame. This is the animation-flavored cousin of the standard "Set Latent Noise Mask" node: instead of one mask for one image, you're supplying a whole timeline of masks for a whole timeline of latents.

You'd reach for this in a video or animation graph where the region you want to regenerate moves over time. Static inpainting masks a fixed area; but if you're masking a walking subject, a panning shot, or an effect that drifts across the frame, a single mask won't track it. A mask sequence lets the masked region change frame by frame - mask the top-left early, the bottom-right later - and this node is what binds that sequence onto the latent batch so the sampler respects it during denoising.

What it actually does

It takes your latent batch (samples) and a mask_sequence, and returns a LATENT with the per-frame masks applied - essentially the video equivalent of setting a noise mask, but with a mask that varies across the batch. Under the hood the mask sequence tells the sampler how much of each frame's latent to leave alone versus regenerate.

The important thing is where the mask_sequence comes from. MASK_SEQUENCE is a custom type from this same pack - you build it with the pack's other mask-sequence nodes (JWMaskSequenceFromMask turns a mask batch into a sequence, JWMaskSequenceJoin stitches sequences together). You can't wire a plain MASK straight in; it has to be a MASK_SEQUENCE, which is why these nodes travel together.

The inputs and outputs that matter

Two required inputs, both of which must come from the right upstream types:

  • samples (LATENT) - your batched latent, typically the frames you're about to sample or re-sample.
  • mask_sequence (MASK_SEQUENCE) - the per-frame masks. Build this from the pack's mask-sequence nodes; a regular MASK won't connect.

Output is a single LATENT with the mask sequence applied. Wire it into your KSampler in place of the plain latent.

How to install it

Pack: jamesWalker55/comfyui-various. ComfyUI Manager - search Various ComfyUI Nodes by Type, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/jamesWalker55/comfyui-various

then restart. No heavy dependencies. This node lives in comfyui_mask_sequence_ops.py - but because it only works alongside the other MASK_SEQUENCE nodes in that file, this is a case where grabbing the whole file (or the whole pack) makes more sense than cherry-picking a single node.

Common issues & troubleshooting

"MASK_SEQUENCE expected, got MASK." The number-one gotcha. You cannot plug a normal mask into mask_sequence - it needs the custom sequence type. Run your mask batch through JWMaskSequenceFromMask first, then wire that in.

Frame counts have to line up. The mask sequence should have as many frames as your latent batch. A mismatch between the number of masks and the number of latent frames is where these graphs quietly go wrong - check that the two counts agree.

It's niche, and that's fine. This whole mask-sequence corner of the pack is for moving, per-frame masking in animation workflows. If you're doing plain single-image inpainting, you don't need it - the standard latent-noise-mask node is simpler and does the job.

CategoryjamesWalker55

Inputs (2)

NameTypeDefaultDescription
samplesLATENT
mask_sequenceMASK_SEQUENCE

Outputs (1)

NameTypeDescription
LATENTLATENT