# anime_audio_encoder.py ## Overview `anime_audio_encoder.py` is a batch-processing script for MKV files, designed for anime encoding workflows. It automates video encoding (with AV1 via SVT-AV1 and `av1an`), audio conversion (to Opus with normalization and optional downmixing), and preserves detailed per-file logs. The script also handles VFR-to-CFR conversion using HandBrakeCLI when needed. ## Features - **Video encoding**: Uses UTVideo intermediate, VapourSynth, and AV1 encoding via `av1an` and SVT-AV1. - **Audio processing**: Converts non-Opus/AAC tracks to normalized Opus, with optional downmixing for surround audio. - **VFR handling**: Detects Variable Frame Rate sources and converts to Constant Frame Rate using HandBrakeCLI. - **Logging**: Creates a log file for each processed MKV in the `conv_logs` directory. - **Cleanup**: Moves original files to `original/`, completed files to `completed/`, and deletes temporary files. ## Requirements The following tools must be installed and available in your `PATH`: - ffmpeg - ffprobe - mkvmerge - mkvpropedit - sox - opusenc - mediainfo - av1an - HandBrakeCLI ## Usage Place your `.mkv` files in the working directory. Run the script: ```sh python3 anime_audio_encoder.py ``` ### Optional Arguments - `--no-downmix` Preserve original audio channel layout (do not downmix surround audio to stereo). Example: ```sh python3 anime_audio_encoder.py --no-downmix ``` ## Output - Processed files are moved to the `completed/` directory. - Originals are moved to the `original/` directory. - Per-file logs are saved in the `conv_logs/` directory. ## Notes - The script will skip files that cannot be decoded by ffmpeg. - Temporary files are cleaned up automatically after processing. - Scene detection and AV1 encoding may take a long time depending on file size and system performance. ## License This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.