fix: audio list
This commit is contained in:
1 parent
2d957a465a
commit
456f3f0051
1 file changed
+5
-5
+5
-5
@@ -220,7 +220,7 @@ def _normalize_audio_language(raw: str) -> str:
|
||||
def select_audio_stream(path: str, cfg_hint: int | str | None = None) -> int | None:
|
||||
"""
|
||||
Probe audio streams and let user pick one.
|
||||
Returns stream index (int) or None (no audio).
|
||||
Returns 0-based audio stream index for ffmpeg -map 0:a:N, or None (no audio).
|
||||
cfg_hint: int = use that index directly, "skip" = None, None = prompt.
|
||||
"""
|
||||
streams = probe_audio_streams(path)
|
||||
@@ -233,7 +233,7 @@ def select_audio_stream(path: str, cfg_hint: int | str | None = None) -> int | N
|
||||
s = streams[0]
|
||||
label = _format_stream_label(s)
|
||||
print(f"[audio] {os.path.basename(path)}: only 1 stream → {label}")
|
||||
return s["index"]
|
||||
return 0 # -map 0:a:0
|
||||
|
||||
# Multiple streams — show menu
|
||||
print(f"\n{'=' * 60}")
|
||||
@@ -242,20 +242,20 @@ def select_audio_stream(path: str, cfg_hint: int | str | None = None) -> int | N
|
||||
for i, s in enumerate(streams):
|
||||
label = _format_stream_label(s)
|
||||
marker = " *" if s.get("is_default") else ""
|
||||
print(f" [{i}] stream {s['index']}: {label}{marker}")
|
||||
print(f" [{i}] {label}{marker}")
|
||||
print(f" [s] skip audio extraction")
|
||||
print(f"{'=' * 60}")
|
||||
|
||||
while True:
|
||||
choice = input("Select audio stream [0]: ").strip().lower()
|
||||
if choice == "" or choice == "0":
|
||||
return streams[0]["index"]
|
||||
return 0
|
||||
if choice == "s":
|
||||
return None
|
||||
try:
|
||||
idx = int(choice)
|
||||
if 0 <= idx < len(streams):
|
||||
return streams[idx]["index"]
|
||||
return idx
|
||||
except ValueError:
|
||||
pass
|
||||
print(f" Invalid choice, enter 0-{len(streams)-1} or 's'")
|
||||
|
||||
Reference in new issue
Block a user