ComfyUI Node

Get Num Frames

Seconds Times FPS, Plus One — Because Latent Spaces Are Picky

By 5agado·Created 12 months ago·Updated 18 days ago· 1
Get Num Frames
    • num_frames
    seconds1
    fps16

    Every video model in ComfyUI wants a frame count, and frame counts are never quite what you expect. You want a 3-second clip, so you type 48 because 16fps × 3 = 48, and then the model yells at you or the video comes out one frame short of a loop. Get Num Frames exists so you stop doing that math in your head and so you don't forget the +1.

    The actual math

    The source is two lines:

    • seconds = 0 → returns 1
    • otherwise → (seconds * fps) + 1

    That trailing +1 is the whole reason the node exists. Video diffusion latent spaces don't count frames the way a video editor does - many of them expect the first and last frame to be the bookends, which is why frame counts for LTX and friends come out as things like 97, 121, 161 rather than round numbers. A fixed +1 isn't a universal magic constant for every model's divisibility rules, but it gets you the "include the end frame" convention most of them want, and it's the behavior the node guarantees.

    Inputs and output

    • seconds (INT, default 1, capped at 20) - clip length.
    • fps (INT, default 16) - frames per second. 16 is a fine default for a lot of video models; LTX's newer releases use 24–30fps, so adjust to match whatever your model actually trained on.
    • Output: num_frames (INT) - feed this into the frame-count input of your Empty Latent Video, or wherever your video pipeline takes a length.

    Install

    Standard Sagado pack install: ComfyUI Manager → "Sagado Nodes for ComfyUI", or

    cd ComfyUI/custom_nodes
    git clone https://github.com/5agado/ComfyUI-Sagado-Nodes
    pip install -r ComfyUI-Sagado-Nodes/requirements.txt
    

    Restart. No models, no heavy deps.

    Where it helps and where it doesn't

    Use it when you're iterating on clip length and want the frame count to update live as you drag seconds - it turns a fiddly constant into something you can tune. The caveat: if your target model has strict divisibility (a model might require (frames - 1) % 8 == 0 or similar), this node doesn't enforce that. It gives you seconds × fps + 1, and it's on you to round that up or down to something the model accepts. For the "I just want a 3-second clip without a spreadsheet" workflow it's exactly right.

    One more honest note: it's a multiplication node with a hard-coded +1. You could build the same thing with a Math node in ten seconds. But it's already here, it documents the +1 convention in its name, and it saves you re-deriving that convention the fourth time you forget.

    CategorySagado-Nodes

    Inputs (2)

    NameTypeDefaultDescription
    secondsINT10–20
    fpsINT16

    Outputs (1)

    NameTypeDescription
    num_framesINT