Nodes/comfyui-huyl2-nodes/Pick Video With Min Frames
ComfyUI Node

Pick Video With Min Frames

Find your bottleneck clip before a batch operation

By huyl3-cpu·Created 9 months ago·Updated 4 months ago· 1
Pick Video With Min Frames
    • min_path
    • min_frames_est
    • report
    valid_paths
    force_rate_fps0.0

    Same caveat as its sibling VHS_VideoFrameGuard: the VHS_ prefix is normally associated with kosinkadink's very popular ComfyUI-VideoHelperSuite pack, and this node has nothing to do with it - it's local to comfyui-sortlist, just reusing the naming convention. Don't go looking for it in the wrong repo's issue tracker.

    What it does

    Given a list of video paths, it estimates each one's frame count and hands back whichever is shortest - a small but genuinely useful piece of logic when you're about to do something that needs equal-length inputs.

    • valid_paths - a multiline STRING list of video paths to compare. The name suggests it's meant to be fed directly from VHS_VideoFrameGuard's valid_paths output (the survivors of a frame-count check), though nothing stops you from feeding it any newline list of paths.
    • force_rate_fps - FLOAT, default 0 (use each file's own reported fps), same meaning as on Frame Guard: set it nonzero to estimate frame counts as if everything were re-timed to a common rate first.

    Outputs: min_path (the shortest clip's path), min_frames_est (INT - its estimated frame count), and report (STRING, presumably a breakdown across the whole list).

    Where it fits

    The use case is syncing a batch of clips to a common length. Rather than picking an arbitrary trim target, this finds your actual bottleneck - the shortest clip in the set - so you know exactly how far everything else needs to come down to match it. That matters before any node downstream that assumes uniform frame counts across a batch: a multi-video composite, a synchronized side-by-side, anything that would otherwise error or misbehave on mismatched lengths.

    Installing it

    ComfyUI Manager: search comfyui-huyl2-nodes. By hand:

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

    restart. Not covered in the pack's README. Like VHS_VideoFrameGuard, frame-count estimation from raw files almost certainly leans on ffmpeg/ffprobe or OpenCV - worth checking that's available on PATH if this errors on first run outside a Colab environment.

    Common issues & troubleshooting

    Take min_frames_est at face value as an estimate, not a guaranteed exact count. Decoding every frame of every candidate video just to compare lengths would be slow for a batch, so this almost certainly uses a faster method - reading container metadata or sampling - that can be off by a frame or two versus what you'd get from actually decoding the file. If your downstream step needs a frame-perfect trim target, verify the winning clip's real length before committing, rather than trusting the estimate blindly.

    If the reported minimum looks wrong for a clip you know is short, double-check force_rate_fps - a mismatch between the fps this node assumes and the clip's actual native rate will throw the frame-count math off in exactly the direction you'd expect (assuming a higher fps than reality inflates the estimated count, and vice versa).

    CategorySortList/Video

    Inputs (2)

    NameTypeDefaultDescription
    valid_pathsSTRING
    force_rate_fpsFLOAT0.00–240

    Outputs (3)

    NameTypeDescription
    min_pathSTRING
    min_frames_estINT
    reportSTRING