Nodes/comfyui-AGSoft/🎬AGSoft VideoFrameExtractor
ComfyUI Node

🎬AGSoft VideoFrameExtractor

Grab the exact frames you need from any video — first, last, or an even sample

By Art-xmaster·Created 12 months ago·Updated a day ago· 23
🎬AGSoft VideoFrameExtractor
  • video
  • video_frames
  • frame
  • width
  • height
  • total_frames
  • video_metadata_json
custom_path
frame_selection_modefirst
exact_frame1
start_frame1
end_frame100
num_frames10
step10

Img2vid workflows need a starting frame. Thumbnails need a representative frame. Contact sheets need an even spread. 🎬AGSoft VideoFrameExtractor from comfyui-AGSoft is the Swiss-army frame picker: first, last, one specific frame, a range, an even sample, or everything - with width, height, total frame count, and metadata JSON all coming out the other side. One node replaces a pile of fragile Python hacks.

How it works

The engine is OpenCV (cv2.VideoCapture), which the pack declares as a dependency. You can feed it three ways, in a strict priority order:

  1. video - a video object from Video Helper Suite's Load Video or ComfyUI's built-in Load Video node. Highest priority; if it's connected, everything else is ignored.
  2. video_frames - pre-loaded frames as an image tensor. Middle priority; used only if video isn't connected.
  3. custom_path - an absolute or relative path to a video file. Lowest priority, so a connected video or video_frames always beats your path.

The frame_selection_mode dropdown is where the real power is:

  • first - the very first frame. The default, and the usual "give me a start frame for img2vid" pick.
  • last - the last frame, via what the author calls a "robust method". That's not marketing: CAP_PROP_FRAME_COUNT in OpenCV is frequently wrong on some containers, so the node seeks and validates to find the last readable frame.
  • exact_frame - one frame by number (1-based, so frame 1 is the first frame).
  • range - from start_frame to end_frame, stepping by step.
  • sample - num_frames frames evenly distributed across the whole video. The "give me 10 frames that cover this whole clip" mode.
  • all - every frame with the given step (step 2 = every second frame).

The outputs

  • frame (IMAGE) - the extracted frame(s) as a normal image batch, ready for VAE encode, img2img, or preview.
  • width, height, total_frames (INT) - video dimensions and frame count.
  • video_metadata_json (STRING) - a JSON blob with the video's info, handy for logging or scripting around it.

Why you'd reach for it

The classic combo: load a video, extract frame 1, feed it to a KSampler as img2img to restyle the video, then reassemble. Or extract ten evenly sampled frames to see what a long clip actually contains without decoding all of it. If you're building video pipelines, this is the picker you'll wire in front of everything else.

Installing it

It's part of the big comfyui-AGSoft utility pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Art-xmaster/comfyui-AGSoft.git
cd comfyui-AGSoft && pip install -r requirements.txt
# restart ComfyUI

Or search comfyui-AGSoft in ComfyUI Manager. The one dependency that actually matters for this node is opencv-python - if the node errors on import, that's what's missing.

Troubleshooting

  • "OpenCV (cv2) is required" - the node hard-fails at import if cv2 isn't installed, so if this node is missing from the menu but the pack otherwise loaded, pip install opencv-python is your fix.
  • Path not found - remember priority: if video or video_frames is connected, custom_path is ignored. You can point the path at a file, change it, and see no difference because a socket is still plugged in.
  • Total frames slightly off - expected on some formats; that's literally why the last mode has the robust fallback. Don't trust total_frames for math on imperfectly-muxed files.
  • Slow extraction on long files - all with a small step decodes a lot of video. Use sample or bump step unless you genuinely need every frame.

Note the pack's loader logs per-module import failures and keeps going - so if this node vanishes but the rest of comfyui-AGSoft is fine, cv2 is the usual suspect.

CategoryAGSoft/Video

Inputs (9)

NameTypeDefaultDescription
custom_pathSTRINGAbsolute or relative path to the video file. Has the lowest priority when video or video_frames are connected. Абсолютный или относительный путь к видеофайлу. Имеет наименьший приоритет, если подключены video или video_frames.
frame_selection_modeCOMBOfirst first: Extracts the very first frame. last: Extracts the very last frame (robust method). exact_frame: Extracts a single frame by its number. range: Extracts frames from 'start_frame' to 'end_frame' with 'step'. sample: Extracts 'num_frames' evenly spaced frames. all: Extracts all frames with the given 'step'. first: Извлекает самый первый кадр. last: Извлекает самый последний кадр (надежным методом). exact_frame: Извлекает один кадр по его номеру. range: Извлекает кадры от 'start_frame' до 'end_frame' с шагом 'step'. sample: Извлекает 'num_frames' равномерно распределенных кадров. all: Извлекает все кадры с заданным шагом 'step'.
videooptVIDEO Video object from Video Helper Suite (VHS) Load Video node or standard ComfyUI Load Video. Has the highest priority. If connected, video_frames and custom_path are ignored. Видеообъект от ноды Load Video из Video Helper Suite (VHS) или стандартного ComfyUI. Имеет наивысший приоритет. При подключении video_frames и custom_path игнорируются.
video_framesoptIMAGE Pre-loaded video frames as tensor (e.g., from VHS or LoadVideo node). Has medium priority. Used only if 'video' is not connected. Предварительно загруженные кадры видео в виде тензора (например, из VHS или LoadVideo). Имеет средний приоритет. Используется только если 'video' не подключен.
exact_frameoptINT11–10000000 Frame number to extract (1-based index). Used only in 'exact_frame' mode. Номер кадра для извлечения (нумерация с 1). Используется только в режиме 'exact_frame'.
start_frameoptINT11–10000000 Starting frame number for 'range' mode (1-based index). Used only in 'range' mode. Начальный номер кадра для режима 'range' (нумерация с 1). Используется только в режиме 'range'.
end_frameoptINT1001–10000000 Ending frame number for 'range' mode (1-based index). Used only in 'range' mode. Конечный номер кадра для режима 'range' (нумерация с 1). Используется только в режиме 'range'.
num_framesoptINT101–10000000 Number of frames to extract in 'sample' mode. Used only in 'sample' mode to determine how many frames to evenly distribute across the video. Количество кадров для извлечения в режиме 'sample'. Используется только в режиме 'sample' для определения количества кадров, равномерно распределенных по видео.
stepoptINT101–1000000 Extract every Nth frame. For example, step=2 will extract every second frame, reducing the total number of frames by half. Used only in 'range' and 'all' modes. Извлекать каждый N-й кадр. Например, step=2 будет извлекать каждый второй кадр, уменьшая общее количество кадров вдвое. Используется только в режимах 'range' и 'all'.

Outputs (5)

NameTypeDescription
frameIMAGE
widthINT
heightINT
total_framesINT
video_metadata_jsonSTRING