Video Folder Cowboy
The Batch Video Iterator That Keeps vid1 < vid2 < vid10
- frames
- filename
- total_videos
- file_path
- frame_count
- fps
If you've ever written a video batch pipeline by hand, you know the pain that this node exists to kill: you point a loader at a folder, and vid10.mp4 loads before vid2.mp4 because that's what plain lexicographic sort gives you. Video Folder Cowboy is a directory iterator that sorts filenames naturally - splitting text and numeric chunks so vid1 < vid2 < vid10 actually holds - then hands you one video's frames as an IMAGE batch, indexed by a simple counter.
This is the load-once-iterate-many node that sits at the front of per-clip render pipelines. You wire the counter into a queue loop, and each run loads the next clip. It's also the reason the pack has a whole cowboy family: wire this node's filename output into TextFileCowboy and RefFolderCowboy and clip 000.mp4 automatically pairs with prompts/000.txt and refs/000/ - a whole keyed batch system with zero naming pain.
How it works
The node globs your folder (default pattern **/*.mp4, **/*.avi, **/*.mov, **/*.mkv, **/*.webm), sorts the matches, then loads frames with OpenCV: BGR→RGB conversion, float normalization to 0–1. The frame-skip and limit controls do the heavy lifting for big files - you can load every 4th frame or cap at 30 frames, which is how you preview a long clip without importing it all.
The inputs that matter
- video_index - which file in the sorted list to load. This is the knob your loop turns.
- sort_by -
name(natural sort) is the default and usually what you want; you can also sort bydate_modified,size,random, ornone. - index_mode - what happens when the index overruns the file count:
wrap(default, back to the start),clamp(stick at the last file), orerror(raise). Wrap is perfect for infinite queue loops;erroris what you want when a missing clip should stop the run, not silently repeat. - frame_skip, max_frames, start_frame - skip N frames between loads (0 = every frame), cap total frames (0 = all), and skip to a starting frame index.
Outputs
Six of them, and they're all actually useful: frames (the IMAGE batch), filename (no extension - this is what the cowboy pairings key on), total_videos, file_path (full path), frame_count, and fps. The last one matters more than beginners expect, because downstream VHS and Combine nodes want real FPS rather than a guess.
Troubleshooting
Where people get burned: forgetting that frame_skip counts between loaded frames, so frame_skip=3 loads every 4th frame, not every 3rd. And if you're feeding these frames straight into a Wan 2.1 sampler and hitting errors, the frame count is your problem, not the loader - Wan wants 4x+1 frames (81, 97…), so run the frames through the pack's Wan2.1 Frame Adjuster first. randomize_final is there if you want a shuffled deck; sort_subdirs (on by default) keeps subdirectory processing deterministic.
Installing
TrentNodes installs once and gives you the whole Trent/ menu. Easiest: ComfyUI Manager → search "Trent Nodes" → Install. If Manager complains about the pack being flagged (a day-one repo rename left a duplicate in the registry that still trips the unsafe check), clone it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes
cd TrentNodes
pip install -r requirements.txt
Restart ComfyUI and you're done. This node only really needs OpenCV, which the pack pulls in anyway.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | Root directory to search for video files | |
| patterns | STRING | **/*.mp4, **/*.avi, **/*.mov, **/*.mkv, **/*.webm | Comma-separated glob patterns for matching files |
| video_index | INT | 00–999999 | Index of the video to load |
| sort_by | COMBO | name | Sorting method: name uses natural sort |
| sort_order | COMBO | ascending | Sort direction |
| frame_skipopt | INT | 00–120 | Skip N frames between each loaded frame (0 = load every frame) |
| max_framesopt | INT | 00–9999 | Maximum frames to load (0 = all frames) |
| start_frameopt | INT | 00–999999 | First frame index to start loading from |
| index_modeopt | COMBO | wrap | How to handle index overflow |
| sort_subdirsopt | BOOLEAN | true | Sort subdirectories alphabetically |
| randomize_finalopt | BOOLEAN | false | Shuffle entire list after sorting |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| frames | IMAGE | Video frames as image batch |
| filename | STRING | Filename without extension |
| total_videos | INT | Total number of videos found |
| file_path | STRING | Full file path of loaded video |
| frame_count | INT | Number of frames loaded |
| fps | FLOAT | Video FPS (frames per second) |