From f2e442218a1870128cb466c11c5908c8ec94e817 Mon Sep 17 00:00:00 2001 From: Bram Date: Wed, 11 Feb 2026 23:43:38 +0100 Subject: [PATCH] freaking languages --- Dockers/self-hosted-iptv/iptv/streamer.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Dockers/self-hosted-iptv/iptv/streamer.py b/Dockers/self-hosted-iptv/iptv/streamer.py index 9f4709f..6a4c27d 100644 --- a/Dockers/self-hosted-iptv/iptv/streamer.py +++ b/Dockers/self-hosted-iptv/iptv/streamer.py @@ -77,8 +77,6 @@ def get_preferred_audio_stream_index(path: Path) -> int | None: streams = data.get("streams") or [] audio_streams = [] for s in streams: - if s.get("codec_type") != "audio": - continue idx = s.get("index") if idx is None: continue @@ -260,11 +258,20 @@ def stream_live_channel(paths: list[Path], wfile, durations: list[float]) -> Non "-stream_loop", "-1", "-f", "concat", "-safe", "0", "-i", list_path, ] + # Prefer Dutch > Flemish > English > first audio (? = optional; first match wins in output order) + audio_map = [ + "-map", "0:v:0", + "-map", "0:a:m:language:nld?", + "-map", "0:a:m:language:dut?", + "-map", "0:a:m:language:nl?", + "-map", "0:a:m:language:vls?", + "-map", "0:a:m:language:eng?", + "-map", "0:a:0?", + ] if NORMALIZE_LIVE_STREAM: w, h = _parse_resolution(NORMALIZE_TARGET_RES) - # Scale to fit target res, pad to exact size. Re-encode for uniform output. vf = f"scale={w}:{h}:force_original_aspect_ratio=decrease,pad={w}:{h}:(ow-iw)/2:(oh-ih)/2" - output_args = [ + output_args = audio_map + [ "-vf", vf, "-c:v", "libx264", "-preset", "ultrafast", "-tune", "zerolatency", "-c:a", "aac", "-ac", "2", "-b:a", "128k", @@ -275,7 +282,7 @@ def stream_live_channel(paths: list[Path], wfile, durations: list[float]) -> Non "-", ] else: - output_args = [ + output_args = audio_map + [ "-c", "copy", "-avoid_negative_ts", "make_zero", "-muxdelay", "0", "-muxpreload", "0",