Random Video Path π²
Random video, decoded to frames β fun until your RAM taps out
- images
- filename
- video
- audio
- fps
- frame_count
Random Image Path, but for video: point it at a folder, and it pulls a random video, decodes it, and hands you the frames as an IMAGE output plus the filename as a STRING. Great for randomly pulling clips into a video pipeline or grabbing a surprise motion reference. Just be ready for the memory math, because this is the node in the pack where the "it just works" energy runs into reality.
How it works
Same recursive os.walk() walk as the others, this time filtered to video extensions: .webm, .mp4, .mkv, .gif. A file is picked at random, then OpenCV (cv2.VideoCapture) opens it and reads every frame into a list of normalized float tensors. That frame collection is your images output, so downstream you're getting the whole clip as a sequence of frames, not one combined image. The node also shows a first-frame preview on the canvas plus a tidy readout of the clip - resolution, frame count, fps, duration - which is a nice touch for a small utility. And yes, the always-rerun float("NaN") trick is here too, so each Queue pulls a new random video.
The inputs and outputs that matter
directory_path- the one input. Absolute path, type it or wire it.images(IMAGE) - every frame of the video as tensors. Feed it to whatever can consume a frame sequence; whether a given downstream node accepts this directly depends on that node handling frames one by one.filename(STRING) - the full path, for logging or for anything that just wants the file.
The memory thing, up front
This is the honest warning the README won't give you: the whole video ends up in RAM as float32 tensors. One 1080p RGB frame at float32 is roughly 12 MB, and that's per frame - a three-minute 30 fps clip is about 5,400 frames, which is 60+ GB. Short clips, fine. Long videos, your machine will fall over. If all you needed was a random video path and never the pixels, the plain Random File Path node from this pack gives you that without decoding anything.
Installing it
Manager search "ComfyUI-Get-Random-File" β install, or clone:
cd ComfyUI/custom_nodes
git clone https://github.com/ChrisColeTech/ComfyUI-Get-Random-File
and restart. This is the node that justifies the pack's heavy requirements.txt: opencv-python is a big wheel, and imageio-ffmpeg bundles an ffmpeg binary to back it. Manager handles both; if you cloned manually, run pip install -r requirements.txt in the pack folder. It's the one install in this pack that can actually take a minute.
Gotchas
- Whole video in RAM (see above) - keep clips short.
- Empty or invalid
directory_pathβNotADirectoryError; no matching files βFileNotFoundError. Amusingly, the error even says "No image files found" on this video node - the author copy-pasted and it shows. - Codec trouble is rare but real. If OpenCV can't open the picked file you get a
ValueError; theimageio-ffmpegdependency exists to keep the ffmpeg backend available.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| directory_path | STRING | β | |
| randomizeopt | BOOLEAN | true | On (default) = pick a new random file every run. Off = keep returning the currently selected file (per node; re-picks only if that file no longer exists). |
| 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 (6)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | β |
| filename | STRING | β |
| video | VIDEO | β |
| audio | AUDIO | β |
| fps | FLOAT | β |
| frame_count | INT | β |