Cheat Sheet速查表
跳转到主要内容

GIF 动图制作 速查表

本文根据 Devhints / Animated GIFs 翻译。代码示例及版本范围沿用原文。

GIF 动图制作

将 MP4 转换为 GIF

mkdir -p gif
mplayer -ao null -vo gif89a:outdir=gif $INPUT
mogrify -format gif *.png
gifsicle --colors=256 --delay=4 --loopcount=0 --dither -O3 gif/*.gif > ${INPUT%.*}.gif
rm -rf gif

你需要 mplayer, imagemagick 以及 gifsicle。此操作将帧转换为 .png 格式,然后将其合成动态 GIF。

指定范围

mplayer -ao null -ss 0:02:06 -endpos 0:05:00 -vo gif89a:outdir=gif videofile.mp4

参见 -ss 以及 -endpos.