Get Video File By Index ▶️
A counter for your video folder — same idea as the image version, frames included
- images
- filename
- index
- int
- video
- audio
- fps
- frame_count
Get Image File By Index, but for video: a persistent counter walks through a folder of clips one per queue run, and each pick comes back with the whole video's frames plus the filename. Where Random Video Path is "surprise me," this one is "next, please" - step through a folder of clips in sequence, review each, feed its frames into a pipeline.
How it works
Mechanically it's the same counter design as Get Image File By Index: a per-node counter (keyed to the node's unique ID), the mode and start/stop/step inputs, reset_bool, wrap-around at the folder size, and the always-rerun float("NaN") from IS_CHANGED so the counter actually advances every queue. The video filter matches Random Video Path - .webm, .mp4, .mkv, .gif - and, like that node, it decodes every frame of the chosen clip into RAM as normalized float tensors. The canvas preview shows the first frame, a resolution/fps/duration readout, and Index: x / n so you always know where you are in the folder.
The whole-video-in-memory caveat from Random Video Path applies here in full: one 1080p float32 frame is roughly 12 MB and there's one per frame, so a long clip can eat tens of gigabytes. This node is a stepper, not a streaming loader - keep clips short, or keep the folder to clips that fit.
The inputs that matter
mode-increment/decrementwrap forever;increment_to_stop/decrement_to_stophalt atstop.start,stop,step- the counter's start, its ceiling for the_to_stopmodes, and the step size.reset_bool- reset the counter tostarton that run.directory_path- absolute folder path.
Same first-run quirk as the image version: the counter starts at start and then the mode applies on that same run, so with defaults the first clip is index 1, not 0.
Outputs
images(IMAGE) - the whole video as a sequence of frame tensors.filename(STRING) - full path of the current clip.index(NUMBER) andint(INT) - the raw counter (pre-wrap) in float and int; wire whichever your downstream accepts.
Installing it
Manager search "ComfyUI-Get-Random-File" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/ChrisColeTech/ComfyUI-Get-Random-File
then restart. This is one of the two nodes that needs the pack's OpenCV dependency (opencv-python, plus imageio-ffmpeg for the ffmpeg backend); Manager installs both, and pip install -r requirements.txt covers a manual clone. It's the heaviest dependency in the pack, and only the video nodes pull it in.
Gotchas
- Memory, again - the whole clip is decoded per pick; keep the folder to short clips.
- Unsorted listing - "index" is filesystem order, not alphabetical, so verify the sequence you care about.
- Off-by-one on the first run with defaults.
- Preview is scratch - it lands in
temp/, so don't expect the clip or its preview inoutput/.
If you just need a random video's path without decoding it, Random File Path is the lighter tool.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| reset_bool | BOOLEAN | false | — |
| mode | COMBO | increment | 4 options: increment, decrement, increment_to_stop, decrement_to_stop |
| start | INT | 00–18446744073709550000 | — |
| stop | INT | 11–18446744073709550000 | — |
| step | INT | 11–99999 | — |
| directory_path | STRING | — | |
| splitopt | BOOLEAN | true | Off = skip decoding frames/audio entirely (much faster when you only need the video/filename outputs - they stay fully functional; fps/frame_count come from the container header). Leave images/audio unwired when off. |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| filename | STRING | — |
| index | NUMBER | — |
| int | INT | — |
| video | VIDEO | — |
| audio | AUDIO | — |
| fps | FLOAT | — |
| frame_count | INT | — |