Nodes/ComfyUI_AIMZ/AIMZ Video Duration Selector
ComfyUI Node

AIMZ Video Duration Selector

One node to compute video duration without the math spaghetti

By AIMZ-GFX·Created 28 days ago·Updated 17 days ago· 3
AIMZ Video Duration Selector
    • total_frames
    • final_seconds
    • effective_fps
    • raw_frames
    • source_seconds
    modeSource Video (V2V)
    custom_seconds6.0
    default_fps24
    minimax_aligntrue
    source_frames
    source_duration
    source_fps

    Every V2V or R2V workflow has a moment where you need to know how long the video will be - and the answer requires grabbing the source duration, multiplying by FPS, rounding, and then (if you're on MiniMax H3) applying that model's weird frame-alignment rule on top. By hand that's four or five Math Expression nodes with brackets you'll misread next month. AIMZ Video Duration Selector collapses the whole calculation into one node with a mode toggle and one checkbox.

    It's the scheduling node of the pack: it takes "how long should this be" and produces the exact frame count your video model needs, including MiniMax H3's alignment, without you touching a calculator.

    How it works

    It has two modes, which cover the two ways people build video pipelines:

    • Source Video (V2V) - you're redoing or extending an existing video. The node reads the source's duration (from source_duration, or computed from source_frames divided by FPS) and uses that as the target. Your new generation matches the length of the source.
    • Custom Seconds (R2V) - you're generating from scratch. It uses the custom_seconds slider instead.

    Either way it computes raw_frames = max(5, round(seconds * fps)). Then, if minimax_align is on (it's the default), it pads the count to satisfy H3's rule:

    total_frames = raw_frames + (5 - (raw_frames % 17)) % 17
    

    That formula - a minimum of 5 frames, aligned so the count lands on the model's 17-frame pattern - is MiniMax H3's requirement, and it's the part people get wrong by hand. The node just does it.

    FPS resolution is the same pattern as the rest of the pack: source_fps (from Get_FPS) wins if connected, otherwise default_fps (24) is used.

    Inputs and outputs

    The ones you'll actually set: mode (the V2V/R2V toggle), custom_seconds (only relevant in R2V mode), and minimax_align (leave on unless you know H3 isn't your target). The optional source_frames (from Get_length), source_duration, and source_fps feed the V2V side.

    Outputs are the payoff: total_frames (the aligned count you feed your sampler or video nodes), raw_frames (before alignment), final_seconds (total_frames / fps, in case a node wants seconds), effective_fps (which FPS it actually used), and source_seconds (the source's duration, for reference). total_frames is the one you're really after.

    Installing it

    Part of the ComfyUI_AIMZ pack. ComfyUI Manager → Custom Nodes Manager → search comfyui_aimz → Install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/AIMZ-GFX/ComfyUI_AIMZ.git
    

    No models, no dependencies beyond the usual.

    Gotchas

    The big one: in V2V mode with no source connected, every output comes back zero - the node returns (0, 0.0, fps, 0, 0.0) rather than guessing. Feed source_frames or source_duration or you'll silently get a 0-frame video. That's deliberate None-safe behavior, but it's easy to misread as a bug the first time.

    Second: minimax_align only makes sense if MiniMax H3 is actually your model. The 17-frame rule is H3-specific - it doesn't apply to LTX or Wan, so turn it off when you're not on H3 or you'll be adding arbitrary frames to every generation.

    Finally, custom_seconds is a FLOAT with a 0.1 step - you can set 5.7 seconds if you want. It rounds to the frame at your effective FPS before alignment, so don't expect the exact seconds you typed to survive frame quantization. That's physics, not a bug.

    CategoryAIMZ/Workflow

    Inputs (7)

    NameTypeDefaultDescription
    modeCOMBOSource Video (V2V)2 options: Source Video (V2V), Custom Seconds (R2V)
    custom_secondsFLOAT6.00.1–600Desired duration in seconds for R2V mode
    default_fpsFLOAT241–240Default FPS used when source_fps is not connected
    minimax_alignBOOLEANtrueAlign frame count to MiniMax H3 formula: max(5, round(sec * fps)) + (5 - (max(...) % 17)) % 17
    source_framesoptINTConnect Get_length or video frame_count directly (Optional, None-safe)
    source_durationoptFLOATConnect source video duration in seconds (Optional, None-safe)
    source_fpsoptFLOATConnect Get_FPS (Optional, None-safe)

    Outputs (5)

    NameTypeDescription
    total_framesINT
    final_secondsFLOAT
    effective_fpsFLOAT
    raw_framesINT
    source_secondsFLOAT