Nodes/komojini-comfyui-nodes/YouTube Video Loader
ComfyUI Node

YouTube Video Loader

YouTube Video Loader — pull any embeddable clip straight into your workflow

By komojini·Created 3 years ago·Updated 2 years ago· 77
YouTube Video Loader
    • images
    • frame_count
    • fps
    • width
    • height
    youtube_urlyoutube/url/here
    start_sec0.0
    end_sec0.0
    max_fps-1
    force_size
    frame_load_cap50
    output_dir

    YouTube Video Loader is the purpose-built version of the komojini pack's signature trick: give it a YouTube URL, and it downloads the video, extracts the frames you asked for, and hands them to your workflow as an IMAGE batch - plus frame count, fps, width and height so downstream nodes know what they're looking at. This is the node from the pack's January 2024 r/comfyui demo ("Download short-clips from youtube with custom node by Komojini"), and honestly the demo still nails the use case: you want a few seconds of a specific clip for local img2vid or video processing, and you don't want to leave ComfyUI to get it.

    Compared to the pack's Ultimate Video Loader, this one drops the filepath/file-upload/empty-video sources and the fancy preview - it's YouTube-only and simpler. Which is why you'd pick it: if the video you need lives on YouTube, this is the minimal node with no extra moving parts.

    How it works. It uses pytube to pull the highest-resolution progressive MP4 stream, saves it to ComfyUI/output/youtube/ by default (or wherever you point the optional output_dir), then reads frames out of the downloaded file with OpenCV. start_sec / end_sec trim the window - end_sec 0.0 means to the end of the video. frame_load_cap (default 50) caps how many frames come back and lowers the effective fps to match the window, so a long clip with a small cap gives you evenly-spaced frames rather than just the first 50. max_fps clamps the rate separately, and force_size resamples to one of the aspect-ratio presets (256x?, ?x512, 512x512, …).

    Inputs and outputs. The required inputs are youtube_url, start_sec, end_sec, max_fps, force_size, and frame_load_cap; the only optional one is output_dir (leave it blank for the default output/youtube/). Outputs: images (IMAGE), frame_count, fps, width, height (all INT). Feed images into your encoder/sampler and fps into your VideoCombine.

    Install. It's part of komojini-comfyui-nodes:

    ComfyUI Manager → search "komojini-comfyui-nodes" → Install → restart
    

    or cd ComfyUI/custom_nodes && git clone https://github.com/komojini/komojini-comfyui-nodes. The heavy-ish dependency here is pytube==15.0.0 (pinned), plus opencv-python. No model files.

    Where people get burned. The pinned pytube 15.0.0 is the #1 failure point - YouTube breaks pytube on a semi-regular basis, and when it does you'll see extraction errors or "VideoUnavailable" on videos that are obviously fine. Only videos that allow embedding can be downloaded; private, age-gated, or embed-disabled videos won't work. And it's a 2024 pack, so don't expect maintenance - if pytube breaks, you're patching it yourself or switching to a maintained loader. If YouTube downloading is a core part of your pipeline, VHS (VideoHelperSuite) is the better-maintained, more reliable option; this node is the quick-and-dirty path.

    Categorykomojini/Video

    Inputs (7)

    NameTypeDefaultDescription
    youtube_urlSTRINGyoutube/url/here
    start_secFLOAT0.00–10000
    end_secFLOAT0.00–10000
    max_fpsINT-1-1–30
    force_sizeCOMBO9 options: Disabled, 256x?, ?x256, 256x256, 512x?, ?x512, +3
    frame_load_capINT501–10000
    output_diroptSTRING

    Outputs (5)

    NameTypeDescription
    imagesIMAGE
    frame_countINT
    fpsINT
    widthINT
    heightINT