Skip to main content

Universal Media Censor - Automatically detect and censor profane language in video files

Project description

Dialogue Guardian

GitHub Actions Workflow Status Codecov PyPI - Version Python versions Downloads License GitHub Actions Workflow Status GitHub Actions Workflow Status

Dialogue Guardian Logo

Universal Media Censor - Automatically detect and censor profane language in video files using subtitle analysis and FFmpeg audio processing.

🚀 Quick Start

# Install from PyPI
pip install dialogue-guardian

# Censor a video file
guardian --input movie.mp4

# Output: movie_censored.mp4

✨ Features

  • 🎯 Direct Audio Censoring: Uses FFmpeg to mute profane segments in video files
  • 🌍 Universal Compatibility: Works on any OS with FFmpeg installed (Windows, macOS, Linux)
  • 🔄 Automatic SRT Extraction: If an external SRT file isn't found, it automatically extracts embedded SRT tracks from the video
  • 🛡️ Non-Destructive: Creates a new video file, leaving the original untouched
  • 📦 Package Structure: Properly structured as a Python package for easy installation and distribution
  • 🎬 FCPX Support: Legacy support available for Final Cut Pro XML generation, but does not require Final Cut Pro
  • 📹 Efficient Processing: Copies video streams without re-encoding to maintain quality
  • 🎛 Enhanced Audio Censoring: Advanced multi-strategy audio filtering system with progressive fallback mechanisms
  • 📡 Silence Verification: Automated verification that censored segments achieve target silence levels (≤ -50 dB)
  • 🎚 Fallback Strategies: Three-tier approach (Basic → Enhanced → Aggressive) ensures effective censoring
  • 🎙 Quality Preservation: Maintains video quality while achieving effective audio silence
  • 🧰 Comprehensive Diagnostics: Detailed logging and JSON diagnostic reports for troubleshooting
  • 🏷 Robust Error Handling: Graceful handling of missing files, corrupted data, and processing failures
  • 🧪 High-Quality Testing: 86% test coverage with pure function testing (no mocks) for reliable logic validation
  • 🔧 Modular Architecture: Refactored codebase with extracted pure functions for better maintainability and testability

📋 Requirements

  • Python 3.7+
  • FFmpeg (must be installed and accessible in PATH)

🛠️ Installation

From PyPI (Recommended)

pip install dialogue-guardian

From Source

git clone https://github.com/tsnearly/dialogue-guardian.git
cd dialogue-guardian
pip install -e .   or   uv sync

Development Installation

git clone https://github.com/tsnearly/dialogue-guardian.git
cd dialogue-guardian
make install-dev   or   uv sync --group dev

💻 Usage

Command Line Interface

# Basic usage
guardian --input movie.mp4

# Custom output path
guardian --input movie.mp4 --output censored_movie.mp4

# Verbose logging
guardian --input movie.mp4 --verbose

# Custom FFmpeg paths
guardian --input movie.mp4 --ffmpeg-path /usr/local/bin/ffmpeg

Python API

from guardian import GuardianProcessor

# Initialize processor
processor = GuardianProcessor()

# Process video
censored_file = processor.process_video("movie.mp4")

if censored_file:
    print(f"Censored video created: {censored_file}")

🧪 Testing

The project features comprehensive testing with 86% code coverage and a focus on testing real logic rather than mocked interfaces.

# Run all tests
make test

# Run with coverage
make test-coverage

# Run specific test
pytest tests/test_guardian_core.py -v

# Run pure function tests (no mocks)
pytest tests/test_guardian_pure_functions.py -v

📈 Test Architecture

  • 115 total tests across 7 test files
  • 34 pure function tests that test actual logic without mocks
  • Real data testing for parsing, filtering, and processing logic
  • Edge case coverage including malformed data, division by zero, and encoding issues
  • Integration tests with sample media files for end-to-end validation

📊 Current Code Coverage: 86%

CoverageGraph

🏗️ Development

Setup Development Environment

# Clone and setup
git clone https://github.com/tsnearly/dialogue-guardian.git
cd dialogue-guardian
make install-dev

# Run quality checks
make lint
make format
make check

Building and Publishing

# Build package
make build

# Upload to PyPI
make upload

Releases

GitHub Release Date GitHub Downloads (specific asset, latest release)

📚 Documentation

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the Open Software License version 3.0 - see the LICENSE file for details.

👨‍💻 Author

Tony Snearly

🙏 Acknowledgments

  • FFmpeg team for the powerful multimedia framework
  • Python community for excellent tooling and libraries

⭐ Star this repository if you find it helpful!

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

dialogue_guardian-1.3.0.tar.gz (442.1 kB view details)

Uploaded Source

Built Distribution

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

dialogue_guardian-1.3.0-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file dialogue_guardian-1.3.0.tar.gz.

File metadata

  • Download URL: dialogue_guardian-1.3.0.tar.gz
  • Upload date:
  • Size: 442.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for dialogue_guardian-1.3.0.tar.gz
Algorithm Hash digest
SHA256 f05f7c5fb87e0877c72ab95d1efc0641856392380967c531d69b6c4fe170792f
MD5 43766700cc9d07427800fd0f7ae9777b
BLAKE2b-256 fc5b6f6a545b0a6837ba51854c8dcaef3dff9a2ad0cf13abb1517eed244cdfb1

See more details on using hashes here.

File details

Details for the file dialogue_guardian-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dialogue_guardian-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 929d959892070a8eac8d41275128d0ffa340a121fc2c96ffd09eba8bffd8bd80
MD5 23e326d89421e77a1462c5fb541f9980
BLAKE2b-256 ca11a9f3be7ff548c983d09ca7a3e651dcec552cf2bf802c03a0fd7cf08edcb4

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