Nodes/ComfyUI-ZML-Image/ZML_从路径加载视频
ComfyUI Node

ZML_从路径加载视频

Pull frames out of a video folder without touching VHS

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_从路径加载视频
    • 图像
    • 帧率
    • 帧数
    文件夹路径
    索引模式固定索引
    索引值0
    读取帧数上限0
    帧率限制0

    Need frames from a video for img2video, a batch of stills, or frame interpolation? ZML_LoadVideoFromPath is the ZML pack's folder-based video loader: point it at a directory, and it decodes one video into a list of frame images you can feed the rest of the graph. It replaces the old GIF path node, and the README notes it handles GIFs too - treating them as short videos, which they basically are.

    The inputs are the path-loading pattern with a video twist:

    • 文件夹路径 (folder path) - where the videos live. It scans for .mp4, .mov, .avi, .webm, .mkv, .flv, .wmv, .gif and sorts them.
    • 索引模式 - 固定索引 (fixed, uses 索引值), 随机索引 (random file each run), or 顺序 (sequential per-node counter that steps through files and resets on startup).
    • 读取帧数上限 (max frames, 0 = all) - the big one for memory. A long 4K video decoded to a tensor list will eat RAM like a toddler with candy; cap it and save yourself.
    • 帧率限制 (fps limit, 0 = keep original) - how it downsamples: if the source is 60fps and you set 30, it reads every 2nd frame and reports the effective output fps.

    Outputs: 图像 (the frames, as a list of IMAGE), 帧率 (the fps you actually got - original or the downsampled rate), and 帧数 (how many frames were read). Wire 图像 into a video model's context or a batch saver and you're off.

    Mechanically it's OpenCV (cv2.VideoCapture) under the hood - which is why the pack's requirements include opencv-python. The node reads frames, honors the interval math for the fps limit, and returns a placeholder 64×64 black tensor if a file can't be opened, with a console message telling you what failed. That "return a placeholder instead of crashing" habit is all over this pack; it keeps graphs running but it also means failures look like "black output" unless you watch the console.

    The real gotchas are the frame-count ones. Setting 读取帧数上限 to something sane is not optional on big files - a 10-minute 30fps clip is 18,000 frames, and feeding all of them to anything that isn't a proper video model is a mistake. Also note the sequential counter lives in a JSON file inside the pack's folder and resets on startup, so "sequential" is per-session, not truly persistent. And as with the image path loader, relative paths resolve against the ComfyUI root - an absolute path is the least surprising.

    Install is pack-standard:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zml-w/ComfyUI-ZML-Image
    

    or Manager search "ComfyUI-ZML-Image", then restart. It lives under ZML 图像 → 图像. The one real dependency to be aware of is opencv-python; Manager installs it from requirements.txt, but on a manual clone, run pip install -r requirements.txt if you see ModuleNotFoundError: cv2.

    If you only occasionally need frames, the built-in VHS pack is the heavyweight standard for video I/O in ComfyUI - but for "grab frames from a folder I already have, quickly," this node is lighter and needs no separate server. Just keep an eye on that frame cap.

    Categoryimage/ZML_图像/图像

    Inputs (5)

    NameTypeDefaultDescription
    文件夹路径STRING
    索引模式COMBO固定索引3 options: 固定索引, 随机索引, 顺序
    索引值INT0
    读取帧数上限INT00–999999
    帧率限制INT00–999

    Outputs (3)

    NameTypeDescription
    图像IMAGE
    帧率INT
    帧数INT