A versatile node for loading individual frames from video files in a directory. This node supports multiple video formats and various loading modes, making it ideal for video-based workflows in ComfyUI.
.mp4
.avi
.mov
.mkv
- mode: Select how video frames are loaded:
single_video
: Load a specific frame from a specific video using indexincremental_video
: Load frames sequentially across videosrandom
: Load a random frame based on seed value
- seed: Random seed for the random mode
- Default: 0
- Range: 0 to 18446744073709551615
- index: The index of the video in the directory listing
- Default: 0
- Range: 0-150000
- Used to select which video to load from
- frame: The frame number to extract from the video
- Default: 0
- Range: 0-999999
- Note: If frame number exceeds video length, last frame is used
- label: A label for the batch (for organization)
- Default: 'Video Batch 001'
- path: Directory path containing the video files
- Must be a valid directory path
- pattern: File matching pattern
- Default: '*'
- Supports glob patterns (e.g., '.mp4', 'video_')
- frame: The loaded video frame as an IMAGE tensor
- Format: RGB
- Normalized to 0-1 range
- Shape: [batch, height, width, channels]
- filename_text: The filename of the source video
- Loads the video at the specified index in the directory
- Extracts the requested frame number
- Returns the frame and filename
- Keeps track of current position in the video list
- Loads frames sequentially across videos
- Wraps back to start when reaching the end
- Uses the provided seed for randomization
- Selects a random video from the directory
- Loads the specified frame from the random video
- Video frames are loaded using OpenCV
- Converted from BGR to RGB color space
- Normalized to 0-1 range
- Converted to PyTorch tensor
- Reshaped to match ComfyUI's expected format
- Validates directory path existence
- Handles invalid video files
- Manages frame number overflow
- Returns None for invalid video/frame combinations
- Training data preparation from videos
- Frame extraction for video editing
- Random frame sampling for AI training
- Sequential video processing
- Batch processing of multiple video files