From 0edbd7c0c7240a995375cb6709aca6fa39c3ed0d Mon Sep 17 00:00:00 2001 From: pat-e Date: Tue, 5 Aug 2025 19:06:09 +0200 Subject: [PATCH] Updated readme and added additional optional parameters --- README.md | 7 +++++-- anime_audio_helper.py | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8af6d1b..71edb4e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Anime Audio Helper +# SVT-AV1-Essential-helper A batch-processing tool for MKV files, designed for high-quality AV1 video encoding and efficient audio handling. This script is tailored for anime and similar content, with a focus on automation, quality, and flexibility. @@ -27,11 +27,14 @@ A batch-processing tool for MKV files, designed for high-quality AV1 video encod ## Usage ```sh -python anime_audio_helper.py [--no-downmix] [--autocrop] +python anime_audio_helper.py [--no-downmix] [--autocrop] [--speed ] [--quality ] [--grain ] ``` - `--no-downmix` : Preserve original audio channel layout (do not force stereo) - `--autocrop` : Automatically detect and crop black bars from video +- `--speed` : Set the encoding speed. Possible values: `slower`, `slow`, `medium`, `fast`, `faster`. +- `--quality` : Set the encoding quality. Possible values: `lowest`, `low`, `medium`, `high`, `higher`. +- `--grain` : Set the film-grain value (number). Adjusts the film grain synthesis level. Place your `.mkv` files in the script directory. Processed files will be moved to `completed/`, and originals to `original/`. Logs are saved in `conv_logs/`. diff --git a/anime_audio_helper.py b/anime_audio_helper.py index d4f6eff..cc74499 100755 --- a/anime_audio_helper.py +++ b/anime_audio_helper.py @@ -465,8 +465,16 @@ def detect_autocrop_filter(input_file, significant_crop_threshold=5.0, min_crop= return None return _analyze_video_cropdetect(input_file, duration, width, height, max(1, os.cpu_count() // 2), significant_crop_threshold, min_crop, debug) -def main(no_downmix=False, autocrop=False): +def main(no_downmix=False, autocrop=False, speed=None, quality=None, grain=None): check_tools() + # Update SVT_AV1_PARAMS with any provided arguments + if speed is not None: + SVT_AV1_PARAMS['speed'] = speed + if quality is not None: + SVT_AV1_PARAMS['quality'] = quality + if grain is not None: + SVT_AV1_PARAMS['film-grain'] = grain + current_dir = Path(".") files_to_process = sorted( f for f in current_dir.glob("*.mkv") @@ -544,7 +552,7 @@ def main(no_downmix=False, autocrop=False): print(f" - Detected VFR based on MediaInfo FrameRate_Mode: {frame_rate_mode}") original_fps_str = video_track_info.get("FrameRate_Original_String") if original_fps_str: - match = re.search(r'\((\d+/\d+)\)', original_fps_str) + match = re.search(r'\\((\\d+)/(\\d+)\\)', original_fps_str) if match: target_cfr_fps_for_handbrake = match.group(1) else: @@ -752,5 +760,8 @@ if __name__ == "__main__": parser = argparse.ArgumentParser(description="Batch-process MKV files with resumable video encoding, audio downmixing, per-file logging, and optional autocrop.") parser.add_argument("--no-downmix", action="store_true", help="Preserve original audio channel layout.") parser.add_argument("--autocrop", action="store_true", help="Automatically detect and crop black bars from video using cropdetect.") + parser.add_argument("--speed", type=str, help="Set the encoding speed. Possible values: slower, slow, medium, fast, faster.") + parser.add_argument("--quality", type=str, help="Set the encoding quality. Possible values: lowest, low, medium, high, higher.") + parser.add_argument("--grain", type=int, help="Set the film-grain value (number). Adjusts the film grain synthesis level.") args = parser.parse_args() - main(no_downmix=args.no_downmix, autocrop=args.autocrop) + main(no_downmix=args.no_downmix, autocrop=args.autocrop, speed=args.speed, quality=args.quality, grain=args.grain)