Nodes/ComfyUI-ALICE-Lab-Audio-Tools/Video First / Last Frame
ComfyUI Node

Video First / Last Frame

Video First / Last Frame

By alice-lab-dev·Created 16 days ago·Updated 2 days ago· 2
Video First / Last Frame
  • video
  • first_frame
  • last_frame

Sometimes you don't need the video at all - you just need its two bookend frames. Video First / Last Frame takes any ComfyUI VIDEO and hands you first_frame and last_frame as plain IMAGE outputs. That sounds trivial, but it's genuinely useful, because in ComfyUI-land video is still a second-class citizen and "get me one frame out of this" is not a button you get for free.

Why would you reach for it? A few honest reasons. You trim a segment with a Media Range node and want its boundaries as stills for a thumbnail or a quick sanity check. You're doing the classic "first frame conditions, last frame verifies" trick in a video-generation workflow - feed the start frame as an image condition and compare the end frame against what the model produced. Or you just want to eyeball the start/end of a generated clip without loading the whole thing into a preview node and scrubbing. It's plumbing, but plumbing you'll actually use.

How it works

This node is a good example of why the ALICE Lab pack requires a current ComfyUI build. It leans on the modern video API (comfy_api.latest) and does two different things depending on how the VIDEO arrived:

  • If the video is in-memory (components-backed, the common case for freshly generated clips), it slices frames[:1] and frames[-1:] directly - instant, no re-decode.
  • If it's file/stream-backed (a loaded media file), it does something smarter than decoding the whole clip. It only decodes a small boundary window at each end through ComfyUI's trim API - at least two nominal frames (50 ms) to tolerate timestamp rounding - and it hunts down the true last frame by inspecting stream timestamps with PyAV rather than trusting the container duration, which can run past the final video frame when there's a longer audio track. The payoff: memory use doesn't scale with video length. A two-hour file costs you the same as a ten-second one.

The outputs keep the IMAGE batch dimension ([1, H, W, C]), so they wire straight into any node that expects a single-frame image - no reshaping gymnastics.

Inputs and outputs that matter

There's exactly one input and two outputs, so there's not much to configure:

  • video (VIDEO) - whatever you're pulling frames from.
  • Outputs first_frame and last_frame (IMAGE) - the two boundary frames.

That's it. No model files, no sliders, no hidden state. If the video is empty or zero-duration, it raises a clear "Video contains no frames" error instead of silently returning garbage.

Installing it

Same as every node in this pack - the whole ALICE Lab Audio Tools collection installs in one go, and it's refreshingly light: no pip dependencies beyond what ComfyUI already ships (PyAV is bundled with ComfyUI, so the stream-timestamp logic "just works") and no models to download. The one external requirement is ffmpeg and ffprobe on the PATH of the process that starts ComfyUI - if ComfyUI launches from a GUI on macOS, it also checks the Homebrew locations /opt/homebrew/bin and /usr/local/bin.

Easiest via ComfyUI Manager (search "ALICE Lab Audio Tools"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/alice-lab-dev/ComfyUI-ALICE-Lab-Audio-Tools

Restart ComfyUI and the nodes appear under ALICE_LabVideo. Because it uses the current video API, update ComfyUI if the nodes don't show up - an outdated ComfyUI is the #1 cause of "video nodes missing."

Where people get burned

Two things, both simple. First: this pack is alpha and its README says interfaces may still change - don't be surprised if a future version tweaks behavior. Second: the node needs a VIDEO-typed input, which means something upstream has to produce one (a Media Range node, a video-generation pack, or the new file-loading nodes). Feed it a plain path string or an IMAGE and you'll get a validation error like "Input is not a valid ComfyUI VIDEO." The video ecosystem is where ComfyUI has no real competition, but it's also where the APIs are moving fastest - if you're on a six-month-old ComfyUI, update before debugging this node.

CategoryALICE_Lab/Video

Inputs (1)

NameTypeDefaultDescription
videoVIDEO

Outputs (2)

NameTypeDescription
first_frameIMAGE
last_frameIMAGE