Nodes/Link Comfy Nodes/WAN Frames to Add & Cut
ComfyUI Node

WAN Frames to Add & Cut

Pad or trim a clip toward a target length, WAN-valid

By Mister-Link·Created 9 months ago·Updated 24 days ago· 0
WAN Frames to Add & Cut
    • frame_count
    • frames_to_add
    • frames_to_cut
    frame_count29
    frames_to_add0
    frames_to_cut0
    preferencebalanced

    WAN Frame Calculator, this pack's other frame-math node, rounds a single target number to a WAN-valid frame count. This node solves the next problem: you already have a clip at some length, and you want to get it toward a target by adding or removing frames - and when the arithmetic doesn't land on a valid WAN count exactly, you want to say which direction you'd rather it bend. That's the padding-for-target-duration calculation this pack's README describes, and it's the same category of problem that shows up constantly in WAN workflows: because the Wan VAE compresses time roughly 4x, only frame counts of the form 4n+1 (1, 5, 9, 13...) survive an encode/decode round trip intact, so hitting a specific duration means hitting one of those numbers, not just any number close to it.

    The inputs and outputs that matter

    • frame_count (default 29 - itself a valid 4n+1 number, worth noticing) - your current or reference frame count.
    • frames_to_add (default 0) and frames_to_cut (default 0) - how many frames you're looking to add or remove.
    • preference - balanced, add frames, or remove frames. When the requested add/cut amounts don't land exactly on a valid WAN count, this decides which way the node resolves the difference: balanced picks whichever is closer, add frames biases toward padding rather than trimming when there's a choice, remove frames biases the other way.

    Outputs: frame_count, frames_to_add, frames_to_cut - the same three names as the inputs, now holding the corrected, WAN-valid values you should actually use. These are the numbers to wire into whatever pads or trims your frame batch downstream - this pack's Shift Image Batch and SCAIL Pose Frames both operate on frame batches and could plausibly sit on the receiving end, depending on your workflow.

    How to install it

    Search "Link Comfy Nodes" in ComfyUI Manager and install from there. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Mister-Link/link-comfy-nodes
    pip install -r link-comfy-nodes/requirements.txt
    

    Restart ComfyUI. Pure integer math, nothing extra to install for this node specifically.

    Common issues & troubleshooting

    Misreading the outputs as an echo of your inputs. Because the three outputs share exact names with the three inputs, it's easy in a screenshot or a shared workflow to assume they're just passing values through unchanged. They're not - they're the corrected numbers after the WAN-valid adjustment, and using the input values downstream instead of the output values defeats the point of the node.

    Chasing a duration finer than single-frame WAN increments allow. Even after running your numbers through this node, remember the underlying constraint from WAN Frame Calculator is still in play: every valid count is 4n+1, so very fine-grained duration targets aren't achievable no matter which preference you pick - the node can only move you to the nearest valid option in your preferred direction, not conjure an exact arbitrary length.

    Not checking which preference actually matches your priority. If padding a few extra frames is harmless for your use case but trimming would cut content you need, make sure preference is set to add frames explicitly rather than leaving it on balanced and hoping it resolves the way you want.

    Categoryconditioning/video_models

    Inputs (4)

    NameTypeDefaultDescription
    frame_countINT291–9999
    frames_to_addINT00–9999
    frames_to_cutINT00–9999
    preferenceCOMBObalanced3 options: balanced, add frames, remove frames

    Outputs (3)

    NameTypeDescription
    frame_countINT
    frames_to_addINT
    frames_to_cutINT