From 5f68eccdbff76dfeb2db8c4046d54fbdbf36c1b6 Mon Sep 17 00:00:00 2001 From: Maxim Vershinin Date: Mon, 31 Aug 2026 19:48:31 +0500 Subject: [PATCH] feat (core): If user_format is provided, map it to the correct container if it's a codec name --- audio_splitter/formats.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/audio_splitter/formats.py b/audio_splitter/formats.py index e549500..6260cd6 100644 --- a/audio_splitter/formats.py +++ b/audio_splitter/formats.py @@ -47,7 +47,7 @@ def determine_output_format(stream_info: Dict, user_format: Optional[str], """ Decide which container format to use. - If user_format is provided, use it. + If user_format is provided, map it to the correct container if it's a codec name. Else, try to detect the input file's container and codec, and use the recommended format. If detection fails or format is not supported, fallback to: - MKV if video/subtitles exist @@ -55,6 +55,10 @@ def determine_output_format(stream_info: Dict, user_format: Optional[str], - MP4 (M4A) otherwise """ if user_format: + # Map codec names to their correct containers + # e.g., 'opus' -> 'ogg', 'aac' -> 'mp4', etc. + if user_format in CODEC_TO_CONTAINER_MAP: + return CODEC_TO_CONTAINER_MAP[user_format] return user_format if input_file: