Nodes/ComfyUI-xiaozhuguang/小珠光帧优化
ComfyUI Node

小珠光帧优化

The frame-padding node video people keep rediscovering

By xiaozhuguang·Created 2 months ago·Updated a day ago· 56
小珠光帧优化
  • image
  • image
  • frame_count
  • original_count
  • front_fill
  • back_fill
  • first_frame
  • last_frame
multi_fillfalse

Every image-to-video user eventually hits the same annoyance: the first frame of your generated clip flickers, or your model needs a specific frame count that your source doesn't have. 小珠光帧优化 (Xiaozhuguang Duplicate First Frame) is the fix for both - it pads your frame batch by duplicating the first frame. The name undersells it; this is the node that makes a source video play nicely with frame-count-sensitive models.

The math it applies is the community-standard one: it pads the front so the total becomes ceil(a/4)*4 + 5 frames, where a is your original count. That's the frame pattern a lot of video pipelines expect - the multiple-of-4 shape plus five is the length many frame-count-sensitive models want to see, and it's the same convention the pack's own video nodes work with. It also reports exactly how much it padded, so you can strip it back out later with the pack's FrameExtract node.

How it works

It takes your IMAGE batch, clones the first frame, and prepends enough copies to hit the target length. front_fill is computed automatically as ceil(batch_count/4)*4 + 5 - batch_count. If you flip multi_fill on and the total still comes up short of 73 frames, it pads the back with copies of the last frame to reach 73 - handy for models with a hard minimum clip length. The node returns everything you need to undo or inspect the operation, not just the padded image.

The inputs that matter

  • image - your frame batch.
  • multi_fill - enable back-filling with the last frame up to 73 total frames. Off by default.

Outputs: image (the padded batch), frame_count (padded total), original_count, front_fill, back_fill, and standalone first_frame / last_frame (IMAGE). Since v12.11.0 it's cache-friendly: if the input image doesn't change, ComfyUI skips re-running it entirely, so it won't slow down repeated runs.

Install

From the ComfyUI-xiaozhuguang pack - Manager (search "ComfyUI-xiaozhuguang"), or:

cd ComfyUI/custom_nodes/
git clone https://github.com/xiaozhuguang/ComfyUI-xiaozhuguang.git

Restart. No model downloads.

Gotcha

The whole point is that the padding is metadata-aware: keep the front_fill and original_count outputs around if you plan to feed the padded video into the pack's FrameExtract later - that's the exact pair that lets you strip the duplicated frames and get your original sequence back. And remember the padding is duplicated frames, not interpolated ones: a short source gets longer, but it doesn't get smoother. For smoothness you want an actual interpolation node upstream.

Categoryxiaozhuguang

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
multi_fillBOOLEANfalse

Outputs (7)

NameTypeDescription
imageIMAGE
frame_countINT
original_countINT
front_fillINT
back_fillINT
first_frameIMAGE
last_frameIMAGE