Skip to content

Instantly share code, notes, and snippets.

@bogdan
Last active June 27, 2026 07:24
Show Gist options
  • Select an option

  • Save bogdan/87a08e26321eec366429a965a5fe673d to your computer and use it in GitHub Desktop.

Select an option

Save bogdan/87a08e26321eec366429a965a5fe673d to your computer and use it in GitHub Desktop.

Third-Party Face Removal from Video

Variants for handling third-party faces that appear in recorded video segments.


1. Cut the Segment

Remove the time range entirely from the final export.

  • The segment where the face appears is deleted from the timeline.
  • Audio is also cut (or can be replaced with silence/ambient sound).
  • Best when the third-party appearance is incidental and the content is expendable.
  • Results in a jump cut — may need a transition or B-roll to smooth.

AI detection needed:

  • Face detection — identify the time range(s) where a third-party face is present so the correct segment boundaries can be determined.
  • No spatial tracking required; temporal detection (which frames contain a face) is sufficient.
  • Example tools: MediaPipe Face Detection, RetinaFace, AWS Rekognition Video.

2. Blur Entire Frame for Segment

Apply a full-frame blur overlay for the duration the face is visible.

  • The entire video frame is blurred while the person is on screen.
  • Audio is preserved.
  • Simple to implement; no tracking needed.
  • Most appropriate when the third party dominates the frame or the background is also sensitive.

AI detection needed:

  • Face detection (temporal only) — determine which frames contain a third-party face; no spatial coordinates needed beyond confirming presence.
  • The blur is applied to the whole frame, so detection just drives the on/off switch per frame.
  • Example tools: MediaPipe Face Detection, DeepFace, AWS Rekognition Video.

3. Blur Interview Background (Subject in Focus, Third Party Behind)

Blur the background layer of the interview frame when a third-party face appears in it.

  • The primary interview subject remains sharp.
  • The background region (behind the subject) is selectively blurred.

AI detection needed:

  • Person/subject segmentation — separate the foreground interview subject from the background so the blur is applied only behind them.
  • Face detection in the background region — confirm a third-party face is present before activating the background blur (avoids blurring when no one is behind the subject).
  • Example tools: MediaPipe Selfie Segmentation (foreground/background split), SAM (Segment Anything Model) for precise subject masking, RetinaFace for background face detection.

4. Blur Entire Moving Object in Background

Track and blur the full silhouette/bounding box of a person moving in the background.

  • A bounding box or segmentation mask is applied to the moving person as a whole.
  • Covers body, clothing, and face — no identity can be inferred.
  • Appropriate when the person's presence in the background is acceptable but their identity must be protected.

AI detection needed:

  • Person detection — locate the full bounding box of the background person each frame (class: "person").
  • Multi-object tracking (MOT) — maintain a consistent identity for the person across frames as they move, so the blur region follows them smoothly.
  • Instance segmentation (optional, higher quality) — produce a pixel-accurate mask of the person instead of a rectangular box to avoid blurring surrounding content.
  • Example tools: YOLOv8 + ByteTrack/BotSort for detection + tracking; Detectron2 or SAM for instance segmentation.

5. Blur Only the Face of the Moving Person

Detect and track the face of a background person and apply a blur or pixelation to it alone.

  • Only the detected face region is blurred; the rest of the person and background remain visible.
  • Least disruptive visually — the scene context is preserved.
  • Appropriate when the person's presence in the background is acceptable but their identity must be protected.

AI detection needed:

  • Face detection — locate the face bounding box within each frame, including faces that are small, partially occluded, or at an angle.
  • Face tracking across frames — link detections frame-to-frame so the blur follows the face through motion without flickering or dropping.
  • Landmark/orientation awareness (optional) — handle profile or tilted faces that standard frontal detectors may miss.
  • Example tools: RetinaFace or MediaPipe Face Detection (detection); DeepSORT or ByteTrack adapted for face ROIs (tracking); InsightFace for robust detection at varying scales and angles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment