Skip to main content

A command-line tool to blur human faces in MP4 videos using face detection.

Project description

Blurface

Blurface is a command-line tool to blur human faces in MP4 videos using face detection powered by the retina-face library. It supports customizable mosaic block sizes and allows users to choose between rectangular or elliptical blur shapes, with dynamic output naming for convenience.

Features

  • Detects and blurs faces in MP4 videos using retina-face.
  • Supports rectangular or elliptical blur shapes (default: ellipse).
  • Adjustable mosaic block size for blur intensity.
  • Preserves audio in the output video.
  • Dynamic output naming (e.g., input_name + timestamp.mp4) or user-specified paths.
  • GPU acceleration with PyTorch if available.

Installation

Blurface requires Python 3.9 or higher. We recommend using a Conda environment for installation.

  1. Clone the repository:

    git clone https://github.com/Ezharjan/blurface.git
    cd blurface
    
  2. Create and activate a Conda environment:

    conda create -n blurface python=3.11
    conda activate blurface
    
  3. Install FFmpeg:

    • Windows: Download from ffmpeg.org or install via Chocolatey (choco install ffmpeg). Add ffmpeg.exe to your PATH.
    • Linux/macOS: Install via package manager (e.g., sudo apt install ffmpeg or brew install ffmpeg).
    • Verify: ffmpeg -version
  4. Install Blurface:

    pip install -e .
    

Dependencies

  • retina-face==0.0.17: Face detection library.
  • tensorflow>=2.10.0: Required by retina-face.
  • tf-keras>=2.19.0: Required by retina-face for TensorFlow 2.19.0+.
  • tqdm>=4.60.0: Progress bar for processing.
  • torch>=1.9.0,<2.5.0: GPU-accelerated mosaic effect.
  • ffmpeg-python>=0.2.0: Audio handling in videos.

Usage

Run blurface from the command line with the following arguments:

blurface <input> [--mosaic-size SIZE] [--output OUTPUT] [--blur-shape SHAPE]

Arguments

  • input: Path to the input MP4 video file (required).
  • --mosaic-size SIZE, -m: Size of mosaic blocks for blurring (default: 10).
  • --output OUTPUT, -o: Path to save the output MP4 video (default: input_name + timestamp.mp4, e.g., movie2504231815.mp4).
  • --blur-shape SHAPE, -s: Shape of the blur area, either rectangle or ellipse (default: ellipse).

Examples

  1. Blur faces with default settings (elliptical blur):

    blurface example_vids/test.mp4
    
    • Output: test2504231815.mp4 (timestamp-based, e.g., 2025-04-23 18:15) with elliptical blur.
  2. Blur faces with rectangular blur and custom mosaic size:

    blurface example_vids/test.mp4 --mosaic-size 15 --blur-shape rectangle
    
    • Output: test2504231815.mp4 with rectangular blur.
  3. Specify output path and elliptical blur:

    blurface example_vids/test.mp4 --mosaic-size 10 --blur-shape ellipse --output output/blurred.mp4
    
    • Output: output/blurred.mp4 with elliptical blur; output directory is created if it doesn't exist.

Error Handling

  • Input must be an MP4 file, or an error is raised: ERROR: Input file must be an MP4 video.
  • If the input file doesn't exist: ERROR: Input video not found: <path>.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For issues or contributions, visit the GitHub repository or contact Alexander Ezharjan at mysoft@111.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blurface-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blurface-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file blurface-0.1.0.tar.gz.

File metadata

  • Download URL: blurface-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for blurface-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7232fc1a4b17749d92f53ed34a4e1a34ca96b439662ae3e920fb0f3d55cf9297
MD5 023b4dc579346a29a390528463daebff
BLAKE2b-256 fe6bbc3f827c9c44c48ebab156d38f9c35203df3810535fdc293078607a7574c

See more details on using hashes here.

File details

Details for the file blurface-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: blurface-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for blurface-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3496ed0629d9b7d040cb2b0eacf3a45439cca7fd27f373bedb3e92703056a00
MD5 ebdb7b25d78598d30b8befc3e07f60f1
BLAKE2b-256 e46709c348bc79a79afcb861ff10b5bbbefe200c13fa4a0a1ce6f684b159f04c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page