Nodes/comfyui-pertineo-vfx/Pertineo Frames for Model
ComfyUI Node

Pertineo Frames for Model

Your Video Model Only Accepts Certain Frame Counts. Do the Maths Once.

By Pertineo·Created 8 days ago·Updated 8 days ago· 0
Pertineo Frames for Model
    • first_frame
    • last_frame
    • length
    • difference
    ◄first_frame1001►
    ◄last_frame1121►
    ◄model▾►
    ◄rounding▾►
    ◄custom_step8►
    ◄custom_offset1►

    Here's a thing that bites almost everyone doing video in ComfyUI: the frame count is not yours to choose. Due to how the temporal side of the VAE compresses, valid clip lengths follow a rule like 8n+1 - 9, 17, 25, … 97, 105, 121. Ask LTX for 120 frames and you get an error, a silent adjustment, or a clip that quietly isn't the length you asked for, depending on the node. Wan wants 4n+1, MiniMax H3 wants 17n+5.

    Which means every workflow has the same annoying bookkeeping problem: you have a plate that starts at frame 1001 and ends at 1140, you want as much of it as the model will take, and you have to redo the arithmetic every time you tweak the range. Pertineo Frames for Model is one node that does that arithmetic in one place.

    What it actually does

    You give it the range you want. It gives you back the range you can have, plus the length, plus how far off you were - and you wire those numbers into everything else instead of typing them.

    The mechanism is small and worth knowing because the edge cases are where it earns its keep. It counts your range inclusively (last - first + 1), divides out the offset, then floors, ceils, or rounds depending on rounding, and rebuilds the length. The returned last_frame is that length added to your first frame, so the range stays anchored where you put it. difference is signed: negative means it gave you fewer frames than you asked for, zero means you got exactly what you typed.

    The inputs

    • first_frame - where you want to start, as a real frame number (1001, not 0). Passed straight through to the first_frame output.
    • last_frame - where you want to end. This is the one that gets adjusted; don't wire this input, wire the output.
    • model - LTX (8n+1), Wan (4n+1), MiniMax H3 (17n+5), or custom. Pick the family you're actually sampling with.
    • rounding - down (fewer frames), up (more), nearest. Use down. Fewer frames always exist because they're inside the range you already have. up adds frames that must be present in the folder, and if they aren't, the loader stops dead. nearest is for when you genuinely don't care which way it goes.
    • custom_step / custom_offset - only read when model is custom: length = step * n + offset. This is the escape hatch for the next model release, and it's why the node won't rot.

    Four outputs, and the interesting bit is how few of them you set by hand:

    • first_frame → the loaders, and start_frame on Save Matte Sequence (so your matte numbering matches the plate).
    • last_frame → the loaders' last frame.
    • length → the sampler's frame/length widget, and frame_count on Pertineo Empty Audio.
    • difference → nothing, usually. It's a readout. Glance at the console line it prints and move on.

    The classic workflow

    Frames for Model ── first_frame ──┬── Load Image Sequence (first_frame)
                     ├─ last_frame ────┘   (last_frame)
                     ├─ first_frame ────── Save Matte Sequence (start_frame)
                     └─ length ───────────  LTX length + Empty Audio (frame_count)
    

    Set your range once, at the top of the graph. Every downstream node reads it. Change the shot length in one field, re-queue, done.

    Install

    ComfyUI Manager → search Pertineo VFX, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/pertineo/comfyui-pertineo-vfx
    pip install -r comfyui-pertineo-vfx/requirements.txt
    

    The pack's only declared dependency is OpenEXR>=3.2, and this node touches none of it - it's pure integer maths and cannot fail on a missing model.

    Where people get burned

    Rounding up past the end of the shot. You have frames 1001–1121 (121, valid for LTX) and you round nearest from 116 requested → it snaps to 121. Fine. But if your folder only holds 1001–1110 and you ask for up, the loader errors out before anything renders. down never does this.

    Counting vs. numbering, again. 1001 to 1121 is 121 frames; the node counts inclusively, so don't subtract one to "fix" it. 8 × 15 + 1 = 121, which is why the defaults are those numbers.

    A last frame before the first. It raises last_frame is before first_frame and stops. Obvious, but it happens when you copy a node from another shot and only edit one field.

    Assuming other models fit a rule you know. If you're running something not in the list, set custom and check the model's own docs - guessing a step of 8 for a model that wants 4 will produce lengths that error at the sampler, not here. This node only knows the arithmetic you told it.

    CategoryPertineo/IO

    Inputs (6)

    NameTypeDefaultDescription
    first_frameINT10010–10000000First frame of the range (e.g. 1001). Passed through on the first_frame output for the loaders and Save Matte Sequence.
    last_frameINT11210–10000000Desired last frame. It is adjusted to the next valid length; use the last_frame OUTPUT for the loaders.
    modelCOMBOVideo model whose length rule is applied. LTX: 8n+1 (97, 121, ...), Wan: 4n+1 (81, ...), MiniMax H3: 17n+5 (124, ...).
    roundingCOMBOdown = fewer frames, all of them exist (safest). up = more frames – they must exist in the folder, otherwise the loader stops. nearest = closest valid length.
    custom_stepINT81–1000Only for model = custom: length = step * n + offset.
    custom_offsetINT10–1000Only for model = custom: length = step * n + offset.

    Outputs (4)

    NameTypeDescription
    first_frameINT—
    last_frameINT—
    lengthINT—
    differenceINT—