Nodes/ComfyUI-LoadAnim-Adv/Load Images/Videos From Directory
ComfyUI Node

Load Images/Videos From Directory

Batch-loading a whole folder of animation, the right way

By SineSwiper·Created 7 months ago·Updated 7 months ago· 0
Load Images/Videos From Directory
    • image
    • mask
    • audio
    • frame_counts
    • fps
    • image_path
    directory
    RGBAfalse
    width0
    height0
    keep_aspect_ratio
    image_file_load_cap0
    image_file_start_index0
    frame_indexes_to_select0:
    total_frame_load_cap0
    flatten_framesfalse
    include_subfoldersfalse
    valid_extensionsjpg,jpeg,png,webp,gif,tga
    sort_method

    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, default jpg,jpeg,png,webp,gif,tga. Add mp4,mov,avi,mkv if 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. Default 0: 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 frame
    • 0,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:

    1. Audio is not sliced by frame selection. If you select a subset of frames from a video, the audio output still carries the full track - so it'll drift out of sync with your shortened clip. The README flags it as a known issue.
    2. Flattened FPS is a lie. If you flatten files with different frame rates, the fps output 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.

    CategoryLoadAnimAdv/Loaders

    Inputs (13)

    NameTypeDefaultDescription
    directorySTRINGAbsolute or relative path to the image directory.
    RGBABOOLEANfalseControls whether to include the Alpha channel in the 'image' output. The 'mask' output will always include this data.
    widthINT0Final width of images, after resizing. Zero means to keep the original width.
    heightINT0Final height of images, after resizing. Zero means to keep the original height.
    keep_aspect_ratioCOMBOWhat action to take, when the image doesn't match the expected aspect ratio.
    image_file_load_capINT0Maximum amount of image files (not frames) to load. Zero means no maximum.
    image_file_start_indexINT0Index (zero-based) to start loading files, based on the collected filenames from the directory search.
    frame_indexes_to_selectSTRING0: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_capINT0Maximum amount of total frames to load. Zero means no maximum.
    flatten_framesBOOLEANfalseControls whether to flatten the frames from multiple files into a single image set. This impacts all outputs except 'image_path'.
    include_subfoldersBOOLEANfalseControls whether to recursively search for files within subdirectories.
    valid_extensionsSTRINGjpg,jpeg,png,webp,gif,tgaComma-delimited list of file extensions to search for.
    sort_methodCOMBOControls how to sort the image filename list.

    Outputs (6)

    NameTypeDescription
    imageIMAGEThe image data, either as a single image or a set of frames.
    maskMASKAny transparency data found in the Alpha channel or transparent palette index.
    audioAUDIOThe audio from the video, if any.
    frame_countsINTTotal number of frames loaded from all images.
    fpsFLOATFrames-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_pathSTRINGFilenames of the loaded images.