ComfyUI Node

Join Mask Sequence

Stitch two mask tracks into one longer sequence

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Join Mask Sequence
  • mask_sequence_1
  • mask_sequence_2
  • MASK_SEQUENCE

Say you've built one mask track for the first stretch of a video and a different one for the rest, and you need them to become a single continuous sequence. JWMaskSequenceJoin does that. It takes two MASK_SEQUENCE inputs and concatenates them end to end: sequence 1's frames first, then sequence 2's frames right after. The result is one longer MASK_SEQUENCE with all the frames in order.

It's one of the mask-sequence nodes in jamesWalker55's "Various ComfyUI Nodes by Type" pack, and it's really only useful alongside its siblings, JWMaskSequenceFromMask (which builds a sequence in the first place) and JWMaskSequenceApplyToLatent (which puts it to work).

Why join sequences at all

Temporal masking in video means one mask per frame. Most of the time you want the same mask throughout, but not always. Sometimes the masked region needs to change partway through the clip, protect one area for the first half, a different area for the second. The clean way to express that is to build each segment as its own sequence and then join them. Segment A masks the left side for 24 frames, segment B masks the right side for the next 24, join them, and now you've got a 48-frame track that switches behavior at the midpoint. Chain more joins and you can assemble a whole storyboard of mask changes.

That's the real pitch: this node is how you compose a non-uniform temporal mask out of simple uniform pieces, instead of trying to author all N frames at once.

The inputs and output

  • mask_sequence_1: the first MASK_SEQUENCE. Its frames come first.
  • mask_sequence_2: the second MASK_SEQUENCE, appended after the first.

Output is a single MASK_SEQUENCE whose length is the two inputs added together. Order is exactly what you'd expect: 1 then 2. Want a different arrangement? Swap which sequence goes into which input, or chain multiple joins.

Installing it

ComfyUI Manager: search "Various ComfyUI Nodes by Type" or jamesWalker55, install, restart. Or clone:

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

then restart ComfyUI. No models, no extra dependencies.

Things to keep straight

MASK_SEQUENCE is a custom type that belongs to this pack, not a standard ComfyUI mask, so both inputs have to be actual MASK_SEQUENCE objects produced by the pack's own nodes (usually JWMaskSequenceFromMask). You can't join a plain MASK to a MASK_SEQUENCE here; convert the plain mask into a one-or-more-frame sequence first, then join.

The other thing to mind is total length. After joining, the sequence is as long as both parts combined, and that combined length needs to match the frame count of the latent batch you eventually apply it to. If you join a 24-frame and a 24-frame track and then try to apply it to a 30-frame render, the counts won't line up. Do the arithmetic so the joined length equals your clip length, and the apply step downstream will behave.

For anything more elaborate than a couple of segments, just keep chaining: feed the output of one join into the input of the next. That's the intended way to build up longer, multi-part mask tracks.

CategoryjamesWalker55

Inputs (2)

NameTypeDefaultDescription
mask_sequence_1MASK_SEQUENCE
mask_sequence_2MASK_SEQUENCE

Outputs (1)

NameTypeDescription
MASK_SEQUENCEMASK_SEQUENCE