Nodes/IAMCCS-nodes/LTX-2 Frame Count Validator ? (8n+1)
ComfyUI Node

LTX-2 Frame Count Validator ? (8n+1)

Check your 8n+1 math before the VAE eats it

By IAMCCS·Created 11 months ago·Updated 8 days ago· 113
LTX-2 Frame Count Validator ? (8n+1)
    • validated_count
    • is_valid
    • nearest_valid
    • report
    frame_count81
    auto_correcttrue
    correction_modenearest

    LTX-2.3's frame-count constraint is the kind of rule you'll violate a dozen times by accident: videos must be 8n + 1 frames (1, 9, 17, 25… no wait - 9, 17, 25, 33… hold on, is 25 valid? (25-1)%8 = 0, yes). Most of us do that arithmetic badly under pressure. FrameCountValidator exists so you don't have to: give it a number, and it tells you whether it's valid, hands you the nearest valid number, and can auto-correct.

    This is the pure-math member of the pack's 8n+1 trio. EnsureFrames8nPlus1 fixes an IMAGE tensor, LTX2 Validator builds an empty latent from validated inputs - this one works on nothing but an INT. It's the node you reach for when you're computing a length in your head, wiring a frame count into EmptyLTXVLatentVideo, or debugging why a segment came out one frame short and want the arithmetic spelled out in front of you.

    How it works

    The rule, decoded: frame count must satisfy (n - 1) % 8 == 0. So 81 is valid (80/8 = 10), 82 is not, 89 is valid again. FrameCountValidator computes the remainder, and if it's nonzero it finds the two neighbors that are valid - round down to n - remainder, round up to n + (8 - remainder) - and picks per your correction_mode:

    • nearest (default) - the closer of the two.
    • round_up - always the next valid count up.
    • round_down - always the previous one.

    auto_correct (on by default) decides what actually comes out of validated_count: the corrected number, or your original (possibly invalid) number if you turn it off and just want the diagnostic. Either way is_valid and nearest_valid tell you the truth, and the report STRING walks you through it - remainder, nearest valid, which n it maps to.

    The inputs and outputs that matter

    One input really: frame_count (INT, default 81). The other two, auto_correct and correction_mode, are set-once. Outputs:

    • validated_count - the number to actually use (corrected if auto_correct is on).
    • is_valid - BOOLEAN, true if your input already passed.
    • nearest_valid - the nearest legal count regardless of correction.
    • report - a STRING explaining the verdict.

    The useful wiring pattern: validated_count → the length input of EmptyLTXVLatentVideo or the pack's own LTX2 Validator, so your latent is legal before it ever reaches the encoder. The is_valid BOOLEAN is handy as a gate - feed it into a conditional if you want a node to behave differently on valid vs invalid counts.

    Installing it

    It ships with IAMCCS-nodes. In ComfyUI Manager, search "IAMCCS" and install, or clone:

    cd ComfyUI/custom_nodes
    git clone https://github.com/IAMCCS/IAMCCS-nodes.git
    

    Restart ComfyUI; it appears under IAMCCS/LTX-2. Zero dependencies, zero model files.

    Common issues

    The honest note: this node overlaps hard with EnsureFrames8nPlus1 and the Validator, and the pack genuinely has a bit of redundancy here - three places to do the same (n-1)%8 dance. Don't chain all three; pick the one that matches what you're working on (a number, an image batch, or a fresh latent). The one trap inside this node: round_down on an input of 1 would produce 0 if not clamped - the code clamps to a minimum of 1, so you're safe, but keep it in mind when nearest picks the lower neighbor and you end up below your intended duration. If that bites you, that's what round_up is for.

    CategoryIAMCCS/LTX-2

    Inputs (3)

    NameTypeDefaultDescription
    frame_countINT811–10000Frame count to validate
    auto_correctBOOLEANtrueAutomatically correct to nearest valid value
    correction_modeCOMBOnearestHow to correct invalid values

    Outputs (4)

    NameTypeDescription
    validated_countINT
    is_validBOOLEAN
    nearest_validINT
    reportSTRING