mirror of
https://github.com/woodchen-ink/video2gif.git
synced 2025-07-18 13:42:03 +08:00
Compare commits
3 Commits
v1.0.0-d40
...
main
Author | SHA1 | Date | |
---|---|---|---|
5f5e5350a7 | |||
7808d7a555 | |||
78a6ec111f |
44
gui.py
44
gui.py
@ -140,22 +140,6 @@ class VideoToGifConverter:
|
||||
self.duration_entry.pack(side="left", padx=5)
|
||||
ttk.Label(duration_frame, text="(留空表示全部)").pack(side="left", padx=5)
|
||||
|
||||
# 质量设置
|
||||
quality_frame = ttk.Frame(self.settings_frame)
|
||||
quality_frame.pack(fill="x", padx=5, pady=5)
|
||||
|
||||
ttk.Label(quality_frame, text="质量设置:").pack(side="left", padx=5)
|
||||
self.quality_var = tk.StringVar(value="medium")
|
||||
ttk.Radiobutton(
|
||||
quality_frame, text="高质量", variable=self.quality_var, value="high"
|
||||
).pack(side="left", padx=5)
|
||||
ttk.Radiobutton(
|
||||
quality_frame, text="中等", variable=self.quality_var, value="medium"
|
||||
).pack(side="left", padx=5)
|
||||
ttk.Radiobutton(
|
||||
quality_frame, text="低质量", variable=self.quality_var, value="low"
|
||||
).pack(side="left", padx=5)
|
||||
|
||||
# 输出设置
|
||||
output_frame = ttk.Frame(self.settings_frame)
|
||||
output_frame.pack(fill="x", padx=5, pady=5)
|
||||
@ -220,16 +204,6 @@ class VideoToGifConverter:
|
||||
for file in files:
|
||||
self.files_list.insert(tk.END, file)
|
||||
|
||||
def get_quality_settings(self):
|
||||
"""根据质量设置返回 FFmpeg 参数"""
|
||||
quality = self.quality_var.get()
|
||||
if quality == "high":
|
||||
return ["-quality", "100"]
|
||||
elif quality == "medium":
|
||||
return ["-quality", "75"]
|
||||
else:
|
||||
return ["-quality", "50"]
|
||||
|
||||
def validate_inputs(self):
|
||||
"""验证输入参数"""
|
||||
try:
|
||||
@ -356,12 +330,7 @@ class VideoToGifConverter:
|
||||
_, stderr = process.communicate()
|
||||
|
||||
if process.returncode != 0:
|
||||
error_output = ""
|
||||
try:
|
||||
error_output = stderr.decode("utf-8", errors="replace")
|
||||
except Exception:
|
||||
error_output = str(stderr) # Fallback to raw string representation
|
||||
raise RuntimeError(f"调色板生成失败: {error_output}")
|
||||
raise RuntimeError(f"调色板生成失败: {stderr.decode()}")
|
||||
|
||||
# 更新状态显示
|
||||
self.status_label.config(
|
||||
@ -381,10 +350,6 @@ class VideoToGifConverter:
|
||||
if duration:
|
||||
gif_cmd.extend(["-t", str(float(duration))])
|
||||
|
||||
# 获取并添加质量设置
|
||||
quality_settings = self.get_quality_settings()
|
||||
gif_cmd.extend(quality_settings)
|
||||
|
||||
gif_cmd.extend(
|
||||
[
|
||||
"-i",
|
||||
@ -413,12 +378,7 @@ class VideoToGifConverter:
|
||||
_, stderr = process.communicate()
|
||||
|
||||
if process.returncode != 0:
|
||||
error_output = ""
|
||||
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}")
|
||||
raise RuntimeError(f"GIF生成失败: {stderr.decode()}")
|
||||
|
||||
# 删除临时调色板文件
|
||||
if os.path.exists(palette_path):
|
||||
|
Loading…
x
Reference in New Issue
Block a user