Nodes/ComfyUI-WepeNerd/Duration Selector (WepeNerd)
ComfyUI Node

Duration Selector (WepeNerd)

Your 111-Frame Video Came Back at 109 Frames. That's the Grid.

By WepeNerd·Created 6 months ago·Updated 9 days ago· 7
Duration Selector (WepeNerd)
    • frames
    • fps
    • seconds
    ◄presetLTX-2.x (8n+1, 24 fps)►
    ◄frames121►

    The problem this solves

    Video models don't take arbitrary frame counts, and they fail in two annoyingly different ways.

    LTX is the loud one: dimensions divisible by 32, frame count divisible by 8 plus 1, and off-grid values fail rather than round. You ask for 100 frames, you get an error, and you go re-read the model card.

    Wan is the quiet one. Its VAE compresses time about 4x, so N frames become ((N - 1) // 4) + 1 latents and decode back to (T_lat - 1) * 4 + 1 frames - the machinery behind the classic "why did my 111-frame clip come back 109 frames" thread. Nothing errored; the VAE did what it always does.

    So the grids are 8n+1 for LTX, 4n+1 for Wan and Hunyuan, 6n+1 for Mochi, and 17n+5 for MiniMax H3. Doing that in your head works most of the time, which is the worst possible failure rate.

    Frame Number Selector (WepeNerd) is a dropdown that only lists counts legal for the model you picked, with each count's duration at that model's native frame rate sitting next to it. Small thing. Genuinely useful thing.

    What it ships with

    | Preset | Rule | Range | fps | |---|---|---|---| | LTX-2.x | 8n+1 | 9–481 | 24 | | LTX-Video 0.9.x | 8n+1 | 9–257 | 25 | | MiniMax H3 | 17n+5 | 5–362 | 24 | | Wan 2.1 / 2.2 14B | 4n+1 | 5–161 | 16 | | Wan 2.2 5B | 4n+1 | 5–161 | 24 | | HunyuanVideo | 4n+1 | 5–129 | 24 | | Mochi 1 | 6n+1 | 7–163 | 30 |

    One caveat the author writes into the preset file himself: H3's trained window is roughly 107–362 frames (4–15 seconds), so shorter counts on the grid decode but are out of distribution. The LTX-2 and Wan upper bounds are practical caps, not model maximums - the "legal value" and the "value that actually works" aren't the same thing.

    Inputs, outputs, and the trick underneath

    You set two things: preset, and frames. Changing the preset keeps the nearest legal count, so 121 frames on LTX becomes 124 on H3 instead of quietly changing how long your clip is.

    The implementation is more interesting than the UI. The frames dropdown declared to ComfyUI is the union of every preset's labels - 196 of them - so validation always accepts a value your workflow saved. A frontend extension then fetches the expanded presets from /wepenerd/frame_number/presets and narrows the visible list to your preset. Labels look like 121 (5.04s), and the count is parsed from the leading integer on both sides.

    Three outputs, and they say exactly what they are:

    • frames (INT) - the count. Per the tooltip: connect it to length, num_frames, frame_count or batch_size.
    • fps (FLOAT) - the preset's native frame rate, for whatever saves or muxes the clip.
    • seconds (FLOAT) - duration at that frame rate. Humans plan in seconds; the model plans in grid positions.

    Installing it

    ComfyUI Manager → search ComfyUI-WepeNerd → install, or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/WepeNerd/ComfyUI-WepeNerd.git
    python -m pip install -r ComfyUI-WepeNerd/requirements.txt
    

    Restart ComfyUI and hard-refresh the browser. Requirements are Pillow, numpy, scipy and av>=17.0.0 - no model downloads, no GPU wheels, torch stays whatever ComfyUI already uses. This node is recent (still in the pack's Unreleased changelog section as of writing), so an older copy won't have it.

    Where people get tripped up

    The dropdown looks wrong. If the frontend extension didn't load, frames shows all 196 labels from every preset mixed together. Hard-refresh; the backend still snaps anything illegal, so nothing breaks - it just looks like a mess.

    A stale value snaps, with a warning. Load an old workflow or hit the API with a count that isn't legal for the chosen preset and the Python side moves you to the nearest legal count, ties going up, logging 111 frames isn't valid for LTX-2.x (8n+1, 24 fps); using 113. Read the console before blaming the sampler.

    Don't trust the seconds inside the label. That parenthetical comes from whichever preset the label belongs to, and two presets can share a count at different durations (121 (5.04s) at 24 fps, 121 (7.56s) at 16 fps). The seconds output is always recalculated from the preset you picked.

    Adding your own presets. Open frame_number_presets.json. Each entry is either a rule (step, offset, min, max, fps) or an explicit frames list; keys starting with _ are ignored. The file is re-read on every run, so a browser refresh is enough for edits; if a new preset name doesn't appear, restart ComfyUI.

    CategoryWepeNerd/Video

    Inputs (2)

    NameTypeDefaultDescription
    presetCOMBOLTX-2.x (8n+1, 24 fps)Video model whose frame-count rule the list follows.
    framesCOMBO121Valid frame counts for the selected preset. Changing preset keeps about the same length in seconds.

    Outputs (3)

    NameTypeDescription
    framesINTFrame count. Connect to length, num_frames, frame_count or batch_size inputs.
    fpsFLOATThe preset's native frame rate.
    secondsFLOATClip duration in seconds: frames / fps.