Nodes/comfyui-AGSoft/🎬AGSoft LastFrameExtractor
ComfyUI Node

🎬AGSoft LastFrameExtractor

Grab the last frame of a video without decoding the whole thing by hand

By Art-xmaster·Created 12 months ago·Updated about 18 hours ago· 23
🎬AGSoft LastFrameExtractor
  • video
  • video_frames
  • frame
  • width
  • height
  • total_frames
  • video_metadata_json
custom_path
frame_offset_from_end1

Every video pipeline needs "the last frame" at some point - as the starting frame for a continuation, as a thumbnail, or as the img2img base for what comes next. Stock ComfyUI doesn't hand you that on a plate; you'd load all the frames and index into the batch. AGSoft LastFrameExtractor pulls a single frame from the end of a video file, at whatever offset you want, and returns it with the video's metadata attached.

The offset is the feature. frame_offset_from_end = 1 gives you the very last frame, 2 the second-to-last, and so on. That matters more than it sounds: video files often end on a fade, a black frame, or a credit card, and being able to reach one or two frames back means you don't have to eyeball a frame count or trim the file first.

How it works

The node takes three possible sources, in priority order:

  1. video - a VIDEO object from Video Helper Suite's Load Video node or standard ComfyUI's loader. Highest priority; if it's connected, the other sources are ignored.
  2. video_frames - pre-loaded frames as an IMAGE tensor. Medium priority; used when no VIDEO object is attached.
  3. custom_path - a path to the video file. Lowest priority, so it's the fallback when nothing's connected.

It reads the source, counts the frames, and extracts the one frame_offset_from_end frames from the end. If you've already got a VIDEO object in your graph from a VHS loader, this node is basically a zero-setup drop-in.

Outputs

  • frame (IMAGE) - the extracted frame, ready for a VAE encode or as an image.
  • width / height (INT) - the frame's dimensions.
  • total_frames (INT) - the video's frame count. Often the more useful number for scheduling.
  • video_metadata_json (STRING) - metadata as a JSON string, which you can pipe into a text display or parse if you're automating.

Installation

It's part of comfyui-AGSoft:

cd ComfyUI/custom_nodes
git clone https://github.com/Art-xmaster/comfyui-AGSoft.git
# restart ComfyUI

Or ComfyUI Manager → search "comfyui-AGSoft". The pack pulls in numpy and opencv-python; video reading leans on whatever video backend ComfyUI already has (VHS installs its own), so no extra model files.

Where people get burned

The number one confusion is the priority order - people wire up a custom_path and a video at the same time and wonder why the path is being ignored. The tooltip is explicit: the VIDEO object wins. If you're testing with a path, leave the video inputs unplugged. Second, remember this extracts one frame. If you need a spread of frames or a true thumbnail strip, the pack's VideoFrameExtractor is the sibling that does ranges. And if the last frame comes back black, that's usually the video's own last frame (fades) - bump frame_offset_from_end to 2 or 3 and move on.

CategoryAGSoft/Video

Inputs (4)

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_offset_from_endINT11–10000 Position from the end of the video (1-based). frame_offset_from_end=1 - extracts the very last frame. frame_offset_from_end=2 - extracts the second-to-last frame. frame_offset_from_end=3 - extracts the third-to-last frame, etc. Позиция от конца видео (нумерация с 1). frame_offset_from_end=1 - извлекает самый последний кадр. frame_offset_from_end=2 - извлекает предпоследний кадр. frame_offset_from_end=3 - извлекает третий с конца кадр и т.д.
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' не подключен.

Outputs (5)

NameTypeDescription
frameIMAGE
widthINT
heightINT
total_framesINT
video_metadata_jsonSTRING