A powerful Python utility for managing and removing Unwanted video language tracks, allowing precise control over audio and subtitle streams in your media files.
- 🎯 Selective Track Retention: Keep only the audio and subtitle tracks you want
- 📁 Batch Processing: Handle single files or entire directories
- ⚡ Stream Copy: Preserve quality with no re-encoding
- ✅ Verification: Automatic output validation
- 🎥 Wide Format Support: Works with MKV, MP4, AVI, and MOV
-
Python 3.11 or higher
-
FFmpeg in system PATH
-
Required Python packages:
psutil==6.1.1 pydantic==2.10.4 setuptools==75.6
-
Clone the repository:
git clone https://github.com/zuidvolt/trim-streams.git cd trim-streams
-
Install dependencies:
pip install -r requirements.txt
python trim_streams.py [options] input_path
Option | Description | Default |
---|---|---|
input_path |
Video file or directory to process | Required |
--audio-langs |
Audio language codes to retain | eng,en,kor,jpn,chi,zho,cmn |
--subtitle-langs |
Subtitle language codes to keep | eng,en |
--no-copy |
Disable stream copy mode | False |
--no-verify |
Skip output verification | False |
-
Keep specific languages:
python trim_streams.py video.mkv --audio-langs eng jpn --subtitle-langs eng
-
Process entire directory:
python trim_streams.py /path/to/videos
-
Re-encode streams:
python trim_streams.py video.mkv --no-copy
- Processed files are saved in a
processed
subdirectory - Original directory structure is preserved
- Output maintains original filename
Tool | Purpose | Command |
---|---|---|
ruff | Linting & Formatting | make ruff-check |
mypy | Static Type Checking | make mypy-strict |
coverage | Test Coverage | make coverage |
radon | Code Complexity | make radon/ make radon-mi |
vulture | Dead Code Detection | make vulture |
make check
-
Create virtual environment:
python -m venv .venv source .venv/bin/activate # Unix # or .venv\Scripts\activate # Windows
-
Install dev dependencies:
pip install -e ".[dev]"
or if you using the uv packages manager
uv pip install -r pyproject.toml --all-extras
processor = VideoProcessor(input_file: Path, config: ProcessingConfig)
Method | Description |
---|---|
probe_file() |
Analyze video file metadata |
process(output_file: Path) |
Process video with current settings |
verify_output(output_file: Path) |
Validate processed file |
config = ProcessingConfig(
audio_langs=["eng", "jpn"],
subtitle_langs=["eng"],
copy_streams=True,
verify_output=True
)
This project is licensed under the Apache License, Version 2.0 with important additional terms, including specific commercial use conditions. Users are strongly advised to read the full LICENSE file carefully before using, modifying, or distributing this work. The additional terms contain crucial information about liability, data collection, indemnification, and commercial usage requirements that may significantly affect your rights and obligations.
-
Fork the repository
-
Create feature branch
git checkout -b feature/amazing-feature
-
Commit changes
git commit -m 'Add: amazing feature'
-
Push to branch
git push origin feature/amazing-feature
-
Open Pull Request
- Follow PEP 8 style guide
- Add tests for new features
- Update documentation
- Maintain type hints
- Run quality checks before submitting
Report issues via GitHub Issues, including:
- Python version
- Operating system
- Minimal reproducible example
- Error messages
- Expected vs actual behavior