视频人脸马赛克
Blur faces in a ComfyUI video without wiring five nodes
- output_video_path
- processing_info
The honest way to blur faces in ComfyUI today is a small graph: an Impact Pack detector spits out a mask, you feed it into a Blur Masked Area node, and you splice the result back over the video. It works, and it's the answer most people get in the subreddit when they ask. This node is the answer you didn't know you wanted: one box that does the whole job. Point it at a video file, it detects faces frame by frame, applies the mosaic, and writes out a finished file. That's the entire pitch, and for a privacy-masking step it's often enough that the five-node graph is pure overhead.
It lives in yzzky/yzz_face_mosaic, a small MIT-licensed pack where every node's display name is in Chinese - look for 视频人脸马赛克 (video face mosaic) under the YZZ_Face_Mosaic category.
How it works
No model weights, no neural network. This is OpenCV's Haar cascade - haarcascade_frontalface_default.xml, the same detector that's been finding faces on laptops since 2001 - running on every frame. Haar is ancient, CPU-cheap, and surprisingly robust at frontal faces. The node converts each frame to grayscale, runs detectMultiScale, then paints the mosaic over every bounding box it finds.
Three mosaic styles, chosen by mosaic_type:
pixelate- downscale the face region, blow it back up with nearest-neighbor. The classic blocky look.blur- Gaussian blur sized offmosaic_size.black_box- just fill the rectangle black. Blunt, but it's what privacy regs actually want sometimes.
Output is written with OpenCV's VideoWriter (mp4v for mp4/mov, XVID for avi) into ComfyUI/output/face_mosaic/ unless you give output_path.
The inputs that actually matter
- video_path - a plain string path. Painful to type, which is why this pack ships the
VideoUploadNodehelper: it returns avideo_pathstring you can wire straight in. - detection_scale and min_neighbors - these two decide whether it finds faces at all. Lower
detection_scale(toward 1.01) is more thorough but slower; highermin_neighborskills false positives but can miss real faces. The defaults (1.1 / 5) are fine to start. - mosaic_size - 20 is chunky and obvious; try 10 for something subtler.
- mosaic_type, output_format - self-explanatory. One honest gotcha:
output_qualityis accepted but the shipped OpenCV writer never feeds it to the encoder, so don't expect it to change file size. If quality matters, use the Unified GPU node's ffmpeg re-encode instead.
Outputs are output_video_path (a STRING pointing at the new file) and processing_info (a JSON string with frame counts, faces detected, and timing - handy for a text-display node).
Installing it
Whole pack installs at once via ComfyUI Manager - search yzz_face_mosaic - or:
cd ComfyUI/custom_nodes
git clone https://github.com/yzzky/yzz_face_mosaic
pip install -r requirements.txt # in your ComfyUI Python env
Then restart ComfyUI. The heavy optional backends (insightface, facenet-pytorch) are not in requirements.txt - you only add those for the GPU/Torch/Selective nodes. This one needs nothing but OpenCV, which requirements.txt pulls.
Where it bites
Haar is a frontal-face detector from the dial-up era. Profile shots, sunglasses, small faces in the background, low light - it will quietly miss them, and the video will come out with people's faces intact. Crank detection_scale down and min_neighbors down if you're missing faces, or step up to the GPU/Torch nodes in this pack that use proper detectors. And remember it's fully CPU: a long 1080p clip will take a while, and the console prints a progress line every 30 frames so you know it's alive.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| video_path | STRING | — | |
| mosaic_size | INT | 205–100 | — |
| detection_scale | FLOAT | 1.101.01–2 | — |
| min_neighbors | INT | 51–20 | — |
| mosaic_type | COMBO | 3 options: pixelate, blur, black_box | |
| output_format | COMBO | 3 options: mp4, avi, mov | |
| output_quality | INT | 801–100 | — |
| output_pathopt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output_video_path | STRING | — |
| processing_info | STRING | — |