优化版视频人脸马赛克
The 'optimized' video face mosaic — faster, with a side of fiction
- output_video_path
- processing_info
Long video files are where the plain CPU mosaic node starts to hurt - it chews through a 1080p clip one frame at a time on a single thread. This variant is the pack's answer to that: same Haar-cascade detection, but with a thread pool, frame batching, and a GPU path it tries to use. In the menu it's 优化版视频人脸马赛克 (optimized video face mosaic) under YZZ_Face_Mosaic.
How it works
The core detector is still OpenCV's Haar cascade, but the plumbing is different. With parallel_processing on, frames are read in batches (up to 1000 in memory to avoid blowing up on long clips) and handed to a ThreadPoolExecutor capped at 8 workers - detection for many frames runs concurrently while the writer stays serialized. batch_size (1–16) sets how many frames go through the pipe per batch.
optimization_level is the interesting knob, because it rewrites your other settings:
fast- forcesdetection_scaleup to at least 1.2 andmin_neighborsto at least 3. Fewer detections per frame, faster.accurate- clampsdetection_scaledown to 1.05 andmin_neighborsto 8 max. More thorough, slower.balanced- leaves your values alone.
So if you set detection_scale to 1.02 and then pick "fast," the node quietly ignores your value. That's worth knowing when you're wondering why faces are getting missed.
About that GPU toggle
use_gpu here attempts OpenCV's CUDA-accelerated CascadeClassifier - cv2.cuda. Reality check: stock pip install opencv-python wheels are not built with CUDA, so hasattr(cv2, 'cuda') is False on almost every ComfyUI install and the node just prints a warning and falls back to CPU. It's a genuine capability, but you'd need a CUDA-enabled OpenCV build to ever see it. Don't buy the node for this feature.
Inputs and outputs
Same cast as the plain node: video_path, mosaic_size, detection_scale, min_neighbors, mosaic_type, output_format, output_quality, optional output_path - plus use_gpu, parallel_processing, batch_size, optimization_level. Outputs are output_video_path and processing_info (JSON with frames, faces, and processing time/fps). Files land in ComfyUI/output/face_mosaic/.
Installing it
Standard pack install: ComfyUI Manager → yzz_face_mosaic, or git clone https://github.com/yzzky/yzz_face_mosaic into custom_nodes + pip install -r requirements.txt, restart. No extra backends needed - this is a pure OpenCV node.
Where it bites
"Optimized" is doing a lot of work. The thread pool helps when the bottleneck is per-frame detection, but video write and OpenCV internals are still serialized, so don't expect a 4× speedup - on many machines the plain node and this one land close. The honest win is optimization_level, which trades detection quality for speed without you fiddling three sliders. If your real problem is accuracy (missed faces), this node doesn't fix that - that's what the InsightFace or MTCNN variants are for.
Inputs (12)
| 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 | — |
| use_gpu | BOOLEAN | true | — |
| parallel_processing | BOOLEAN | true | — |
| batch_size | INT | 41–16 | — |
| optimization_level | COMBO | 3 options: fast, balanced, accurate | |
| output_path | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output_video_path | STRING | — |
| processing_info | STRING | — |