Menu

Blur faces in video with MediaPipe and FFmpeg (without the flicker)
πŸ“°

Blur faces in video with MediaPipe and FFmpeg (without the flicker)

DEV Community: pythonΒ·Mason KΒ·about 5 hours ago
#ulrlSvUg
#devtopython#devto#dev#python#ffmpeg
Reading 0:00
15s threshold

πŸ“¦ Code: github.com/USER/video-redact (replace before publishing)

TL;DR

We'll turn per-frame face detections into padded, time-held blur regions and render them with a single FFmpeg filter graph. You get: no flicker on missed frames, audio copied untouched, one re-encode. Python 3.10+, mediapipe 0.10.x, FFmpeg 6+.

🎯 The problem

A face detector gives you one box per face per frame. Blur exactly those boxes and the blur flickers whenever the detector misses a frame, which is when someone turns their head. In a redaction pipeline, the flicker frame is the leak.

So we do three things to the raw detections:

Pad each box so the hairline and jaw are covered.

Hold each detection for N frames so a missed frame is bridged.

Merge overlapping boxes in space and time into one wider region.

Then we render with FFmpeg: crop, blur, overlay, enabled only during each region's time window.

⚠️ Note: The detection step below was not run on real faces by me (no face footage or model download in my test environment).…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.