Nodes/ComfyUI-FFmpeg/🔥PipVideo
ComfyUI Node

🔥PipVideo

Overlay one video on another — with optional green screen

By MoonHugo·Created 2 years ago·Updated 4 months ago· 146
🔥PipVideo
    • video_complete_paths
    • width
    • height
    • duration
    • fps
    video1_pathC:/Users/Desktop/video1.mp4
    video2_pathC:/Users/Desktop/video2.mp4
    devicecpu
    use_audiovideo1
    use_durationvideo2
    align_typecenter
    pip_fg_zoom2.5
    output_pathC:/Users/Desktop/output
    scale_and_cropnone
    fps30.0
    is_chromakeyfalse

    PipVideo is the picture-in-picture node: one video plays in the background while a second, smaller one sits on top of it. That's the classic "reaction cam over gameplay" or "talking head in the corner" composition, and the node even throws in a green-screen keying option so a chroma-keyed foreground can float over the background without a box. It's the most feature-dense node in the pack, and also the fiddliest - worth it if you actually need PiP, overkill if you just want to stack two clips side by side (that's StitchingVideo's job).

    How it works

    FFmpeg's overlay filter does the compositing. Both videos are looped (-stream_loop -1) and trimmed to whichever duration you pick, so a short foreground can sit over a long background without running out of frames. If is_chromakey is on, the foreground is run through chromakey=0x00FF00 - that's a hardcoded green, so your foreground genuinely needs a green (or near-green) background. No picking your key color.

    The inputs that matter

    • video1_path / video2_path - background and foreground respectively. No preview here, no dropzone; paste absolute paths.
    • align_type - where the foreground sits: top-left, top-right, bottom-left, bottom-right, or center.
    • pip_fg_zoom - the confusingly-named one. It's not zoom - it's the divisor. Higher values make the foreground smaller. Default 2.5 means the foreground is the background's width divided by 2.5. Want it half size? Set 2. Want it tiny in the corner? Set 5.
    • use_duration - video1 or video2; which clip sets how long the final render runs. use_audio picks whose soundtrack you keep.
    • scale_and_crop - none, or force the output to a fixed 540×960 or 960×540, cropping or letterboxing as needed.
    • fps - force a frame rate. Per the README, 0 and 1 both mean "use video2's fps" (yes, it's a duplicate - that's the author's own docs), anything else forces that rate.
    • is_chromakey - the green-screen toggle.

    Outputs

    Returns video_complete_paths (where the file landed), plus the resulting width, height, duration, and fps as numbers - handy if you're feeding the size downstream.

    Install

    Same as the rest of the pack: FFmpeg on PATH is the real requirement; the Python side is a single dependency. ComfyUI Manager, search "ComfyUI-FFmpeg", or:

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

    Restart ComfyUI afterwards.

    Gotchas

    • device here is cpu or cuda - if you pick cuda and the encode chokes, the node automatically retries on CPU. That auto-retry is a nice touch, but it means a failed GPU run silently becomes a CPU run, so your "GPU" encode might not be what you think.
    • libx264 needs even dimensions; the node rounds width/height up to the nearest even number for you, so that specific error is less likely here than elsewhere.
    • The chromakey color and thresholds are hardcoded. A badly lit green screen will leave halos, and there's no tolerance knob to fix it.
    Category🔥FFmpeg

    Inputs (11)

    NameTypeDefaultDescription
    video1_pathSTRINGC:/Users/Desktop/video1.mp4说明:画中画背景画面!
    video2_pathSTRINGC:/Users/Desktop/video2.mp4说明:画中画前景画面!
    deviceCOMBOcpu2 options: cpu, cuda
    use_audioCOMBOvideo1说明:最终视频使用哪个视频的音轨!
    use_durationCOMBOvideo2说明:使用哪个视频作为最终参考时长!
    align_typeCOMBOcenter5 options: top-left, top-right, bottom-left, bottom-right, center
    pip_fg_zoomFLOAT2.51–100说明:画中画背景缩放系数,越大前景画面越小,值为背景宽高的缩小倍数!
    output_pathSTRINGC:/Users/Desktop/output
    scale_and_cropCOMBOnone说明:缩放和裁剪比例!
    fpsFLOAT30.00–60说明:画中画合并后的强制帧率,设置为0将使用video2的帧率,设置为1为将使用video2的帧率!
    is_chromakeyBOOLEANfalse说明:是否进行绿幕去背景!

    Outputs (5)

    NameTypeDescription
    video_complete_pathsSTRING
    widthINT
    heightINT
    durationFLOAT
    fpsFLOAT