- PowerShell 55.4%
- Python 44.6%
- Changed "legacy compatibility version" to "Windows compatibility version" for the PowerShell script. - Updated section titles and descriptions for better readability. - Added details about the new normalization features in the Python script. - Clarified downmixing functionality as "Nightmode Dialogue downmix." - Removed references to `sox_ng` as a requirement. - Updated usage instructions for both Python and PowerShell scripts. |
||
|---|---|---|
| LICENSE.md | ||
| MkvOpusEnc.ps1 | ||
| MkvOpusEnc.py | ||
| README.md | ||
MkvOpusEnc
MkvOpusEnc is a batch MKV audio processing toolchain with Python as the primary implementation.
The main script is MkvOpusEnc.py. It scans the current folder for .mkv files, re-encodes non-AAC/Opus audio to Opus, preserves metadata, and organizes outputs automatically.
The PowerShell script MkvOpusEnc.ps1 is a Windows compatibility version for users who do not have Python installed. It follows the same ffmpeg-based pipeline.
Project Status
- Primary script: MkvOpusEnc.py
- Windows fallback: MkvOpusEnc.ps1
If both are available in your environment, use the Python script.
What The Scripts Do
- Process all
.mkvfiles in the current directory (except files starting withtemp-output-). - Keep
aacandopusaudio tracks as-is (remux). - Re-encode other audio codecs to Opus.
- Normalize re-encoded tracks with ffmpeg
loudnorm(two-pass linear, true-peak aware). No SoX. - Preserve language, track title, and delay for re-encoded tracks.
- Optional Nightmode Dialogue downmix to stereo for 6+ channel tracks (
pan '<', so the mix cannot clip). - Write one log file per input to
conv_logs. - Move processed outputs to
completedand originals tooriginal.
Requirements
Primary (Python)
- Python 3.8+
- ffmpeg
- ffprobe
- mkvmerge (MKVToolNix)
- opusenc (opus-tools)
- mediainfo
All tools must be available in your PATH.
Windows (PowerShell)
For MkvOpusEnc.ps1, install PowerShell 7+ plus the same external tools above.
Installation Notes
Install the media tools using your package manager, then verify they are on PATH.
Post-Install Check (PATH Validation)
Run the following commands to confirm each required tool is available:
ffmpeg -version
ffprobe -version
mkvmerge --version
opusenc --version
mediainfo --Version
Windows (winget)
winget install Gyan.FFmpeg MoritzBunkus.MKVToolNix MediaArea.MediaInfo
For Opus tools (opusenc), install from:
Linux (Debian / Ubuntu example)
sudo apt-get update
sudo apt-get install ffmpeg mkvtoolnix opus-tools mediainfo
Usage (Primary)
Run from a folder containing your .mkv files:
python MkvOpusEnc.py
With Nightmode Dialogue downmix enabled:
python MkvOpusEnc.py --downmix
Custom loudness targets:
python MkvOpusEnc.py --norm-i -18 --norm-tp -1.5
Python CLI
--downmix: Nightmode Dialogue downmix of 5.1/7.1 to stereo before Opus encoding.--norm-i LUFS: target integrated loudness (default:-18.0).--norm-tp dBTP: true-peak ceiling (default:-1.5).
Output Layout
When at least one input file is found, the script creates:
completed/for processed MKV filesoriginal/for original source filesconv_logs/for per-file logs
Windows PowerShell Usage
Use MkvOpusEnc.ps1 when Python is unavailable:
./MkvOpusEnc.ps1
./MkvOpusEnc.ps1 -Downmix
./MkvOpusEnc.ps1 -Downmix -NormI -18 -NormTp -1.5
The PowerShell version follows the same batch behavior and ffmpeg loudnorm pipeline as the Python script.