2.6 KiB
2.6 KiB
MkvOpusEnc
Overview
MkvOpusEnc.py is a cross-platform Python script designed for batch-processing the audio tracks within MKV files. It automatically scans the current directory for MKV files and processes them sequentially. The script intelligently converts various audio codecs to the highly efficient Opus format while preserving all other tracks (video, subtitles, etc.) and metadata.
Features
- Automated Batch Processing: Automatically finds and processes all MKV files in its directory, one by one.
- Intelligent Codec Handling:
- Remuxes existing
AACandOpustracks without re-encoding to preserve quality. - Re-encodes all other audio formats (DTS, AC3, TrueHD, FLAC, etc.) to Opus.
- Remuxes existing
- Advanced Downmixing: Includes an optional
--downmixflag that converts multi-channel audio (5.1, 7.1) to stereo using a dialogue-boosting formula. - Audio Normalization: Uses
SoXto normalize audio levels for a consistent listening experience. - Audio Normalization: Uses
ffmpeg's two-passloudnormfilter (EBU R 128) to normalize audio levels for a consistent listening experience. - Detailed Logging: Creates a separate, detailed log file for each processed MKV in the
conv_logs/directory, capturing the full terminal output and conversion details for easy review. - File Organization: Automatically moves the original source files to an
original/directory and the newly processed files to acompleted/directory, keeping your workspace clean. - Cross-Platform: As a Python script using common command-line tools, it is designed to work on Windows, macOS, and Linux.
Requirements
The following command-line tools must be installed and available in your system's PATH:
ffmpegffprobemkvmergeopusencmediainfo
Usage
-
Place your
.mkvfiles in the same directory as the script. -
Execute the script from your terminal:
python MkvOpusEnc.py
Optional Arguments
-
--downmix: By default, the script preserves the original audio channel layout. Use this flag to downmix multi-channel audio to stereo.Example:
python MkvOpusEnc.py --downmix
Output
- Processed files are moved to the
completed/directory. - Original files are moved to the
original/directory. - Per-file logs are saved in the
conv_logs/directory, containing detailed information about:- Original audio track properties (codec, bitrate, channels)
- Track titles, languages, and delay information
- Conversion details for each track, including target bitrates
- Any errors or warnings encountered during processing