Nodes/ComfyUI-Get-Random-File/Get Video File By Index ▶️
ComfyUI Node

Get Video File By Index ▶️

A counter for your video folder — same idea as the image version, frames included

By ChrisColeTech·Created 2 years ago·Updated 4 days ago· 3
Get Video File By Index ▶️
    • images
    • filename
    • index
    • int
    • video
    • audio
    • fps
    • frame_count
    reset_boolfalse
    modeincrement
    start0
    stop1
    step1
    directory_path
    splittrue

    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 / decrement wrap forever; increment_to_stop / decrement_to_stop halt at stop.
    • start, stop, step - the counter's start, its ceiling for the _to_stop modes, and the step size.
    • reset_bool - reset the counter to start on 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) and int (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 in output/.

    If you just need a random video's path without decoding it, Random File Path is the lighter tool.

    Category🤖 CCTech/Files

    Inputs (7)

    NameTypeDefaultDescription
    reset_boolBOOLEANfalse
    modeCOMBOincrement4 options: increment, decrement, increment_to_stop, decrement_to_stop
    startINT00–18446744073709550000
    stopINT11–18446744073709550000
    stepINT11–99999
    directory_pathSTRING
    splitoptBOOLEANtrueOff = 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)

    NameTypeDescription
    imagesIMAGE
    filenameSTRING
    indexNUMBER
    intINT
    videoVIDEO
    audioAUDIO
    fpsFLOAT
    frame_countINT