fix: improve subprocess encoding handling for duration retrieval and file conversion

This commit is contained in:
joel committed 2026-11-09 16:06:58 +01:00
1 parent 56bf8aa3d1
commit 20f62e48d9
1 file changed
+15 -2
+15 -2
View File
@@ -514,7 +514,14 @@ def get_duration(file, ffprobe_path):
file,
]
try:
return float(subprocess.check_output(cmd, universal_newlines=True, stderr=subprocess.DEVNULL).strip())
return float(
subprocess.check_output(
cmd,
encoding="utf-8",
errors="replace",
stderr=subprocess.DEVNULL,
).strip()
)
except Exception:
return 0
@@ -552,7 +559,13 @@ def convert_file(entry, index, export_dir, meta, use_subdirs, ffmpeg_path, ffpro
mp3_path,
]
process = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.DEVNULL, universal_newlines=True)
process = subprocess.Popen(
cmd,
stderr=subprocess.PIPE,
stdout=subprocess.DEVNULL,
encoding="utf-8",
errors="replace",
)
while True:
line = process.stderr.readline()
if not line: