Skip to content

tsnearly/dialogue-guardian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

149 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

πŸ“‹ 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
 - `--full` : When set, run the full (and slower) verification path which performs per-segment audio analysis using FFmpeg astats, produces a comprehensive diagnostic report, and allows multiple fallback attempts to improve censoring. Default: disabled (fast path). Use `--full` when you want maximum assurance at the cost of slower runs.

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

# Run all tests
make test

# Run with coverage
make test-coverage

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

πŸ“ˆ Current code coverage

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!

About

A powerful and accessible Python application designed to automatically detect and censor profane language in video files. Leveraging the robust capabilities of FFmpeg, Guardian now offers a streamlined, platform-independent solution, eliminating the previous reliance on Apple's Final Cut Pro.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors