How to Blur Faces in a Video from Command Line

By  on  

Privacy is always incredibly important, especially with visual media where you may not have the permission of individuals in the video. If you're filming something in public, it's likely you'll catch someone's face who simply doesn't want or need to be identified. This recently got me to thinking: what's the easiest way to blur faces in a video via command line?

The best open source utility I found for blurring faces in a video was deface. Let's have a look at how you can use deface to blur faces in videos!

Start by downloading Python-based via pip:

python3 -m pip install deface

With deface installed, simply provide the video name and get the output file with blurred faces:

sudo deface ./sample-4k-faces-video.mp4
Input:  ./sample-4k-faces-video.mp4
Output: ./sample-4k-faces-video_anonymized.mp4
100%|█████████████████████████████

The resulting video does an impressive job of blurring out faces of persons walking by in the original recording:

View the resulting video of persons walking down the streets of New York:

The default threshold for face recognition works very well, even on moving subjects. You can experiment with thresholds with the thresh argument, and even draw the thresholds out while debugging:

I downloaded a handful of YouTube videos using my favorite YouTube downloading utility youtube-dl and I was amazed at how well deface did on a variety of visual environments. Faces were identified at a reliable level even at default threshold!

Recent Features

  • By
    CSS Animations Between Media Queries

    CSS animations are right up there with sliced bread. CSS animations are efficient because they can be hardware accelerated, they require no JavaScript overhead, and they are composed of very little CSS code. Quite often we add CSS transforms to elements via CSS during...

  • By
    39 Shirts – Leaving Mozilla

    In 2001 I had just graduated from a small town high school and headed off to a small town college. I found myself in the quaint computer lab where the substandard computers featured two browsers: Internet Explorer and Mozilla. It was this lab where I fell...

Incredible Demos

  • By
    Introducing MooTools ElementSpy

    One part of MooTools I love is the ease of implementing events within classes. Just add Events to your Implements array and you can fire events anywhere you want -- these events are extremely helpful. ScrollSpy and many other popular MooTools plugins would...

  • By
    MooTools CountDown Plugin

    There are numerous websites around the internet, RapidShare for example, that make you wait an allotted amount of time before presenting you with your reward. Using MooTools, I've created a CountDown plugin that allows you to easily implement a similar system. The MooTools JavaScript The CountDown class...

Discussion

    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!