mirror of
https://github.com/woodchen-ink/video2gif.git
synced 2025-07-18 05:32:03 +08:00
Compare commits
8 Commits
v1.0.0-6d8
...
main
Author | SHA1 | Date | |
---|---|---|---|
5f5e5350a7 | |||
7808d7a555 | |||
78a6ec111f | |||
d407d3f72e | |||
163f71564f | |||
861b4af2d2 | |||
0f8751a2f2 | |||
302dbc805f |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
__pycache__/gui.cpython-311.pyc
|
||||
ffmpeg/ffmpeg.exe
|
||||
|
38
gui.py
38
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 "stats_mode=full"
|
||||
elif quality == "medium":
|
||||
return "stats_mode=diff"
|
||||
else:
|
||||
return "stats_mode=diff:dither=bayer:bayer_scale=2"
|
||||
|
||||
def validate_inputs(self):
|
||||
"""验证输入参数"""
|
||||
try:
|
||||
@ -329,13 +303,8 @@ class VideoToGifConverter:
|
||||
if duration:
|
||||
palette_cmd.extend(["-t", str(float(duration))])
|
||||
|
||||
# 获取质量设置
|
||||
quality_setting = self.get_quality_settings()
|
||||
|
||||
# 修改调色板生成命令中的滤镜
|
||||
palette_cmd.extend(
|
||||
["-vf", f"{filter_complex},palettegen={quality_setting}", palette_path]
|
||||
)
|
||||
# 添加滤镜和输出
|
||||
palette_cmd.extend(["-vf", f"{filter_complex},palettegen", palette_path])
|
||||
|
||||
# 打印命令用于调试
|
||||
print("调色板生成命令:", " ".join(palette_cmd))
|
||||
@ -381,13 +350,12 @@ class VideoToGifConverter:
|
||||
if duration:
|
||||
gif_cmd.extend(["-t", str(float(duration))])
|
||||
|
||||
# 修改 GIF 生成命令中的滤镜
|
||||
gif_cmd.extend(
|
||||
[
|
||||
"-i",
|
||||
palette_path,
|
||||
"-lavfi",
|
||||
f"{filter_complex} [x]; [x][1:v] paletteuse=dither=bayer:bayer_scale=2",
|
||||
f"{filter_complex} [x]; [x][1:v] paletteuse",
|
||||
output_path,
|
||||
]
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user