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 typing import List, Dict, Any
|
||||||
|
|
||||||
from .constants import (
|
from .constants import (
|
||||||
|
CONTAINER_INFO,
|
||||||
CONTAINER_NAMES,
|
CONTAINER_NAMES,
|
||||||
CODEC_TO_EXTENSION_MAP,
|
CODEC_TO_EXTENSION_MAP,
|
||||||
CODEC_NAME_TO_FFMPEG,
|
CODEC_NAME_TO_FFMPEG,
|
||||||
@@ -117,12 +118,15 @@ def split_audio(input_file: str, output_directory: str, tracks: List[Dict[str, A
|
|||||||
else:
|
else:
|
||||||
output_audio_codec = stream_info.get('audio_codec', '')
|
output_audio_codec = stream_info.get('audio_codec', '')
|
||||||
|
|
||||||
# Choose extension based on audio codec if possible, otherwise fallback to container default
|
# Choose extension based on the output container, not the audio codec.
|
||||||
if output_audio_codec in CODEC_TO_EXTENSION_MAP:
|
# 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]
|
extension = CODEC_TO_EXTENSION_MAP[output_audio_codec]
|
||||||
else:
|
else:
|
||||||
container_info = next((c for c in CONTAINER_INFO if c['name'] == output_container), None)
|
extension = '.mkv'
|
||||||
extension = container_info['extension'] if container_info else '.mkv'
|
|
||||||
|
|
||||||
print(f"Output extension: {extension}")
|
print(f"Output extension: {extension}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user