🎬AGSoft VideoFrameExtractor
Grab the exact frames you need from any video — first, last, or an even sample
- video
- video_frames
- frame
- width
- height
- total_frames
- video_metadata_json
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:
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.video_frames- pre-loaded frames as an image tensor. Middle priority; used only ifvideoisn't connected.custom_path- an absolute or relative path to a video file. Lowest priority, so a connectedvideoorvideo_framesalways 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_COUNTin 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- fromstart_frametoend_frame, stepping bystep.sample-num_framesframes evenly distributed across the whole video. The "give me 10 frames that cover this whole clip" mode.all- every frame with the givenstep(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
cv2isn't installed, so if this node is missing from the menu but the pack otherwise loaded,pip install opencv-pythonis your fix. - Path not found - remember priority: if
videoorvideo_framesis connected,custom_pathis 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
lastmode has the robust fallback. Don't trusttotal_framesfor math on imperfectly-muxed files. - Slow extraction on long files -
allwith a small step decodes a lot of video. Usesampleor bumpstepunless 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.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| custom_path | STRING | Absolute or relative path to the video file. Has the lowest priority when video or video_frames are connected. Абсолютный или относительный путь к видеофайлу. Имеет наименьший приоритет, если подключены video или video_frames. | |
| frame_selection_mode | COMBO | first | 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'. |
| videoopt | VIDEO | 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_framesopt | IMAGE | 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_frameopt | INT | 11–10000000 | Frame number to extract (1-based index). Used only in 'exact_frame' mode. Номер кадра для извлечения (нумерация с 1). Используется только в режиме 'exact_frame'. |
| start_frameopt | INT | 11–10000000 | Starting frame number for 'range' mode (1-based index). Used only in 'range' mode. Начальный номер кадра для режима 'range' (нумерация с 1). Используется только в режиме 'range'. |
| end_frameopt | INT | 1001–10000000 | Ending frame number for 'range' mode (1-based index). Used only in 'range' mode. Конечный номер кадра для режима 'range' (нумерация с 1). Используется только в режиме 'range'. |
| num_framesopt | INT | 101–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' для определения количества кадров, равномерно распределенных по видео. |
| stepopt | INT | 101–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)
| Name | Type | Description |
|---|---|---|
| frame | IMAGE | — |
| width | INT | — |
| height | INT | — |
| total_frames | INT | — |
| video_metadata_json | STRING | — |