Nodes/ComfyUI-FairLab/Image To Video
ComfyUI Node

Image To Video

Frames to MP4 in one node — Image To Video encodes a folder of images into a video

By yanhuifair·Created 2 years ago·Updated 3 months ago· 2
Image To Video
    • image_paths
    • video_path
    image_dir
    frame_rate30
    video_dir
    video_nameoutput

    You've got a folder full of frames - maybe extracted from a video, maybe rendered frame-by-frame by a generation workflow - and you want them stitched back into an MP4. Image To Video does exactly that: point it at a directory of images, tell it the frame rate, and it writes a video file using OpenCV, returning the image paths and the output video path.

    The mechanism, from the source, is a classic OpenCV encode. It lists everything in image_dir, reads the first image to get the resolution, creates a VideoWriter with the mp4v codec at your frame_rate, and writes every image in order before releasing the writer. It uses the pack's opencv-python dependency, which is one of the heavier things FairLab installs - but it comes with the pack, so there's nothing extra for you to download.

    The inputs:

    • image_dir - the folder containing the frames.
    • frame_rate - frames per second, default 30.
    • video_dir - where to write the output.
    • video_name - the output filename base, default output (produces output.mp4).

    The outputs:

    • image_paths - the list of image paths it read (returned as a string).
    • video_path - the full path to the written MP4.

    Now the gotchas, and there are two real ones. First, frame order is not guaranteed. The node uses os.listdir(image_dir), which returns files in arbitrary order on most filesystems. If your frames are named frame_1.png, frame_2.png, ..., frame_10.png, you will very likely get frame_10 before frame_2, and your video will stutter and jump. Zero-pad your filenames (frame_001.png) - that sorts correctly in practice on most systems - and don't assume the node sorts for you. Second, the resolution comes from the first image and every frame is written as-is, so all frames must share the same dimensions; a mismatched frame breaks the encode. No audio, no fancy settings - it's a silent video of your frames.

    Where it fits: turning extracted frames back into a video after processing, or collecting the output of a frame-by-frame generation into a playable clip. It's the encode half of the pack's video story (Video To Image is the decode half).

    A couple of notes from the source: the image and video directories are passed through with surrounding quotes stripped, which is a small convenience if you paste a path with quotes from a file manager. And the mp4v codec output plays in most players but is re-encodable to H.264 if you need a smaller file.

    Install is the standard pack path: ComfyUI Manager → search ComfyUI-FairLab → install → restart:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yanhuifair/ComfyUI-FairLab.git
    cd ComfyUI-FairLab
    pip install -r requirements.txt
    

    Restart, search "Image To Video" or "encode video". It does need opencv-python - if your ComfyUI env is missing it, pip install opencv-python fixes it, and pip list | grep opencv confirms it's there.

    CategoryFair/image

    Inputs (4)

    NameTypeDefaultDescription
    image_dirSTRING
    frame_rateINT30
    video_dirSTRING
    video_nameSTRINGoutput

    Outputs (2)

    NameTypeDescription
    image_pathsSTRING
    video_pathSTRING