ComfyUI Node

Loop GIF

The Loop GIF node turns ComfyUI VIDEO into seamless GIFs

By HM1579·Created 4 months ago·Updated 4 months ago· 0
Loop GIF
  • video
  • gif_path
  • images
  • frame_rate
filename_prefixgif
delete_ratio0.10
gif_fps24.00
blend_frames2
blend_strength0.10
color_drift_strength0.00

If the GIF doesn't loop, it's just a video

You generated a two-second Wan or LTX image-to-video clip and it's lovely - right up until the last frame snaps back to the first and the whole thing judders. Looping is where short AI video dies, and that's exactly the problem this pack's single node, Loop GIF, exists to fix. Feed it a ComfyUI VIDEO, tell it how much slop to trim off the ends, and it hands you back a GIF file plus the processed frames.

It's a finishing tool, not a magic wand - it can't rescue a clip whose last frame is nothing like its first. But for image-to-video workflows where you deliberately used the same start and end image, it's the difference between "nice clip" and "GIF someone actually shares."

How it works

Mechanically it's ffmpeg plus Pillow wearing a ComfyUI costume. The node takes your VIDEO input and resolves it one of two ways: if it's an in-memory video (like frames from VideoHelperSuite's VideoFromComponents or another node building video inside the graph), it writes the frames out as PNGs; if it's a file path, it shells out to ffmpeg to extract a frame sequence. Then it works down a short list:

  1. delete_ratio chops a matching number of frames off head and tail
  2. optional color drift correction nudges later frames toward the first frame's average color
  3. optional seam blending crossfades the new head and tail frames into each other
  4. ffmpeg's palettegen + paletteuse produce a proper palette-limited GIF

It wipes its temp .output_name_work folder afterward whether the run succeeds or fails, so you won't find frame dumps littering your output directory.

The inputs that matter

  • delete_ratio - the star. Default 0.10, recommended 0.05–0.15. It removes that fraction of frames from both ends so the loop seam lands mid-motion instead of on the frozen or glitchy first frames. Set it to 0 and the node becomes a plain GIF exporter.
  • gif_fps - default 24, keep it in the 18–24 range. Higher looks smoother but bloats the file.
  • blend_frames / blend_strength - defaults 2 and 0.10. Mild smoothing at the seam. Crank blend_frames past a few and you'll get ghosting; this is seasoning, not a fix. Note it only engages when delete_ratio is above 0 - with trimming off, the original first/last structure is left untouched.
  • color_drift_strength - default 0, capped at 3. Targets the "last frame has a slightly different color tone, so the loop flashes" problem. The author calls it experimental; treat it as a last resort.
  • filename_prefix - what the GIF in your output folder gets called.

Outputs: gif_path (the saved file), images (the processed frames - handy to pipe into VideoHelperSuite's Video Combine for an in-workflow GIF preview), and frame_rate.

Installing it

ComfyUI Manager - search "ComfyUI-LoopGif" - or the registry:

comfy node install comfyui-loopgif

Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/HM1579/ComfyUI-LoopGif.git
cd ComfyUI-LoopGif
/path/to/your/comfyui/python -m pip install -r requirements.txt

Then restart ComfyUI. No model downloads, no API keys, nothing heavy at runtime - the requirements are just numpy, Pillow, and imageio-ffmpeg. The one real dependency is ffmpeg: it prefers your system install (checking the usual Homebrew paths on macOS), and falls back to the ffmpeg bundled with imageio-ffmpeg if you don't have one.

Gotchas

  • Hit a Chinese error about the video having too few frames? That's the <4-frame guard. Looping math needs a handful of frames to work with; generate a longer clip.
  • The loop only looks good if the source actually returns to its start. The author's advice is worth stealing: use the same first and last image, and prompt the return motion, not just the action - describe the recovery, or there won't be frames left to do it in.
  • Seam quality lives in the source video, not in this node. delete_ratio alone fixes most loops; the blend and color-drift sliders are polish you add when the simple fix isn't enough.
Categoryvideo/gif

Inputs (7)

NameTypeDefaultDescription
videoVIDEO
filename_prefixSTRINGgif
delete_ratioFLOAT0.100–0.8
gif_fpsFLOAT24.001–60
blend_framesINT20–8
blend_strengthFLOAT0.100–1
color_drift_strengthFLOAT0.000–3

Outputs (3)

NameTypeDescription
gif_pathSTRING
imagesIMAGE
frame_rateFLOAT