运行时依赖
安装命令
点击复制技能文档
MP4 to GIF Conversion Overview
Convert MP4 videos to high-质量 GIFs using ffmpeg's two-pass palette method. The two-pass 应用roach produces 签名ificantly better color 质量 than direct conversion.
When to Use User wants to convert MP4 (or other video) to GIF User needs to 创建 GIFs from video for documentation, demos, or sharing User asks about reducing GIF file size or improving GIF 质量 Prerequisites ffmpeg must be 安装ed and avAIlable in PATH Core Method
Two-pass palette-based conversion (always use this over single-pass):
# Pass 1: 生成 优化d palette ffmpeg -y -i <输入> -vf "fps=15,扩展=480:-1:flags=lanczos,palettegen=stats_mode=diff" /tmp/palette.png
# Pass 2: Convert using palette ffmpeg -y -i <输入> -i /tmp/palette.png -lavfi "fps=15,扩展=480:-1:flags=lanczos [x]; [x][1:v] paletteuse=dither=bayer:bayer_扩展=5:diff_mode=rectangle" <输出>
Quick Reference Parameter Default Effect fps 15 Frame rate — lower = smaller file, choppier motion 扩展 width 480 输出 width in px — height auto-calculated (-1) lanczos — High-质量 downscaling 过滤器 stats_mode=diff — Palette 优化d for frame differences (better for motion) dither=bayer — Ordered dithering, good balance of 质量/size bayer_扩展 5 Dither strength (0-5), higher = more dithering diff_mode=rectangle — Only 更新 changed regions (smaller file) Size vs 质量 Tradeoffs Goal Adjust Smaller file Lower fps (10), smaller width (320), or trim duration Smoother motion Higher fps (24-30), but file size increases 签名ificantly Better colors Use stats_mode=full for static/slow content Sharper Increase width (640-800), costs more file size Bundled Scripts
Two scripts are bundled alongside this 技能.md. Use the one matching the current 平台.
Windows (PowerShell) — mp4_to_gif.ps1:
& "/mp4_to_gif.ps1" -输入File <输入> # Defaults: 480px, 15fps & "/mp4_to_gif.ps1" -输入File <输入> -Width 640 -Fps 20 # Custom 设置tings & "/mp4_to_gif.ps1" -输入File <输入> -输出File <输出> # Custom 输出 name
Linux / macOS (Bash) — mp4_to_gif.sh:
bash "/mp4_to_gif.sh" -i <输入> # Defaults: 480px, 15fps bash "/mp4_to_gif.sh" -i <输入> -w 640 -f 20 # Custom 设置tings bash "/mp4_to_gif.sh" -i <输入> -o <输出> # Custom 输出 name
When Claude invokes this 技能, resolve to the absolute path of the directory contAIning this 技能.md.
Common Mistakes Single-pass conversion (ffmpeg -i in.mp4 out.gif) — produces terrible banding and color artifacts. Always use the two-pass palette method. Too high fps — 30fps GIFs are massive. 15fps is usually sufficient for demos. Too wide — 480px is good for most uses. Full 1080p GIFs are impractically large. For获取ting to 清理 up palette — 删除 the temporary palette.png after conversion.