Mac中如何制作Demo的gif图并上传github
第一步:打开终端,依次输入命令
brew install ffmpeg
brew cask install x-quartz #dependency for gifsicle, only required for mountain-lion and above
open /usr/local/Cellar/x-quartz/2.7.4/XQuartz.pkg # runs the XQuartz installer
brew install gifsicle
如果期间x-quartz安装失败,可以到下面链接下载:
安装成功后,打开QuickTime

新建屏幕录制

录制好后保存到本地,比如我保存到download文件夹,命名为video1

打开终端,输入
ffmpeg -i /Users/huangxingguo/Downloads/video1.mov -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > /Users/huangxingguo/Downloads/out.gif
输入的格式是:
ffmpeg -i 视频位置 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > 输出gif位置
当然,里面参数也可以改
-r 10tells ffmpeg to reduce the frame rate from 25 fps to 10
-s 600x400tells ffmpeg the max-width and max-height
--delay=3tells gifsicle to delay 30ms between each gif

我们看下成功吧:

还行吧
本文参考: