Nodes/Eden.art nodesuite/Eden_DetermineFrameCount
ComfyUI Node Runs on cloud

Eden_DetermineFrameCount

Pick the right number of frames, by the rules

By edenartlabΒ·Created 3 years agoΒ·Updated 6 months agoΒ· 119
Eden_DetermineFrameCount
    • INT
    β—„n_target_frames24β–Ί
    β—„n_source_frames1β–Ί
    β—„policyβ–Ύβ–Ί
    β—„min_frames1β–Ί
    β—„max_frames1024β–Ί

    There's a deeply annoying class of ComfyUI bug that only appears in video work: you ask for 24 output frames, but your source video has 30, or 15, or 90 - and the interpolation or loop node downstream produces a stutter, a hang, or frames it clearly wasn't meant to handle. Eden_DetermineFrameCount is the tiny math node that kills that whole family of bugs: you tell it how many frames you want and how many your source has, and it returns the closest valid multiple that downstream nodes can actually work with.

    It's a one-number answer node from Eden.art's pack, and like most of the pack's "general" utility nodes it exists because their own production workflows kept tripping over frame-count mismatches.

    How it works

    The logic is deliberately simple and it's all about multiples. You give it n_target_frames (what you'd like) and n_source_frames (what your source actually has). It computes a result that is a whole multiple of n_source_frames, rounded to the target according to your chosen policy:

    • closest - the multiple of source frames nearest your target.
    • round down - the multiple at or below the target (never below one source length).
    • round up - the multiple at or above the target.

    Then the result is clamped into [min_frames, max_frames] so it can't come back absurd. Two special cases are handled gracefully: if n_target_frames is 0, and if n_source_frames is 1 or less (in which case the target is used directly, clamped).

    Inputs and outputs

    • n_target_frames (default 24) - what you want.
    • n_source_frames (default 1) - the frame count your source actually has.
    • policy - closest, round down, or round up.
    • min_frames (default 1) / max_frames (default 1024) - the output is clamped to this range. If you set min > max, it swaps them, so you can't break it.

    Output: a single INT - the frame count to feed your interpolation, loop, or batch-repeat node.

    The pattern

    Wire it between a frame-count source and a downstream node that needs a valid count. Classic setup: your video loader reports COUNT (say, 150 source frames) and you want output at 24fps for 10 seconds (240 frames). Feed those in with policy "closest" and you get 300 - the nearest multiple of 150 - which a frame-extend or loop node can tile cleanly. It's the kind of node that feels pointless until a 300-frame workflow hangs on a 9-frame remainder, and then it's the reason you don't hate your job.

    Installing

    One of 70+ nodes in edenartlab/eden_comfy_pipelines (Eden.art nodesuite):

    cd ComfyUI/custom_nodes
    git clone https://github.com/edenartlab/eden_comfy_pipelines.git
    cd eden_comfy_pipelines
    pip install -r requirements.txt
    

    Restart ComfyUI, or ComfyUI Manager β†’ search "Eden". Zero dependencies, no models - it's integer math.

    Gotchas

    Remember the output is a multiple of the source, not your literal target - that's the entire point, but it surprises people the first time. Also note max_frames defaults to 1024, so if your math would produce a bigger multiple it gets capped and you'll silently lose the tail. And since both inputs are plain widget ints, the node doesn't re-run until you queue the graph - but for a pure function like this, that's harmless. If you're unsure whether you even need it, you probably don't yet; you'll know the moment a loop node refuses a frame count.

    CategoryEden 🌱/general

    Inputs (5)

    NameTypeDefaultDescription
    n_target_framesINT240–1024β€”
    n_source_framesINT10–1024β€”
    policyCOMBO3 options: closest, round down, round up
    min_framesINT10–1024β€”
    max_framesINT10240–1024β€”

    Outputs (1)

    NameTypeDescription
    INTINTβ€”