Nodes/ComfyUI-iterator-nodes/逐个读取视频文件 (Iterator)
ComfyUI Node

逐个读取视频文件 (Iterator)

Walk a folder of videos and hand each one to your workflow as a full frame batch

By GHOSTLXH·Created about a year ago·Updated about a year ago· 7
逐个读取视频文件 (Iterator)
    • frames
    • 文件名
    folder_pathC:\path\to\your\video_folder

    This is ImageFileIterator's video cousin, with one important difference: instead of one image per run, it loads the entire clip and hands it to you as a single IMAGE batch. Every frame of the video, decoded and stacked into one tensor. That makes it the node you reach for when the whole clip needs to be in the graph at once - img2vid where the sampler conditions on the source, frame interpolation, VAE-encoding an entire sequence, or slicing keyframes out downstream. If you want a folder of videos processed one clip at a time through an otherwise static workflow, this is the loader.

    How it works

    Same iterator engine as the rest of the pack: a per-node index, a cached sorted file list, and the IS_CHANGED-returns-NaN always-rerun trick so each queue run advances to the next file. It scans the folder for .mp4, .mov, .avi, .mkv, .webm, sorts the names, and for the current file uses OpenCV to decode every frame (BGR → RGB, normalized to 0–1), then torch.stacks them into one tensor shaped [frame_count, H, W, 3]. When the folder's done it resets the index and raises - the "all N videos processed" error is the designed stop, same as its siblings.

    The inputs and outputs that matter

    One input: folder_path - absolute path to the video folder (default C:\path\to\your\video_folder; forward slashes fine elsewhere).

    Outputs:

    • frames (IMAGE) - the full decoded clip as a single batch tensor. Wire it anywhere that accepts an image batch: a VAE encode, an img2vid conditioning path, or a Get Image From Batch/Split Image Batch style node if you want individual frames.
    • 文件名 (STRING) - the base filename without extension (Chinese label again), ready for a FilenameComparator if you're pairing videos with txt files.

    Installing it

    It ships in ComfyUI-iterator-nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/GHOSTLXH/ComfyUI-iterator-nodes
    

    then restart ComfyUI, or use ComfyUI Manager and search the pack name. No model downloads. One real dependency caveat: the pack ships no requirements.txt, so Manager won't auto-install anything, and this node imports OpenCV (cv2) directly. If ComfyUI throws an ImportError: No module named cv2, install it yourself:

    pip install opencv-python
    

    Where people get burned

    • Memory, memory, memory. This node gives you every frame at native resolution - a five-minute 1080p clip is roughly 7,500 full-res tensors sitting in RAM before your sampler ever sees them. That's the price of "whole clip in the graph," and it means this node is for short or low-res clips, or clips you're going to slice immediately. For long footage, the pack's VideoFramesByIntervalIterator (which pulls spaced-out keyframes instead of everything) or a proper streaming video node is the better tool.
    • No throttling, no resizing. You get what's on disk, at the source frame rate. If your sampler expects a specific size, resize after the iterator.
    • The usual family rules apply: set the queue to "Run (on change)" mode for hands-free walking, the file list is cached at first scan, and the end-of-folder exception is the finish line, not a crash.

    It's blunt, but that's its job: a folder of videos becomes a folder of full-frame-batch loads, one queue run each, no wiring up per-clip loaders by hand.

    Categoryutilities/loaders

    Inputs (1)

    NameTypeDefaultDescription
    folder_pathSTRINGC:\path\to\your\video_folder

    Outputs (2)

    NameTypeDescription
    framesIMAGE
    文件名STRING