用 ffmpeg 把视频片段转成动图 GIF

在 macOS 上用 ffmpeg 的 palettegen/paletteuse 滤镜链生成小而清晰的 GIF(ffmpeg 需自行安装)。

macOS视频FFmpegGIF低风险
先 `brew install ffmpeg`,再运行含 palettegen/paletteuse 的一行命令,配合 fps=12 和 scale 完成截取、缩放与编码。

01命令

命令
$ ffmpeg -ss 3 -t 4 -i input.mp4 -vf "fps=12,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" out.gif

02作用说明

直接 `ffmpeg -i in.mp4 out.gif` 会得到体积大、颗粒感强的 GIF;先调色板取样再套用 paletteuse,可以在更小体积下显著提升画质。-ss 3 -t 4 表示从第 3 秒截取 4 秒,fps=12,scale=480:-1 控制帧率和宽度让文件便于分享。ffmpeg 不是 macOS 预装软件,需先 `brew install ffmpeg`。

03风险

风险低风险
使用条件ffmpeg (brew install ffmpeg)
!注意: GIF 体积增长很快,片段要短、分辨率要低,或改用 MP4/WebM。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • ffmpeg — Homebrew formula
    Homebrew · community · 2026-09-17
    依据: ffmpeg is not preinstalled on macOS; install via `brew install ffmpeg`.
  • Create GIF — FFmpeg wiki
    FFmpeg · vendor-doc · 2026-09-17
    依据: Shows the palettegen/paletteuse two-pass filter chain for high-quality GIFs, with fps and scale filters.

最后验证: 2026-09-17 · 分类: 媒体