fix #25 (core): wrong output filename extensions when they are autodetected #34
@@ -7,6 +7,7 @@ import sys
|
||||
from typing import List, Dict, Any
|
||||
|
||||
from .constants import (
|
||||
CONTAINER_INFO,
|
||||
CONTAINER_NAMES,
|
||||
CODEC_TO_EXTENSION_MAP,
|
||||
CODEC_NAME_TO_FFMPEG,
|
||||
@@ -117,12 +118,15 @@ def split_audio(input_file: str, output_directory: str, tracks: List[Dict[str, A
|
||||
else:
|
||||
output_audio_codec = stream_info.get('audio_codec', '')
|
||||
|
||||
# Choose extension based on audio codec if possible, otherwise fallback to container default
|
||||
if output_audio_codec in CODEC_TO_EXTENSION_MAP:
|
||||
# Choose extension based on the output container, not the audio codec.
|
||||
# When user specifies --container, the file extension must match the container.
|
||||
container_info = next((c for c in CONTAINER_INFO if c['name'] == output_container), None)
|
||||
if container_info:
|
||||
extension = container_info['extension']
|
||||
elif output_audio_codec in CODEC_TO_EXTENSION_MAP:
|
||||
extension = CODEC_TO_EXTENSION_MAP[output_audio_codec]
|
||||
else:
|
||||
container_info = next((c for c in CONTAINER_INFO if c['name'] == output_container), None)
|
||||
extension = container_info['extension'] if container_info else '.mkv'
|
||||
extension = '.mkv'
|
||||
|
||||
print(f"Output extension: {extension}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user