A Bash script to clean media files keeping only specified video, audio, and subtitle streams based on language. No re-encoding is performed (stream copy mode).
- Filter by Language: Keep only audio/subtitle streams in specified languages.
- No Re-encoding: Uses
ffmpegin stream copy mode (-c copy) for fast processing. - Dry Run Mode: Preview changes without modifying files.
- Verbose Output: Enable detailed logging for debugging.
- Batch Processing: Process a single file or all MKV files in a directory.
- Clone or download the script:
git clone https://github.com/vr-ski/stream-cleaner.git cd stream-cleaner/src - Make the script executable:
chmod +x stream_cleaner.sh
./stream_cleaner.sh [OPTIONS]| Option | Description |
|---|---|
-i, --input-file |
Input MKV file to process (cannot be used with --root-dir). |
-r, --root-dir |
Root directory containing MKV files (cannot be used with --input-file). |
-a, --audio-langs |
Comma-separated list of audio languages to keep (e.g., "jpn,eng"). |
-s, --sub-langs |
Comma-separated list of subtitle languages to keep (e.g., "eng,deu"). |
-n, --no-video |
Exclude video streams (include all video by default). |
-d, --dry-run |
Simulate the process without modifying files (shows detailed output). |
-v, --verbose |
Enable verbose output. |
-h, --help |
Show this help message. |
Keep only Japanese audio and English subtitles in movie.mkv:
./stream_cleaner.sh --input-file movie.mkv --audio-langs jpn --sub-langs engKeep only Japanese audio and English/German subtitles in all MKV files in /path/to/files:
./stream_cleaner.sh --root-dir /path/to/files --audio-langs jpn --sub-langs eng,deuPreview what would happen without modifying files:
./stream_cleaner.sh --input-file movie.mkv --audio-langs jpn --sub-langs eng --dry-runKeep only Japanese audio and English subtitles, excluding video:
./stream_cleaner.sh --input-file movie.mkv --audio-langs jpn --sub-langs eng --no-videoThis project is licensed under the BSD-2-Clause License – see the LICENSE file for details.