Nodes/First Frame & Last Frame Extractor/First Frame & Last Frame Extractor 🎬
ComfyUI Node

First Frame & Last Frame Extractor 🎬

Grab the First and Last Frame of Any Video Without Losing Your Mind

By RmaNMetaverseΒ·Created about a month agoΒ·Updated about a month agoΒ· 7
First Frame & Last Frame Extractor 🎬
  • images
  • first_frame
  • last_frame
β—„video_pathβ–Ί

Some workflows need one thing done and one thing only: pull the very first and very last frame out of a video. Maybe you're building an img2video workflow - Wan-style models will happily morph between a start and end image - or you want a quick before/after comparison, or you need the last frame of a clip as the first frame of the next one. This node is that job, and nothing else. It's a single utility node from a pack called First Frame & Last Frame Extractor that takes any video in and hands you two clean IMAGE tensors out.

It's genuinely tiny, and that's the point. It's the kind of plumbing node you'd rather have than type ffmpeg incantations into a terminal, especially mid-workflow when you just want the frames to flow into a Preview Image or straight into a sampler.

How it works

The node has two input modes and picks between them automatically. If you feed it an images batch - say, the IMAGE output of a VideoHelperSuite Load Video node - it takes images[0] and images[-1], the first and last tensors in the batch, and clones them so the giant parent batch can be garbage-collected right away instead of lingering in VRAM. Slick little touch.

If you instead type a file path into video_path, it opens the file with OpenCV, seeks to frame 0 and to frame_count - 1, and reads both. Some codecs won't seek cleanly to the last frame, so it falls back to reading sequentially until the end. Frames are converted from OpenCV's BGR to RGB, normalized to float32 in the 0–1 range, and returned with a batch dimension, which is exactly what every downstream ComfyUI node expects. The code also strips stray quotes you might paste around a path - a small mercy, because people do that constantly.

The inputs that matter

Only two inputs exist, and both are optional:

  • video_path - a STRING. The absolute path to a video file (.mp4, .avi, .mkv, .mov, .webm, .gif per the tooltip).
  • images - an IMAGE batch from any node that outputs one.

You need at least one of them. If you connect both, the image batch wins - the node never reads the file, which saves you from accidentally re-decoding a huge video. Outputs are first_frame and last_frame, both single-image IMAGE tensors shaped [1, H, W, C]. Wire them to Preview Image, Save Image, or any downstream node.

Installing it

Easiest route is ComfyUI Manager: search for "FirstFrameLastFrame" or "First Frame Last Frame" and hit install. Or clone it manually:

cd ComfyUI/custom_nodes
git clone https://github.com/RmaNMetaverse/ComfyUI-FirstframeLastframeExtractor.git

Then restart ComfyUI. You'll find it under Add Node β†’ Video/Utils β†’ First Frame & Last Frame Extractor 🎬. The only real dependency is opencv-python-headless>=4.5.0 - torch and numpy are already in every ComfyUI install, so there are no model files to download and no API key to hunt for. The one gotcha the README hammers on: if you're on the Windows portable build, install requirements with the embedded Python (python_embeded\python.exe -m pip install -r ...\requirements.txt), not your system Python, or ComfyUI won't see the package. The usual custom-node dependency hell (see the ecosystem docs) is barely a factor here - it's about as low-risk a pack as you can install.

Common issues

Most failures are input problems, and the node's error messages tell you exactly what's wrong. Blank or missing path β†’ "No input provided." Wrong path β†’ "Video file not found." Unreadable file β†’ "Could not open video file." If a codec resists seeking, the sequential fallback handles it, but it's slower on long clips - nothing to fix, just something to know. One tip from real life: give it an absolute path, not a relative one, and don't worry about quoting - it strips quotes either way.

CategoryVideo/Utils

Inputs (2)

NameTypeDefaultDescription
video_pathoptSTRINGAbsolute path to a video file (.mp4, .avi, .mkv, .mov, .webm, .gif)
imagesoptIMAGEβ€”

Outputs (2)

NameTypeDescription
first_frameIMAGEβ€”
last_frameIMAGEβ€”