FIX: maps codecs names and ffmpeg encoders correctly
This commit was merged in pull request #11.
This commit is contained in:
@@ -67,6 +67,9 @@ CODEC_INFO = [
|
||||
CODEC_TO_CONTAINER_MAP = {codec['name']: codec['recommended_container'] for codec in CODEC_INFO}
|
||||
CODEC_TO_EXTENSION_MAP = {codec['name']: codec['recommended_extension'] for codec in CODEC_INFO}
|
||||
|
||||
# Map codec name → FFmpeg encoder name
|
||||
CODEC_NAME_TO_FFMPEG = {codec['name']: codec['ffmpeg'] for codec in CODEC_INFO}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Video codec support per container (legacy, will be superseded by compatibility matrix)
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
+20
-4
@@ -6,7 +6,11 @@ import subprocess
|
||||
import sys
|
||||
from typing import List, Dict, Any
|
||||
|
||||
from .constants import FORMAT_INFO, CODEC_TO_EXTENSION_MAP
|
||||
from .constants import (
|
||||
FORMAT_INFO,
|
||||
CODEC_TO_EXTENSION_MAP,
|
||||
CODEC_NAME_TO_FFMPEG, # <-- Add this
|
||||
)
|
||||
from .ffmpeg import (
|
||||
get_audio_duration,
|
||||
get_stream_info,
|
||||
@@ -192,6 +196,18 @@ def split_audio(input_file: str, output_directory: str, tracks: List[Dict[str, A
|
||||
# ----------------------------------------------------------------------
|
||||
# 8d. Build and execute FFmpeg command
|
||||
# ----------------------------------------------------------------------
|
||||
# Map codec names to FFmpeg encoder names
|
||||
audio_enc = args.audio_codec
|
||||
if audio_enc != 'copy':
|
||||
audio_enc = CODEC_NAME_TO_FFMPEG.get(audio_enc, audio_enc) # fallback to itself if not found
|
||||
video_enc = args.video_codec
|
||||
if video_enc != 'copy':
|
||||
video_enc = CODEC_NAME_TO_FFMPEG.get(video_enc, video_enc)
|
||||
subtitle_enc = args.subtitle_codec
|
||||
if subtitle_enc != 'copy':
|
||||
subtitle_enc = CODEC_NAME_TO_FFMPEG.get(subtitle_enc, subtitle_enc)
|
||||
|
||||
# Then build command with these mapped encoders
|
||||
cmd = build_ffmpeg_command(
|
||||
input_file=input_file,
|
||||
start_seconds=start_seconds,
|
||||
@@ -199,9 +215,9 @@ def split_audio(input_file: str, output_directory: str, tracks: List[Dict[str, A
|
||||
output_path=output_path,
|
||||
stream_info=stream_info,
|
||||
format_opt=output_container,
|
||||
audio_codec=args.audio_codec,
|
||||
video_codec=args.video_codec,
|
||||
subtitle_codec=args.subtitle_codec,
|
||||
audio_codec=audio_enc,
|
||||
video_codec=video_enc,
|
||||
subtitle_codec=subtitle_enc,
|
||||
metadata=metadata,
|
||||
cover_image_path=cover_image_path,
|
||||
video_quality=getattr(args, 'video_quality', None),
|
||||
|
||||
Reference in New Issue
Block a user