video-to-gif
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: Video to GIF
Skill:视频转GIF
Convert a video file into multiple GIF variants with different parameters, so the user can visually compare and pick the best one.
Prerequisite: FFmpeg must be installed. gifsicle is optional (enables lossy compression variants).
将视频文件转换为具有不同参数的多种GIF变体,方便用户直观对比并选择最佳版本。
前置要求:必须安装FFmpeg。gifsicle为可选组件(启用有损压缩变体)。
When to Use
使用场景
The user wants to create a GIF from a video clip but isn't sure about the right parameters. GIF quality involves tradeoffs between:
- File size — smaller is better for sharing/embedding
- Color accuracy — fewer colors = smaller but may cause banding
- Smoothness — higher FPS = smoother but larger
- Resolution — wider = sharper detail but larger
Rather than guessing, this skill generates multiple variants and lets the user decide.
用户想要从视频片段创建GIF,但不确定合适的参数。GIF的画质需要在以下方面进行权衡:
- 文件大小 — 越小越利于分享/嵌入
- 色彩准确度 — 颜色数量越少=文件越小,但可能出现色带
- 流畅度 — FPS越高=越流畅,但文件越大
- 分辨率 — 宽度越大=细节越清晰,但文件越大
无需猜测参数,该Skill会生成多种变体,让用户自行决定。
Default Workflow
默认工作流程
When the user provides a video file:
bash
python /path/to/skills/video-to-gif/scripts/video_to_gif.py <input.mp4>This generates GIFs in directory with the full preset (18 variants):
<input>_gifs/- 3 FPS options: 10, 15, 20
- 3 widths: 480px, 640px, 800px
- 2 color counts: 128, 256
Output includes a sorted comparison table showing file size, FPS, width, and colors for each variant.
当用户提供视频文件时:
bash
python /path/to/skills/video-to-gif/scripts/video_to_gif.py <input.mp4>此命令会在目录下生成采用full预设的GIF(共18种变体):
<input>_gifs/- 3种FPS选项:10、15、20
- 3种宽度:480px、640px、800px
- 2种颜色数量:128、256
输出内容包含一个排序后的对比表格,展示每个变体的文件大小、FPS、宽度和颜色数量。
Presets
预设配置
| Preset | Variants | Best For |
|---|---|---|
| ~18 | General use — broad exploration of the parameter space |
| ~4 | Quick comparison — just a few key tradeoff points |
| ~12 | Smallest files — includes gifsicle lossy compression levels |
| ~12 | Best visuals — higher res, includes bayer dithering |
bash
undefined| 预设 | 变体数量 | 适用场景 |
|---|---|---|
| ~18 | 通用场景 — 全面探索参数空间 |
| ~4 | 快速对比 — 仅包含几个关键权衡点 |
| ~12 | 最小文件体积 — 包含gifsicle有损压缩级别 |
| ~12 | 最佳视觉效果 — 更高分辨率,包含拜耳抖动 |
bash
undefinedQuick comparison with fewer variants
使用更少变体进行快速对比
python .../video_to_gif.py input.mp4 --presets minimal
python .../video_to_gif.py input.mp4 --presets minimal
Include lossy compression (requires gifsicle)
启用有损压缩(需要gifsicle)
python .../video_to_gif.py input.mp4 --presets lossy
python .../video_to_gif.py input.mp4 --presets lossy
Higher quality focus
侧重更高画质
python .../video_to_gif.py input.mp4 --presets quality
---python .../video_to_gif.py input.mp4 --presets quality
---Common Options
常用选项
| Flag | Default | Description |
|---|---|---|
| | Output directory for all GIF variants |
| none | Start time in seconds (trim source) |
| none | End time in seconds (trim source) |
| | Preset config: full, minimal, lossy, quality |
| preset | Override FPS values (e.g., |
| preset | Override width values (e.g., |
| preset | Override color counts (e.g., |
| preset | Gifsicle lossy levels (e.g., |
| 标识 | 默认值 | 说明 |
|---|---|---|
| | 所有GIF变体的输出目录 |
| 无 | 起始时间(秒,用于裁剪源视频) |
| 无 | 结束时间(秒,用于裁剪源视频) |
| | 预设配置:full、minimal、lossy、quality |
| 预设值 | 覆盖FPS值(例如: |
| 预设值 | 覆盖宽度值(例如: |
| 预设值 | 覆盖颜色数量(例如: |
| 预设值 | Gifsicle有损压缩级别(例如: |
Examples
示例
bash
undefinedbash
undefinedConvert first 10 seconds of a video
转换视频的前10秒
python .../video_to_gif.py demo.mp4 --end 10
python .../video_to_gif.py demo.mp4 --end 10
Extract a specific segment
提取特定片段
python .../video_to_gif.py demo.mp4 --start 5 --end 15
python .../video_to_gif.py demo.mp4 --start 5 --end 15
Custom parameter sweep
自定义参数扫描
python .../video_to_gif.py demo.mp4 --fps 12 15 --width 480 800 --colors 256
python .../video_to_gif.py demo.mp4 --fps 12 15 --width 480 800 --colors 256
Lossy compression comparison (needs gifsicle)
有损压缩对比(需要gifsicle)
python .../video_to_gif.py demo.mp4 --lossy 0 30 60 100
---python .../video_to_gif.py demo.mp4 --lossy 0 30 60 100
---How to Choose
选择技巧
After running, open the output directory and compare:
- Start with the smallest files — check if quality is acceptable
- Look for color banding — if visible, try 256 colors or bayer dithering (quality preset)
- Check smoothness — if too choppy, go up to 15 or 20 FPS
- Check clarity — if text is unreadable, go up to 640 or 800px width
The sweet spot for most screen recordings is usually around 640px, 15fps, 256 colors.
运行完成后,打开输出目录进行对比:
- 先看最小的文件 — 检查画质是否可接受
- 查看是否有色带 — 如果存在,尝试256色或拜耳抖动(quality预设)
- 检查流畅度 — 如果过于卡顿,将FPS提升至15或20
- 检查清晰度 — 如果文字无法辨认,将宽度提升至640或800px
对于大多数屏幕录制内容,最佳平衡点通常是640px、15fps、256色。
Important Notes
重要说明
- Widths larger than the source video resolution are automatically skipped.
- The script uses FFmpeg's two-pass palette generation for optimal GIF quality (much better than single-pass).
- Lossy compression via gifsicle can reduce file size by 30-70% with minimal visual impact at level 30-60.
- For very long clips, consider trimming with /
--startfirst — GIFs over 10 seconds can get very large.--end
- 大于源视频分辨率的宽度会自动跳过。
- 脚本使用FFmpeg的两次调色板生成技术,以获得最佳GIF画质(远优于单次生成)。
- 通过gifsicle进行的有损压缩在30-60级别时,可减少30-70%的文件大小,且视觉影响极小。
- 对于超长片段,建议先使用/
--start进行裁剪 — 超过10秒的GIF文件可能会非常大。--end