fix(gui): 简化GIF生成错误处理逻辑,直接解码错误输出

This commit is contained in:
wood chen 2025-05-24 20:19:27 +08:00
parent 7808d7a555
commit 5f5e5350a7

8
gui.py
View File

@ -315,7 +315,6 @@ class VideoToGifConverter:
startupinfo = subprocess.STARTUPINFO() startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE startupinfo.wShowWindow = subprocess.SW_HIDE
# 运行调色板生成命令 # 运行调色板生成命令
process = subprocess.Popen( process = subprocess.Popen(
palette_cmd, palette_cmd,
@ -379,12 +378,7 @@ class VideoToGifConverter:
_, stderr = process.communicate() _, stderr = process.communicate()
if process.returncode != 0: if process.returncode != 0:
error_output = "" raise RuntimeError(f"GIF生成失败: {stderr.decode()}")
try:
error_output = stderr.decode("utf-8", errors="replace")
except Exception:
error_output = str(stderr) # Fallback to raw string representation
raise RuntimeError(f"GIF生成失败: {error_output}")
# 删除临时调色板文件 # 删除临时调色板文件
if os.path.exists(palette_path): if os.path.exists(palette_path):