Nodes/ComfyUI_BadgerTools/VideoCutFromDir-badger
ComfyUI Node

VideoCutFromDir-badger

Scene-cut your frame dumps automatically, with an OpenCLIP brain

By AbyssBadger0·Created 3 years ago·Updated 2 years ago· 8
VideoCutFromDir-badger
    • STRING
    frame_dir
    min_frame16
    max_frame240

    If you've ever extracted a video to frames and then tried to split those frames into coherent scenes by hand, you know the pain: thousands of PNGs and no sensible way to divide them. VideoCutFromDir-badger automates the division by running a real vision model over consecutive frames and cutting wherever the content actually changes. It's the most ambitious node in this pack - and the heaviest.

    The mechanism is the interesting part, because it's not a simple diff. The node loads OpenCLIP (ViT-B-16-plus-240, pretrained on laion400m_e32) onto your torch device, then walks the frames in pairs. For each consecutive pair it computes a CLIP cosine-similarity score (via sentence_transformers' cosine util) and an SSIM score (via scikit-image) - CLIP catches semantic changes, SSIM catches pixel-level changes, and a cut is declared when the combined penalty crosses a threshold. It enforces a minimum spacing between cuts (so you don't get a cut every frame) and a hard maximum (so no single scene runs on forever). When a cut is found, frames are shuffled into numbered subdirectories - 000, 001, 002... - inside your frame folder.

    The inputs are just three:

    • frame_dir - the folder of extracted frames (PNGs, named in sorted order).
    • min_frame - int, default 16, minimum frames between cuts.
    • max_frame - int, default 240, maximum scene length before a forced cut.

    The output is a single STRING - but it's actually a newline-separated list of directory paths, one per scene. To get the individual paths you split the string on \n (a Text Split or equivalent). It's an awkward output shape, and worth knowing before you wire it into a loader that expects one clean path.

    Three things will bite you. First, the model download: ViT-B-16-plus-240 is a real OpenCLIP checkpoint, downloaded on first run and cached under ./models/clip relative to ComfyUI's working directory. That's a big download and a big chunk of GPU memory. Second, it reloads the model on every execution - no caching, no reuse - so runs are slow and spike your VRAM even if you're just tweaking thresholds. Third, it pulls the pack's heavy dependencies into play: open_clip_torch, sentence_transformers, scikit-image, opencv. The full requirements list is big, and installing it drags a lot of torch-adjacent packages into your environment.

    Install is standard:

    cd ComfyUI/custom_nodes
    git clone https://github.com/AbyssYuan0/ComfyUI_BadgerTools
    

    or search ComfyUI_BadgerTools in ComfyUI Manager, restart, and it's under badger. Realistically, this is a dataset-prep and research node - it's built to feed training-data pipelines and video-understanding workflows, not casual use. For that job it works, and the CLIP-plus-SSIM approach is genuinely more robust than a naive pixel diff at catching "the camera moved, the scene changed" moments. Just budget for the model download and don't run it on a machine you're also trying to generate on.

    Categorybadger

    Inputs (3)

    NameTypeDefaultDescription
    frame_dirSTRING
    min_frameINT161–4096
    max_frameINT2401–4096

    Outputs (1)

    NameTypeDescription
    STRINGSTRING