Nodes/ComfyUI-CustomNodeKit/图像批次指定帧复制 (Frame Replicate)
ComfyUI Node

图像批次指定帧复制 (Frame Replicate)

BatchFrameReplicate for longer first/last frames and keyframe pauses

By user2318·Created 4 months ago·Updated about a month ago· 56
图像批次指定帧复制 (Frame Replicate)
  • image_a
  • image_b
  • image_a
  • image_b
enabledtrue
image_index0
copy_count0

Sometimes the best edit is to just stop time for a beat. You've generated a video and the first frame whooshes away before anyone sees it, or you want a keyframe to linger like a held breath, or a pose stays still for two frames and you need it for eight. BatchFrameReplicate is the plumbing node for that: it picks one image out of a batch and inserts copies of it right behind itself.

It's dead simple to use, so most of this article is about the two things people miss. First, it has two independent channels - image_a and image_b - and each is processed separately with the same settings. That's the killer feature. In the pack's WanAnimate workflows this is how you keep a character reference sequence and its mask sequence in lockstep while stretching a frame: run both through one node, same image_index, same copy_count, and both come out the same length. Second, the settings are a single global pair, so you can't do "2 copies of frame 0 on channel A, 5 copies on channel B" in one node - if you need different amounts, use two of them.

What you set

  • image_index - which frame to replicate. 0 is the first, -1 is the last, -2 second-to-last, and anything out of range gets clamped to a valid frame. Negative indexing is how you stretch the end of a clip.
  • copy_count - how many copies to insert. 0 means pass through untouched.
  • enabled - the master switch. Off, and both channels pass through unchanged. Leave it wired to a toggle if you want to A/B the timing without re-splicing the graph.

Each channel outputs back out as image_a / image_b. Unplugged channels just output None, so it won't crash your graph if you only feed one side.

When you'd reach for it

  • Lengthen the hold on a clip's first or last frame before you encode to video - image_index = -1, copy_count = N is the classic "let the ending breathe" move.
  • Keyframe pauses in pose-driven work: the pack's SCAIL/WanAnimate workflows use it to make a character linger on a critical pose.
  • Frame-count padding: when a downstream node demands a batch length that your segment doesn't have yet, replicate the last frame to top it up.

This is unapologetic plumbing - it touches no pixels, no models, no math beyond a torch repeat and a torch.cat. If you're new to ComfyUI, that's the point: the ecosystem is 70% nodes like this (see the KB's node-plumbing doc), and knowing exactly what one does lets you spot it in other people's graphs.

Install

It ships in user2318/ComfyUI-CustomNodeKit. ComfyUI Manager: search "CustomNodeKit". Or:

cd ComfyUI/custom_nodes
git clone https://github.com/user2318/ComfyUI-CustomNodeKit.git
cd ComfyUI-CustomNodeKit
pip install -r requirements.txt

then restart. No extra models, no downloads, nothing heavy - this one only needs the pack's base install.

The gotcha

Remember that copy_count counts copies, not final length. With copy_count = 2 on frame 0 of [A, B, C], you get [A, A, A, B, C] - three A's total. Counts off by one are the classic mistake, and the pack's own README uses exactly that example. Also note it inserts after the chosen frame, so replicating frame 0 grows the head of the clip and replicating -1 grows the tail. If you replicate a middle frame you get a pause, not a loop - if you actually want a freeze-frame loop effect, that's a different node (BatchImageReplace is your friend there).

Categoryimage

Inputs (5)

NameTypeDefaultDescription
enabledBOOLEANtrue总开关。关闭时各路直接透传,不做任何复制。Master switch. When disabled, all channels pass through unchanged.
image_indexINT0-4294967295–4294967295要复制的图像索引。0=第一张,-1=最后一张,-2=倒数第二张,以此类推。越界时自动限制到有效范围。Index of the image to replicate. 0=first, -1=last, -2=second-to-last. Clamped to valid range automatically.
copy_countINT00–4294967295复制多少份。0=不复制,直接透传。Number of copies to make. 0=pass through (no replication).
image_aoptIMAGE第一路图像批次输入 [B, H, W, C],未连接时对应输出为 None。Channel A image batch input [B, H, W, C]. When disconnected, output is None.
image_boptIMAGE第二路图像批次输入 [B, H, W, C],未连接时对应输出为 None。Channel B image batch input [B, H, W, C]. When disconnected, output is None.

Outputs (2)

NameTypeDescription
image_aIMAGE
image_bIMAGE