mirror of
https://github.com/woodchen-ink/video2gif.git
synced 2025-07-18 13:42:03 +08:00
Compare commits
7 Commits
v1.0.0-302
...
main
Author | SHA1 | Date | |
---|---|---|---|
5f5e5350a7 | |||
7808d7a555 | |||
78a6ec111f | |||
d407d3f72e | |||
163f71564f | |||
861b4af2d2 | |||
0f8751a2f2 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
__pycache__/gui.cpython-311.pyc
|
__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)
|
self.duration_entry.pack(side="left", padx=5)
|
||||||
ttk.Label(duration_frame, text="(留空表示全部)").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 = ttk.Frame(self.settings_frame)
|
||||||
output_frame.pack(fill="x", padx=5, pady=5)
|
output_frame.pack(fill="x", padx=5, pady=5)
|
||||||
@ -220,16 +204,6 @@ class VideoToGifConverter:
|
|||||||
for file in files:
|
for file in files:
|
||||||
self.files_list.insert(tk.END, file)
|
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:dither=sierra2_4a"
|
|
||||||
elif quality == "medium":
|
|
||||||
return "stats_mode=diff:dither=bayer:bayer_scale=3"
|
|
||||||
else:
|
|
||||||
return "stats_mode=single:dither=bayer:bayer_scale=5"
|
|
||||||
|
|
||||||
def validate_inputs(self):
|
def validate_inputs(self):
|
||||||
"""验证输入参数"""
|
"""验证输入参数"""
|
||||||
try:
|
try:
|
||||||
@ -329,13 +303,8 @@ class VideoToGifConverter:
|
|||||||
if duration:
|
if duration:
|
||||||
palette_cmd.extend(["-t", str(float(duration))])
|
palette_cmd.extend(["-t", str(float(duration))])
|
||||||
|
|
||||||
# 获取质量设置
|
# 添加滤镜和输出
|
||||||
quality_setting = self.get_quality_settings()
|
palette_cmd.extend(["-vf", f"{filter_complex},palettegen", palette_path])
|
||||||
|
|
||||||
# 修改调色板生成命令中的滤镜
|
|
||||||
palette_cmd.extend(
|
|
||||||
["-vf", f"{filter_complex},palettegen={quality_setting}", palette_path]
|
|
||||||
)
|
|
||||||
|
|
||||||
# 打印命令用于调试
|
# 打印命令用于调试
|
||||||
print("调色板生成命令:", " ".join(palette_cmd))
|
print("调色板生成命令:", " ".join(palette_cmd))
|
||||||
@ -381,13 +350,12 @@ class VideoToGifConverter:
|
|||||||
if duration:
|
if duration:
|
||||||
gif_cmd.extend(["-t", str(float(duration))])
|
gif_cmd.extend(["-t", str(float(duration))])
|
||||||
|
|
||||||
# 修改 GIF 生成命令中的滤镜
|
|
||||||
gif_cmd.extend(
|
gif_cmd.extend(
|
||||||
[
|
[
|
||||||
"-i",
|
"-i",
|
||||||
palette_path,
|
palette_path,
|
||||||
"-lavfi",
|
"-lavfi",
|
||||||
f"{filter_complex} [x]; [x][1:v] paletteuse=dither=bayer:bayer_scale=2",
|
f"{filter_complex} [x]; [x][1:v] paletteuse",
|
||||||
output_path,
|
output_path,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user