Nodes/KJNodes for ComfyUI/Pad Image Batch Interleaved
ComfyUI Node Runs on cloud

Pad Image Batch Interleaved

Space out keyframes with gap frames

By kijai·Created 3 years ago·Updated about 12 hours ago· 3,048
Pad Image Batch Interleaved
  • images
  • images
  • masks
empty_frames_per_image1
pad_frame_value0.00
add_after_lastfalse

Pad Image Batch Interleaved takes a batch of images and inserts empty frames between each one. Simple mechanically, but it solves a real setup problem in video and animation workflows: getting your real, meaningful frames spaced out correctly with gaps a downstream model or process is supposed to fill.

Why you'd want gaps in your frame batch

A lot of video-generation and interpolation setups work from sparse keyframes rather than a dense sequence - you provide a handful of real anchor frames spread across the timeline, and the model's job is to generate everything in between. Getting that spacing right by hand - building a batch where frame 1 is real, frames 2 through 5 are placeholders, frame 6 is real, and so on - is fiddly to construct manually. This node automates exactly that: give it your real keyframes as a single batch, tell it how many empty frames to insert between each one, and it produces the correctly-spaced sequence for you, along with a mask marking which frames are real and which are padding.

The inputs and outputs that matter

  • images (IMAGE) - your batch of real, meaningful frames, in order.
  • empty_frames_per_image (default 1, 0–4096) - how many blank frames get inserted after each real image. Set this to match whatever spacing your downstream model or workflow expects.
  • pad_frame_value (default 0, range 0–1) - the fill value for the inserted blank frames. 0 is black; push it toward 1 for a lighter/white fill if that's what your pipeline needs the gaps to look like.
  • add_after_last (default false) - whether padding also gets added after the very last real image, or only in the gaps between images. Leave it off if your sequence should end cleanly on a real frame; turn it on if you need trailing padding too.
  • Outputs: images (the full interleaved sequence) and masks (marking which frames are the original images versus inserted padding) - feed that mask into whatever downstream node needs to know where the real anchor content is versus where it's expected to generate or interpolate.

Installing it

Ships with the pack:

  • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt, restart.

No models involved - it's straightforward batch construction.

Common issues & troubleshooting

Downstream node doesn't recognize which frames are padding. Make sure you're actually wiring the masks output into whatever node needs that information - the padding is in the image batch either way, but a lot of downstream nodes need the mask specifically to know where the gaps are rather than inferring it from the pixel content.

Sequence is longer or shorter than expected. Do the arithmetic against empty_frames_per_image and add_after_last before assuming something's wrong - with N real images and empty_frames_per_image set to a nonzero value, the output batch length grows accordingly, and add_after_last adds one more block of padding on top of that if enabled. It's easy to lose track of the expected count once you're several images and a nontrivial gap size in.

Padding frames aren't actually blank/black. Check pad_frame_value - the default of 0 is black, but if it's been nudged toward 1 (whether by you or by a saved workflow you inherited), the gap frames will render as gray or near-white instead. Reset it to 0 if you specifically need black.

CategoryKJNodes/image

Inputs (4)

NameTypeDefaultDescription
imagesIMAGE
empty_frames_per_imageINT10–4096
pad_frame_valueFLOAT0.000–1
add_after_lastBOOLEANfalse

Outputs (2)

NameTypeDescription
imagesIMAGE
masksMASK