Nodes/ComfyUI-Advanced-ControlNet/SparseCtrl Index Method πŸ›‚πŸ…πŸ…’πŸ…
ComfyUI Node Runs on cloud

SparseCtrl Index Method πŸ›‚πŸ…πŸ…’πŸ…

Map sparse frames for AnimateDiff in ComfyUI

By KosinkadinkΒ·Created 3 years agoΒ·Updated 7 days agoΒ· 993
SparseCtrl Index Method πŸ›‚πŸ…πŸ…’πŸ…
    • SPARSE_METHOD
    β—„indexes0β–Ί

    SparseCtrl is the AnimateDiff trick that lets you condition a video on just a few frames - give it a starting image and an ending image and the motion module fills in everything between. It's what unlocked keyframe interpolation, image-to-video, and sketch-to-video in the AnimateDiff era. But for that to work, SparseCtrl needs to know which frames your handful of control images correspond to. That mapping is exactly what this node sets.

    By default your control images map to the first frames (index 0, 1, 2…). The Index Method lets you say "no - this image is frame 0, that one is frame 15," so a two-image input can pin the first and last frame of a 16-frame clip and let the motion fill the gap. It's a tiny node with one text field, but it's the difference between SparseCtrl doing what you meant and smearing your keyframes across the wrong positions.

    How it works

    You type frame indices as a string, one per control image, in order. A single 0 (the default) puts your first image on the first frame. 0,15 puts the first image on frame 0 and the second on frame 15 - the canonical "keyframe the ends, interpolate the middle" setup. The node bundles that into a SPARSE_METHOD object that a SparseCtrl loader consumes.

    This is the "index" method - mapping by explicit frame position. It's the intuitive one for keyframing. (The pack also has a spread method for evenly distributing frames, but that's a different node.)

    Inputs and outputs

    • indexes (required, default "0") - a comma-separated list of frame indices, one per control image you're feeding SparseCtrl, in order.

    Output: SPARSE_METHOD - wire it into the sparse_method input on a SparseCtrl loader (like the Merged SparseCtrl loader in this pack).

    Installing the pack

    ComfyUI Manager β†’ Install Custom Nodes β†’ "ComfyUI-Advanced-ControlNet" β†’ restart. Or cd ComfyUI/custom_nodes && git clone https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet then restart. It's Kosinkadink's pack - the same author as AnimateDiff-Evolved, which is not a coincidence, since SparseCtrl is an AnimateDiff feature and the two packs are meant to run together. You'll also need a SparseCtrl model in ComfyUI/models/controlnet (the RGB or scribble SparseCtrl checkpoint) and the AnimateDiff motion module.

    Common gotchas

    Count mismatch is the trap: the number of indices should match the number of control images you're feeding SparseCtrl. Two images but one index (or vice versa) and the mapping won't line up with what you intended.

    Second, indices are zero-based and must fall inside your clip's frame count. 0,15 needs at least 16 frames; ask for frame 15 in a 12-frame batch and that keyframe lands nowhere useful.

    Third - the bigger-picture caveat - SparseCtrl lives in the AnimateDiff / SD 1.5 world, and per the AnimateDiff KB that whole approach is superseded for new video projects (Wan 2.2 and friends took the general use case). It still works and it will keep working, but if you're starting fresh and just want video, this is the old road. If you specifically want AnimateDiff's keyframe-interpolation look, though, this node is part of how you get it.

    CategoryAdv-ControlNet πŸ›‚πŸ…πŸ…’πŸ…/SparseCtrl

    Inputs (1)

    NameTypeDefaultDescription
    indexesSTRING0β€”

    Outputs (1)

    NameTypeDescription
    SPARSE_METHODSPARSE_METHODβ€”