Nodes/ComfyUI_Lam/视频加载
ComfyUI Node

视频加载

Pull video frames into the graph, with optional audio extraction

By yanlang0123·Created 2 years ago·Updated 11 days ago· 77
视频加载
    • 图片
    • 帧率
    • 总帧数
    • 音频文件名
    videoPath
    sample_start_idx1
    n_sample_frames0
    extract_audiofalse
    filename_prefixcomfyUI

    ComfyUI's built-in video loader is picky about where files live and hands you a fixed format. LamLoadVideo (视频加载) takes the simpler path: you give it a real file path, it reads the video with OpenCV, and gives you the frames as an IMAGE batch plus the frame rate and total frame count. Turn on extract_audio and it also rips the soundtrack out to an mp3 with ffmpeg. That last part is the feature people actually search for.

    The workflow pattern it's built for: you want a handful of frames from a video to work with (style transfer, frame interpolation, detection, or just choosing a still), and you want to keep the numbers - fps and length - so downstream nodes can reconstruct timing. And when you need the audio for a TTS/dubbing/sync workflow, having it come out of the same node means no separate ffmpeg step in your graph.

    Inputs that matter

    • videoPath - the video file path. Forced-input, so wire it from a path/loader node. A missing file throws a "视频文件不存在" error - this node fails loudly, unlike the pack's image loader.
    • sample_start_idx - which frame to start at. Default 1. Negative counts backward from the end (e.g. -1 starts at the last frame).
    • n_sample_frames - how many frames to grab. Default 0 means all of them.
    • extract_audio - true runs ffmpeg to pull the audio track into an mp3.
    • filename_prefix - prefix for the extracted audio file (default comfyUI).

    Outputs

    • 图片 (IMAGE) - the sampled frames as a batch.
    • 帧率 (INT) - the video's fps.
    • 总帧数 (INT) - total frame count.
    • 音频文件名 (STRING) - the path to the extracted mp3, or an empty string if extract_audio was off.

    Install

    Part of the ComfyUI_Lam pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yanlang0123/ComfyUI_Lam
    

    or via ComfyUI Manager, then the README's install + 修改文件 steps. Audio extraction needs ffmpeg available on your PATH - on the portable Windows build it usually is, on Linux you may need to install it.

    Gotchas

    The extract_audio flag is the trap: it defaults to false, so if your audio output comes back as an empty string, check that switch before you blame ffmpeg. Opening a video with OpenCV fails silently-ish for some codecs - if you get zero frames from a file that plays fine in a player, the codec (often HEVC/H.265, sometimes AV1) isn't in your OpenCV build, and you'll want to re-encode or install opencv with the right video support. And grabbing every frame of a long video will happily eat RAM; set n_sample_frames when you only need a clip.

    Categorylam

    Inputs (5)

    NameTypeDefaultDescription
    videoPathSTRING
    sample_start_idxINT1-10000–10000
    n_sample_framesINT00–100000
    extract_audioCOMBOfalse2 options: true, false
    filename_prefixSTRINGcomfyUI

    Outputs (4)

    NameTypeDescription
    图片IMAGE
    帧率INT
    总帧数INT
    音频文件名STRING