From f0ccd197e50f21a97bf37348a660fb67f119af98 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Fri, 17 Apr 2026 13:17:16 -0700 Subject: [PATCH] Fix lossy copy error logging hiding actual ffmpeg error The ffmpeg failure log was truncated to 200 chars which only showed the version banner, hiding the actual error message. Now strips the banner preamble and shows up to 500 chars of the real error with exit code. Also cleans up 0KB output files left behind when ffmpeg fails. --- web_server.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/web_server.py b/web_server.py index 5af4cb17..582ed46e 100644 --- a/web_server.py +++ b/web_server.py @@ -18309,9 +18309,28 @@ def _create_lossy_copy(final_path): except Exception as del_err: print(f"[Blasphemy Mode] Error during original deletion, keeping original: {del_err}") else: - print(f"[Lossy Copy] ffmpeg failed: {result.stderr[:200]}") + # ffmpeg always prints its version banner to stderr (~300 chars). + # Strip it so the actual error is visible, and show more than 200 chars. + stderr = result.stderr or '' + # Remove the version/config preamble (ends after the first empty line) + stderr_lines = stderr.split('\n') + error_lines = [] + past_banner = False + for line in stderr_lines: + if past_banner: + error_lines.append(line) + elif line.strip() == '': + past_banner = True + error_msg = '\n'.join(error_lines).strip() if error_lines else stderr[-500:] + print(f"[Lossy Copy] ffmpeg failed (exit code {result.returncode}): {error_msg[:500]}") + # Clean up empty/broken output file + if os.path.isfile(out_path) and os.path.getsize(out_path) == 0: + os.remove(out_path) + print(f"[Lossy Copy] Removed empty output file: {os.path.basename(out_path)}") except subprocess.TimeoutExpired: print(f"[Lossy Copy] Conversion timed out for: {os.path.basename(final_path)}") + if os.path.isfile(out_path) and os.path.getsize(out_path) == 0: + os.remove(out_path) except Exception as e: print(f"[Lossy Copy] Conversion error: {e}") return None