🔥PipVideo
Overlay one video on another — with optional green screen
- video_complete_paths
- width
- height
- duration
- fps
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, orcenter. - pip_fg_zoom - the confusingly-named one. It's not zoom - it's the divisor. Higher values make the foreground smaller. Default
2.5means 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 -
video1orvideo2; which clip sets how long the final render runs.use_audiopicks 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,
0and1both 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
cpuorcuda- if you pickcudaand 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. libx264needs 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.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| video1_path | STRING | C:/Users/Desktop/video1.mp4 | 说明:画中画背景画面! |
| video2_path | STRING | C:/Users/Desktop/video2.mp4 | 说明:画中画前景画面! |
| device | COMBO | cpu | 2 options: cpu, cuda |
| use_audio | COMBO | video1 | 说明:最终视频使用哪个视频的音轨! |
| use_duration | COMBO | video2 | 说明:使用哪个视频作为最终参考时长! |
| align_type | COMBO | center | 5 options: top-left, top-right, bottom-left, bottom-right, center |
| pip_fg_zoom | FLOAT | 2.51–100 | 说明:画中画背景缩放系数,越大前景画面越小,值为背景宽高的缩小倍数! |
| output_path | STRING | C:/Users/Desktop/output | — |
| scale_and_crop | COMBO | none | 说明:缩放和裁剪比例! |
| fps | FLOAT | 30.00–60 | 说明:画中画合并后的强制帧率,设置为0将使用video2的帧率,设置为1为将使用video2的帧率! |
| is_chromakey | BOOLEAN | false | 说明:是否进行绿幕去背景! |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| video_complete_paths | STRING | — |
| width | INT | — |
| height | INT | — |
| duration | FLOAT | — |
| fps | FLOAT | — |