Load Images/Videos From Directory
Batch-loading a whole folder of animation, the right way
- image
- mask
- audio
- frame_counts
- fps
- image_path
Single-file loaders are easy. The moment you have a folder of 200 renders, 50 shot files, or a frame sequence scattered across subdirectories, you find out which loader nodes actually pull their weight. Load Images/Videos From Directory is the heavyweight of SineSwiper's LoadAnim-Adv pack: point it at a folder and it loads every image or video in it, lets you pick which frames to keep, and hands you the file paths so you know what you got.
What it's for
This is the batch engine of the pack. It runs the same loader that backs Load Image/Video, but in a loop over a directory scan. Typical jobs: feeding a whole shot's worth of frames into a vid2vid pipeline, ingesting a folder of GIFs for frame extraction, or preprocessing an image sequence before a batch loop. The README even calls out the killer trick - image_file_start_index exists specifically so you can increment it in a batch loop and chew through files sequentially without reloading everything.
The inputs that matter
Most are shared with the single-file loaders: directory, RGBA, width/height (0 = original), keep_aspect_ratio. The interesting ones are the batch controls:
valid_extensions- comma-delimited list, defaultjpg,jpeg,png,webp,gif,tga. Addmp4,mov,avi,mkvif you want videos in the scan.sort_method-None, Alphabetical (ASC/DESC), Numerical (ASC/DESC), or Datetime (ASC/DESC). Numerical is the one you want for frame sequences - it sorts file2 before file10, which plain alphabetical sorting won't do.image_file_load_cap- max number of files to load. 0 = no limit.image_file_start_index- skip this many files from the front. This is your batch-loop hook.frame_indexes_to_select- the frame-selection syntax, applied to each file. Default0:means every frame.total_frame_load_cap- a global cap on frames across all files, for when the folder is bigger than your VRAM patience.flatten_frames- when on, all files' frames get concatenated into one IMAGE tensor instead of staying as per-file sets.include_subfolders- recurse. Off by default.
Outputs
Everything comes out as a list: image, mask, audio, frame_counts, fps, and image_path (the filenames, in the same order - invaluable for debugging what actually loaded). If flatten_frames is on, image collapses to a single combined set.
The frame selection syntax
It's Python's range() with the parts separated by colons, first frame = index 0:
0:5- frames 0 through 4:-5- all but the last 5::2- every second frame0,5:10,-1- a mix of singles, ranges, and the last frame
Gotchas - read these before you run it
Two real traps, both in the author's own tooltips:
- Audio is not sliced by frame selection. If you select a subset of frames from a video, the
audiooutput still carries the full track - so it'll drift out of sync with your shortened clip. The README flags it as a known issue. - Flattened FPS is a lie. If you flatten files with different frame rates, the
fpsoutput is just the average, which the tooltip warns "may have unpredictable results." Keep your sources at matching FPS if you need the number to mean anything.
Also worth knowing: the node raises an error if the directory doesn't exist or has no matching files - it fails loudly rather than silently feeding your pipeline nothing.
Installing
ComfyUI Manager → search "LoadAnim", or:
cd ComfyUI/custom_nodes
git clone https://github.com/SineSwiper/ComfyUI-LoadAnim-Adv.git
Restart, done. Dependencies are just torch, numpy, Pillow - no models to download.
For a one-shot single file this node is overkill. For a folder, it's the difference between writing 200 Load Image nodes and writing one.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | Absolute or relative path to the image directory. | |
| RGBA | BOOLEAN | false | Controls whether to include the Alpha channel in the 'image' output. The 'mask' output will always include this data. |
| width | INT | 0 | Final width of images, after resizing. Zero means to keep the original width. |
| height | INT | 0 | Final height of images, after resizing. Zero means to keep the original height. |
| keep_aspect_ratio | COMBO | What action to take, when the image doesn't match the expected aspect ratio. | |
| image_file_load_cap | INT | 0 | Maximum amount of image files (not frames) to load. Zero means no maximum. |
| image_file_start_index | INT | 0 | Index (zero-based) to start loading files, based on the collected filenames from the directory search. |
| frame_indexes_to_select | STRING | 0: | Frame indexes (zero-based) to select from each image file. Supports ':' for range selection (including ':#', '#:' formats), '::#' & '#::#' & '#:#:#' formats for step selection, ',' for multiple entries, and negative numbers for selecting from the end. Note that audio is not sliced based on frame selection, which may cause audio desyncs. (This may be fixed in the future.) |
| total_frame_load_cap | INT | 0 | Maximum amount of total frames to load. Zero means no maximum. |
| flatten_frames | BOOLEAN | false | Controls whether to flatten the frames from multiple files into a single image set. This impacts all outputs except 'image_path'. |
| include_subfolders | BOOLEAN | false | Controls whether to recursively search for files within subdirectories. |
| valid_extensions | STRING | jpg,jpeg,png,webp,gif,tga | Comma-delimited list of file extensions to search for. |
| sort_method | COMBO | Controls how to sort the image filename list. |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | The image data, either as a single image or a set of frames. |
| mask | MASK | Any transparency data found in the Alpha channel or transparent palette index. |
| audio | AUDIO | The audio from the video, if any. |
| frame_counts | INT | Total number of frames loaded from all images. |
| fps | FLOAT | Frames-per-second, as reported from all of the image metadata. This may be zero, if the data could not be found, or the image doesn't animate. If flattened, multiple animations with different FPSs will be averaged and may have unpredictable results. |
| image_path | STRING | Filenames of the loaded images. |