Skip to main content

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

Project description

Dialogue Guardian Logo

Dialogue Guardian: Universal Media Censor

This project provides two Python scripts to automatically detect and censor profane language in video files by processing SRT subtitle files.

  • guardian_by_ffmpeg.py (Recommended): A standalone, cross-platform tool that directly censors audio using FFmpeg.
  • guardian.py (Legacy): A tool that generates a Final Cut Pro XML (.fcpxml) file with volume keyframes to mute profane segments.

Installation

From PyPI (when published)

pip install dialogue-guardian

From Source

git clone <repository-url>
cd dialogue-guardian
pip install -e .

Development Installation

git clone <repository-url>
cd dialogue-guardian
make install-dev

Usage

Command Line Interface

After installation, you can use the guardian command:

# Basic usage
guardian movie.mp4

# With custom output path
guardian movie.mp4 --output censored_movie.mp4

# With verbose logging
guardian movie.mp4 --verbose

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

Python API

from guardian import GuardianProcessor

# Initialize the processor
processor = GuardianProcessor()

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

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

# Custom configuration
processor = GuardianProcessor(
    matching_words=['custom', 'word', 'list'],
    ffmpeg_cmd='/usr/local/bin/ffmpeg',
    ffprobe_cmd='/usr/local/bin/ffprobe'
)

Key Features

  • Direct Audio Censoring: Uses FFmpeg's audio filters to mute profane segments and create a new, censored video file.
  • Universal Compatibility: Works on any OS with FFmpeg installed (Windows, macOS, Linux).
  • No FCPX Dependency: Does not require Final Cut Pro.
  • 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.
  • Efficient: Copies the video stream without re-encoding to maintain quality, only re-encoding the audio.
  • Package Structure: Properly structured as a Python package for easy installation and distribution.

Requirements

  • Python 3.7+
  • FFmpeg: Installed and accessible in your system's PATH.
  • Python Packages: Automatically installed with the package

guardian.py (Legacy FCPXML Workflow)

This script is for users who want to import a censorship timeline into Apple's Final Cut Pro.

Features

  • FCPXML Generation: Outputs a ready-to-import XML file for Final Cut Pro with volume keyframes to mute profanity.
  • Metadata Extraction: Uses ffprobe to get video details for the FCPXML project.
  • Subtitle Parsing: Reads an external .srt file to find profane words.

Requirements

  • Python 3.7+
  • ffprobe (part of FFmpeg): The script defaults to /Users/Shared/FFmpegTools/ffprobe, but you can edit the path in the script.

Usage

  1. Prepare your files:

    • Place your video file (e.g., movie.mp4) and its subtitle file (movie.srt) in the same directory.
  2. Run the script:

    python guardian.py <path_to_your_video_file>
    

    Example:

    python guardian.py movie.mp4
    
  3. Output:

    • A Final Cut Pro XML file (movie.fcpxml) will be generated.
    • A log file (guardian.log) will be created.

Customization

To customize the list of censored words, edit the matching_words list at the top of either guardian.py or guardian_by_ffmpeg.py.


Development

Running Tests

# Run all tests
make test

# Run tests with verbose output
make test-verbose

# Run specific test file
pytest tests/test_guardian_core.py

Code Quality

# Format code
make format

# Run linting
make lint

# Run all checks
make check

Building and Publishing

# Build the package
make build

# Upload to PyPI (requires credentials)
make upload

Testing

This project includes a full suite of unit tests. For detailed instructions on how to run the tests, please see TESTING.md.


License

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


Author

Created by Tony Snearly.

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.2.0.tar.gz (221.8 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.2.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dialogue_guardian-1.2.0.tar.gz
  • Upload date:
  • Size: 221.8 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.2.0.tar.gz
Algorithm Hash digest
SHA256 77cd5158c675fd5452359699cb4da7267145757f2f13f9bf51d8a8cd00960cb5
MD5 d60f727e3f91e476947bd88804f32332
BLAKE2b-256 52228b3417e1fa9a25485ce4e1ac6d95a71f1711ff0b59a96549775fc1db15ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dialogue_guardian-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9bfca39c0820a43d40bf015ab427aaa6c43ed0f58584055f418a5e68516cf9ce
MD5 5e0d1d367e00887b65ee21ac88a16da5
BLAKE2b-256 c9fb50dbc7cc6db7fbb27329d425e2b392279565a91ed698ead7aa6ec4867712

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