Nodes/ComfyUI-Video-Edit/Video Get Total Frames
ComfyUI Node

Video Get Total Frames

How many frames is this thing, anyway?

By guchendesigndog·Created 4 months ago·Updated 4 months ago· 6
Video Get Total Frames
  • video
  • total_frames

VideoGetTotalFrames answers one question: how many frames are in this video? As an INT output. That's it - and for a node with zero moving parts, it quietly unblocks a lot of workflows.

The important implementation detail: like VideoGetFrameRate from the same pack, it reads the count from metadata without decoding anything. That matters because "how many frames" is usually the first thing you want to know about a long file, and the last thing you want is to pay the full decode cost just to find out. On this pack's lazy-decode model, the count comes free.

Where it fits

One input, one output:

  • video (VIDEO) - from Video Load Preview, same as the rest of this pack.
  • Output: total_frames (INT).

The classic pairing is with VideoGetFrame or VideoGetFramesRange - both of those throw errors if you ask for an index past the end of the file. Rather than guessing, compute it: total_frames → clamp your frame_index or your end_frame. Say you want the last 60 frames of a clip of unknown length: start_frame = total_frames - 60, end_frame = -1. Or use the count to drive a loop that walks a long file in chunks - handy for processing footage that's longer than your VRAM.

Gotchas

  • It reports the total decoded frame count. For variable-frame-rate sources the count can differ slightly from what a naive "duration × fps" guess would give you. Trust the node; it's reading the actual frame count.
  • Metadata reads assume the video object cooperates. If the video input is a plain in-memory tensor (say, from ImageToVideo), it falls back to counting that tensor's frames - which is also correct, just a different path.
  • Pair it, don't run it alone. On its own it's a readout. Its power comes from wiring the number into range calculations.

Install

Standard for this pack:

cd ComfyUI/custom_nodes/
git clone https://github.com/guchendesigndog/comfyui-video-edit.git
pip install -r comfyui-video-edit/requirements.txt

Or search "ComfyUI-Video-Edit" in ComfyUI Manager and restart. The only real dependency is PyAV (av>=10.0.0), which needs FFmpeg. It's a small MIT-licensed pack from a solo author - nothing heavyweight, and the metadata helpers like this one are the cheapest nodes it ships. If you're building a workflow that processes video of unknown length, VideoGetTotalFrames is the safety rail that keeps your indices in bounds.

CategoryVideoEdit

Inputs (1)

NameTypeDefaultDescription
videoVIDEO

Outputs (1)

NameTypeDescription
total_framesINT