← 返回
未分类 中文

Mp4 To Gif

Use when the user wants to convert MP4 video files to GIF format, or asks about video-to-GIF conversion with quality/size control
用于用户需要将MP4视频文件转换为GIF格式,或询问带有质量/大小控制的视频转GIF功能
zzlupus
未分类 clawhub v1.0.0 1 版本 99595.1 Key: 无需
★ 0
Stars
📥 246
下载
💾 0
安装
1
版本
#latest

概述

MP4 to GIF Conversion

Overview

Convert MP4 videos to high-quality GIFs using ffmpeg's two-pass palette method. The two-pass approach produces significantly better color quality than direct conversion.

When to Use

  • User wants to convert MP4 (or other video) to GIF
  • User needs to create GIFs from video for documentation, demos, or sharing
  • User asks about reducing GIF file size or improving GIF quality

Prerequisites

  • ffmpeg must be installed and available in PATH

Core Method

Two-pass palette-based conversion (always use this over single-pass):

# Pass 1: Generate optimized palette
ffmpeg -y -i <input> -vf "fps=15,scale=480:-1:flags=lanczos,palettegen=stats_mode=diff" /tmp/palette.png

# Pass 2: Convert using palette
ffmpeg -y -i <input> -i /tmp/palette.png -lavfi "fps=15,scale=480:-1:flags=lanczos [x]; [x][1:v] paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" <output>

Quick Reference

ParameterDefaultEffect
----------------------------
fps15Frame rate — lower = smaller file, choppier motion
scale width480Output width in px — height auto-calculated (-1)
lanczosHigh-quality downscaling filter
stats_mode=diffPalette optimized for frame differences (better for motion)
dither=bayerOrdered dithering, good balance of quality/size
bayer_scale5Dither strength (0-5), higher = more dithering
diff_mode=rectangleOnly update changed regions (smaller file)

Size vs Quality Tradeoffs

GoalAdjust
--------------
Smaller fileLower fps (10), smaller width (320), or trim duration
Smoother motionHigher fps (24-30), but file size increases significantly
Better colorsUse stats_mode=full for static/slow content
SharperIncrease width (640-800), costs more file size

Bundled Scripts

Two scripts are bundled alongside this SKILL.md. Use the one matching the current platform.

Windows (PowerShell)mp4_to_gif.ps1:

& "<this-skill-dir>/mp4_to_gif.ps1" -InputFile <input>                    # Defaults: 480px, 15fps
& "<this-skill-dir>/mp4_to_gif.ps1" -InputFile <input> -Width 640 -Fps 20 # Custom settings
& "<this-skill-dir>/mp4_to_gif.ps1" -InputFile <input> -OutputFile <output> # Custom output name

Linux / macOS (Bash)mp4_to_gif.sh:

bash "<this-skill-dir>/mp4_to_gif.sh" -i <input>                    # Defaults: 480px, 15fps
bash "<this-skill-dir>/mp4_to_gif.sh" -i <input> -w 640 -f 20      # Custom settings
bash "<this-skill-dir>/mp4_to_gif.sh" -i <input> -o <output>        # Custom output name

When Claude invokes this skill, resolve to the absolute path of the directory containing this SKILL.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.
  • Forgetting to clean up palette — Delete the temporary palette.png after conversion.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-21 15:11 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 673 📥 325,054
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,374 📥 319,869
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,223 📥 267,442