Nodes/ComfyUI-UniversalToolkit/Extract Video Frames (UTK)
ComfyUI Node

Extract Video Frames (UTK)

Pull exactly N frames out of a video — evenly, front-loaded, or tail-heavy

By whmc76·Created about a year ago·Updated 2 months ago· 72
Extract Video Frames (UTK)
  • images
  • images
  • frames_count
video_path
target_frames8
modeaverage

Video-to-video workflows usually start the same way: you have a clip and you want a handful of frames to drive img2video, a context window, or a pose pass. The naive approach is "grab one every N frames," which is wrong more often than not - action is usually front-loaded, loops need their endpoints, and the middle of a shot is where nothing happens. Extract Video Frames (UTK) gives you control over where those N frames come from, which is the part everyone ignores until a generation drifts.

How it works

It reads a video file with OpenCV (mp4, avi, mov - whatever cv2 opens), or, if you feed the optional images input, it uses your image sequence instead and ignores the path entirely (the tooltip says so explicitly, and the code honors it). You set target_frames and a mode, and it computes frame indices with a weighted sampling pattern rather than blind stride:

  • average - uniform spacing across the whole clip. The safe default.
  • front_heavy - roughly 60% of frames from the first half. Good for clips where the action opens the shot.
  • back_heavy - the reverse, 60% from the second half.
  • middle_heavy - favors the center, where a subject is usually in frame and doing something.
  • ends_heavy - samples both ends hard. This is the one for loopable sequences, because the endpoints are exactly what your loop boundary needs to match.

If you ask for more frames than the clip has, it just returns every frame - no crash, no weird interpolation.

Outputs

Two: images (an IMAGE batch you feed straight into your video model or a batch node) and frames_count (the integer count, handy for logging or feeding a context-window calculator).

Installing it

Part of the ComfyUI-UniversalToolkit pack:

  • ComfyUI Manager → search ComfyUI-UniversalToolkit → Install → restart, or
  • cd ComfyUI/custom_nodes && git clone https://github.com/whmc76/ComfyUI-UniversalToolkit then pip install -r requirements.txt and restart.

It needs opencv-python, which is in the pack's requirements - if you install via Manager that's handled for you.

Gotchas

  • The path is a literal filesystem path, not the ComfyUI upload dialog. No drag-and-drop file picker here. If you want the input-panel experience, load the video as frames elsewhere and feed the images input instead.
  • Front/back heavy are 60/40 splits, not dramatic. Don't expect a five-frame burst at the start; it's a gentle skew that keeps temporal coverage.
  • Frame order is preserved - the output batch keeps clip order, which your video model will quietly assume. Handing it shuffled frames is how you get motion that looks like a slideshow.

It's a small, honest utility: no models, no magic. If you do a lot of video-to-video, the ends_heavy mode alone is worth having, because loop drift is usually a frame-selection problem and this is the cheapest fix for it.

CategoryUniversalToolkit/Tools

Inputs (4)

NameTypeDefaultDescription
video_pathSTRING视频文件路径(支持mp4, avi, mov等格式)
target_framesINT81–1000目标抽取的帧数
modeCOMBOaverageFrame extraction mode
imagesoptIMAGE图片序列输入(如果提供,将优先使用图片序列而不是视频)

Outputs (2)

NameTypeDescription
imagesIMAGE
frames_countINT