Nodes/comfyui-huyl2-nodes/Wan Frame Window Size 🎞️
ComfyUI Node

Wan Frame Window Size 🎞️

The math behind chunking a long WanAnimate clip

By huyl3-cpu·Created 9 months ago·Updated 4 months ago· 1
Wan Frame Window Size 🎞️
    • frame_window_size
    • output_frames
    • frame_diff
    • n_used
    total_frames81
    min_window_size93
    max_window_size113

    WanAnimate and similar Wan-based motion-transfer models don't process an arbitrarily long clip in one shot - they work in fixed-size windows, and picking the right window size is a real tradeoff: too small and you waste compute re-processing overlap between windows, too large and quality drops. This node does that arithmetic for you.

    Why windowing matters here

    The wider Wan ecosystem's native context tops out well short of most real clips - the community-standard working length is 81 frames, and anything longer requires chunking the video into overlapping windows and stitching the results back together. That stitching is exactly where the well-known failure mode shows up: identity and consistency drift across chunk boundaries. Getting the window size right doesn't eliminate that risk, but it's the first lever you actually control.

    This node's own description (written in Vietnamese in the source) lays out the goal directly: find a window size x of the form 4k+1, somewhere between your chosen minimum and maximum, that leaves the least wasted padding when tiling your actual clip length. The author's stated recommendation is 93 ≤ x ≤ 113 for good WanAnimate quality - going much below 90 hurts quality, and going much above 114 just wastes frames on unnecessary overlap.

    How it works

    The formula, per the node's own description: output = 1 + n*(x-1) - a stride of x-1 with one frame of overlap between consecutive windows. Given your total_frames, it searches the min_window_sizemax_window_size range for the x that tiles your clip with the least leftover.

    Inputs and outputs

    • total_frames (INT, default 81, tooltip: "Tổng số frame của video input" - total frames in your input video) - your actual source length.
    • min_window_size / max_window_size (INT, defaults 93 / 113, step 4 to stay in the 4k+1 family) - the search range. The tooltips are explicit: windows under ~90 hurt quality, windows over ~114 waste frames.
    • Outputs: frame_window_size (the chosen x), output_frames (total frames the windowing will produce, which is ≥ total_frames), frame_diff (the padding you'll need to trim afterward), and n_used (how many windows it landed on).

    Installing it

    No models or extra dependencies mentioned in the README. Search ComfyUI Manager for the repo name first, but a small personal pack like this often isn't indexed - the manual route is reliable:

    cd ComfyUI/custom_nodes
    git clone https://github.com/huyl3-cpu/comfyui-sortlist.git
    

    Restart ComfyUI afterward.

    Common issues and troubleshooting

    This node does math only - it doesn't touch your video. Wire its frame_window_size output into whatever WanAnimate node actually performs the chunked sampling; on its own this just tells you a number.

    frame_diff usually isn't zero. Windowing rarely divides your clip evenly, so expect a handful of trailing frames beyond your source length that you'll need to trim in a later step - this pack doesn't ship a trim node, so that's on you or your video-loading pack's own tools.

    Stay inside the recommended 93–113 band unless you've tested otherwise. Widening min_window_size/max_window_size past what the tooltips recommend trades away a tradeoff the author already validated for one you haven't. It lines up with the broader community experience around Wan's native context limits: pushing chunk sizes too far outside what the model was actually trained to handle is where identity drift across chunks tends to get worse, not better.

    Categoryutils

    Inputs (3)

    NameTypeDefaultDescription
    total_framesINT811–99999Tổng số frame của video input
    min_window_sizeINT935–121Window size nho nhat (4k+1). Default=93. Khuyen nghi: 93-113 cho chat luong WanAnimate tot nhat.
    max_window_sizeINT1135–121Window size lon nhat (4k+1). Default=113. Window nho hon 90 => chat luong kem. Window lon hon 114 => lang phi frames nhieu.

    Outputs (4)

    NameTypeDescription
    frame_window_sizeINT
    output_framesINT
    frame_diffINT
    n_usedINT