Nodes/comfyui-videoframenode/Video: First & Last Frame
ComfyUI Node

Video: First & Last Frame

The boring node your I2V workflow quietly needs

By esp-dev·Created 8 months ago·Updated 7 months ago· 4
Video: First & Last Frame
  • video_in
  • FIRST_FRAME
  • LAST_FRAME
video

This node does exactly one thing, and it's a thing you'll need the moment you start doing serious image-to-video work: you point it at an .mp4, it hands you the first frame and the last frame as two regular ComfyUI IMAGE tensors. That's it. No models, no sampler, no VRAM footprint to speak of.

Why that matters: almost every real video workflow is anchored on endpoints. In Wan and LTX I2V, the first frame is your conditioning image - the thing the model animates forward from. And the last frame is what you feed back in when you want to continue a clip instead of letting the model reinvent the ending. The community pattern of draft-in-LTX-then-refine-in-Wan is basically a first-frame handoff between pipelines. This node is the plumbing between those two images and your graph, so you don't have to export a still from a video player and drag it into the input folder by hand.

How it works

Under the hood it's OpenCV, not ffmpeg magic. It opens the file with cv2.VideoCapture, reads frame 0, then jumps to frame_count - 1 to grab the last one - with a fallback that scans to the end if seeking fails, and a second fallback to imageio[ffmpeg] if OpenCV isn't importable. Either way it converts BGR→RGB, normalizes to 0–1, and returns a [1, H, W, C] tensor, which is what ComfyUI's IMAGE type expects. It also saves a preview thumbnail so you see the first frame on the node without wiring up a preview node.

The inputs that matter

  • video (string, required): a filename from ComfyUI/input, a path with an input/, output/, or temp/ prefix, or an absolute path. This is the field you'll set 95% of the time.
  • video_in (optional, any type): accepts a path string, a dict with a path/filename key, or an actual batch of IMAGE tensors - in which case it skips the file entirely and just takes element 0 and the last element. Handy when the "video" is already frames in your graph.

Outputs are FIRST_FRAME and LAST_FRAME, both IMAGE. Wire FIRST_FRAME into your I2V model's image conditioning, or both into a loop-extension setup.

Install

Easiest path is ComfyUI Manager - search "comfyui-videoframenode" and hit install, then restart. Manual install is the usual clone:

cd ComfyUI/custom_nodes
git clone https://github.com/esp-dev/comfyui-videoframenode
pip install -r requirements.txt

Dependencies are just opencv-python and imageio[ffmpeg]. Notice torch is deliberately missing from that file - the author comments it out so a naive pip install doesn't clobber ComfyUI's CUDA build. Don't go "fixing" that.

Where people get burned

  • "Video file not found" - remember video resolves against ComfyUI/input. Either drop the file there (drag-and-drop onto the node does this for you) or give an absolute path.
  • "Could not read video frames" - that's the node telling you neither OpenCV nor imageio is importable. pip install opencv-python in ComfyUI's venv.
  • Drag-and-drop and the recent-files dropdown are UI-only. In API mode the core node still works, just set video yourself.

One honest caveat: this is a brand-new, single-node pack from a small author with basically zero community chatter yet. The code is simple and readable if you want to eyeball it before trusting it - which, given ComfyUI's no-sandbox reality, isn't a bad habit for any custom node.

Categoryvideo

Inputs (2)

NameTypeDefaultDescription
videoSTRING
video_inopt*

Outputs (2)

NameTypeDescription
FIRST_FRAMEIMAGE
LAST_FRAMEIMAGE