Nodes/ComfyUI Multimedia Utilities/⏱️ Calculate Video Frame Count
ComfyUI Node

⏱️ Calculate Video Frame Count

The frame-count calculator that actually respects 23.976, not just 24

By thimpat·Created about a year ago·Updated about a year ago· 0
⏱️ Calculate Video Frame Count
    • frame_count
    duration1
    fps24

    "How many frames is 6 seconds at 24 fps?" is the kind of arithmetic you do ten times while building a video workflow, and it's one mistake away from a clip that ends two frames early or spits out a latent batch of the wrong size. CalculateVideoFrameCount is a single node that does duration × fps, rounds it, and hands you the frame count as an INT - nothing more, nothing less.

    The reason it exists (and the reason both inputs are floats rather than integers) is written in the source's comments: video FPS is frequently not a whole number. NTSC rates like 23.976 and 29.97 are the norm in real footage, and duration is a float anyway when it comes from audio or a loader. So you get two FLOAT inputs - duration in seconds (default 1, step 0.01) and fps (default 24, minimum 1, step 0.01) - and one INT output, frame_count, computed as round(duration * fps). Feed it 10.0 and 23.976 and you get 240, which is the right number for a 10-second 24p clip even though the math is sitting on a fraction.

    When you'd actually reach for it

    • Syncing video to an audio track: take the audio's duration, multiply by your target fps, and you know exactly how many frames your renderer or batch node needs. This pack's ExtractAudioInfo outputs duration specifically so this node can consume it.
    • Pre-computing latent batch sizes for a fixed-length generation pass.
    • Chunking a long clip: divide the total count and feed the per-chunk count to your processing loop.

    One caveat: the widget sliders are guarded (fps won't go below 1), but nothing here checks that your inputs are sane beyond that - a duration of 0 yields 0 frames, and huge values yield huge counts. It's a calculator, not a validator; the sanity check is on you.

    The pair you'll actually build

    CalculateVideoFrameCount outputs INT, and a surprising number of downstream nodes demand FLOAT for the same value. That's the exact gap this pack's IntToFloatConverter fills - it exists, per its own docstring, to connect INT outputs like frame_count to float-only inputs. Put the two together and the wiring stops being a hunt through menus.

    Installation is the pack standard: ComfyUI Manager (search "Multimedia Utilities") or git clone https://github.com/thimpat/ThimPatUtils into custom_nodes/, then restart. It pulls in no models and has no heavy deps of its own - pure Python math - but remember the pack as a whole wants opencv-python and soundfile installed or none of its nodes will even register. If it shows up in your list at all, you're fine; if it's missing, that's the first thing to check.

    Category🎨 ThimPatUtils/Video Tools

    Inputs (2)

    NameTypeDefaultDescription
    durationCOMBO11 options: FLOAT
    fpsCOMBO241 options: FLOAT

    Outputs (1)

    NameTypeDescription
    frame_countINT