Nodes/comfyui-myloadvideo/My Drop Last Frames
ComfyUI Node

My Drop Last Frames

Trim the garbage off the end of your frame batch

By 1123156819·Created 3 months ago·Updated 3 months ago· 0
My Drop Last Frames
  • images
  • IMAGES
  • frame_count
drop_last_n5

Videos rarely end cleanly. There's the fade to black nobody asked for, the last few frames where the model gave up and smeared, the awkward frozen tail before the loop point. My Drop Last Frames exists to cut all of that off: give it an IMAGE batch, tell it how many frames to shed from the end, and it hands back a trimmed batch. That's the whole job, and it does it without fuss.

It's the smallest node in the comfyui-myloadvideo pack, and the one you'll bolt on almost as an afterthought. Load a clip, notice the last handful of frames are junk, and drop a node in instead of reloading with a different frame_load_cap. It's also the classic fix for looped video: generate a clip with a visible seam at the tail and simply trim past it.

How it works

One line of Python, essentially:

selected_images = images[:-drop_last_n]

It slices the batch down to everything except the last n frames and returns the new tensor. Two guardrails matter: set drop_last_n to 0 and it's a no-op that passes the batch straight through, which is a handy way to keep the node in a shared workflow without it doing anything. And if you ask it to drop more frames than the batch has, it refuses with a ValueError rather than silently handing you an empty batch - annoying at first, but it beats debugging a graph that just stops producing output.

The inputs and outputs that matter

There are exactly two inputs:

  • images - any IMAGE batch: output from a video loader, from VAEEncode, from a batch of generated frames.
  • drop_last_n (default 5) - how many frames to cut from the end.

Both outputs come back like the rest of this pack: IMAGES is your trimmed batch, and frame_count is an INT reporting how many frames remain. If your downstream node needs a specific count - a fixed-length context for a video model, say - wire frame_count somewhere visible and confirm the numbers line up before the long run.

Installing it

Same story as its packmates - it's one of three nodes in comfyui-myloadvideo, and you get all of them in one install. Clone it or use ComfyUI Manager:

cd ComfyUI/custom_nodes
git clone https://github.com/1123156819/comfyui-myloadvideo.git

Restart ComfyUI and My Drop Last Frames appears under image/video. No models, no new dependencies - it's the same opencv-python/numpy/Pillow stack ComfyUI already ships with.

Where people get burned

Dropping before the VAE is a trap. This node works on raw IMAGE batches, so you can place it before VAEEncode or after VAEDecode. Do it after: the frames you're dropping are the generated frames you actually want to inspect and keep, and trimming before encode just wastes the compute that went into them. The one exception is when you're using the loaded video as conditioning - there, trim early to skip encoding frames you'll never use.

Overlapping your trim and cap. If you already set a tight frame_load_cap on the loader, the tail you're trying to drop might not exist. The error message tells you exactly how many frames you have, so read it, then adjust one of the two.

Thinking it fixes audio. It doesn't - this pack is frames-only, no audio track anywhere. If your workflow carries sound, drop the frames in ComfyUI but trim the audio in your editor, or use a pack that handles both.

Categoryimage/video

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
drop_last_nINT50–999999

Outputs (2)

NameTypeDescription
IMAGESIMAGE
frame_countINT