fix: audio list
This commit is contained in:
1 parent
00790fb18c
commit
b76b7394cf
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:
|
def select_audio_stream(path: str, cfg_hint: int | str | None = None) -> int | None:
|
||||||
"""
|
"""
|
||||||
Probe audio streams and let user pick one.
|
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.
|
cfg_hint: int = use that index directly, "skip" = None, None = prompt.
|
||||||
"""
|
"""
|
||||||
streams = probe_audio_streams(path)
|
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]
|
s = streams[0]
|
||||||
label = _format_stream_label(s)
|
label = _format_stream_label(s)
|
||||||
print(f"[audio] {os.path.basename(path)}: only 1 stream → {label}")
|
print(f"[audio] {os.path.basename(path)}: only 1 stream → {label}")
|
||||||
return s["index"]
|
return 0 # -map 0:a:0
|
||||||
|
|
||||||
# Multiple streams — show menu
|
# Multiple streams — show menu
|
||||||
print(f"\n{'=' * 60}")
|
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):
|
for i, s in enumerate(streams):
|
||||||
label = _format_stream_label(s)
|
label = _format_stream_label(s)
|
||||||
marker = " *" if s.get("is_default") else ""
|
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" [s] skip audio extraction")
|
||||||
print(f"{'=' * 60}")
|
print(f"{'=' * 60}")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
choice = input("Select audio stream [0]: ").strip().lower()
|
choice = input("Select audio stream [0]: ").strip().lower()
|
||||||
if choice == "" or choice == "0":
|
if choice == "" or choice == "0":
|
||||||
return streams[0]["index"]
|
return 0
|
||||||
if choice == "s":
|
if choice == "s":
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
idx = int(choice)
|
idx = int(choice)
|
||||||
if 0 <= idx < len(streams):
|
if 0 <= idx < len(streams):
|
||||||
return streams[idx]["index"]
|
return idx
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
print(f" Invalid choice, enter 0-{len(streams)-1} or 's'")
|
print(f" Invalid choice, enter 0-{len(streams)-1} or 's'")
|
||||||
|
|||||||
Reference in new issue
Block a user