Mac生成gif

参考文章:https://www.jianshu.com/p/a86efa5147d5
写在前面,在参照文章安装后,提示缺少gifsicle,通过brew install gifsicle安装后,又说缺少lossy,再执行brew install giflossy,报错说与gifsicle冲突,通过brew unlink gifsicle再执行brew install giflossy总算成功。

gifify test.mp4 -o test.gif

总结起来就是按照参照文章安装后,再执行brew install giflossy就可以了。下面重复一下参考文章的步骤:
(参考文章:https://www.jianshu.com/p/a86efa5147d5)

安装

在进行转换命令之前呢我们得先安装几个小东东。

homebrew

如果你已经装好了,这一步就当没看见。否则把下面两行脚本粘贴到你的终端,并执行。首先:

xcode-select --install

然后

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

不出意外的话,homebrew就装好了。

gifify

接下来就要安装我们真正的主角了。
首先,安装Node.js环境(如果以前已经装好了,这跳过这步):

brew install node

然后,安装FFmpeg

brew install ffmpeg --with-libass --with-fontconfig

再安装convert

brew install imagemagick --with-fontconfig

然后去pornel/giflossy下载最新的zip包,解压之后把和电脑匹配的执行文件放到/usr/local/bin下面,你放其他地方也行,只要能保证它运行就可以。
如果你的网速不好,安装FFmpegconvert时会很慢,我用了六七个小时。
最后安装gifify

npm install -g gifify

执行

gifify -h

如果没问题的话,会出现如下结果:

Usage: gifify [options] [file]

  Options:

    -h, --help              output usage information
    -V, --version           output the version number
    --colors <n>            Number of colors, up to 255, defaults to 80
    --compress <n>          Compression (quality) level, from 0 (no compression) to 100, defaults to 40
    --from <position>       Start position, hh:mm:ss or seconds, defaults to 0
    --fps <n>               Frames Per Second, defaults to 10
    -o, --output <file>     Output file, defaults to stdout
    --resize <W:H>          Resize output, use -1 when specifying only width or height. `350:100`, `400:-1`, `-1:200`
    --speed <n>             Movie speed, defaults to 1
    --subtitles <filepath>  Subtitle filepath to burn to the GIF
    --text <string>         Add some text at the bottom of the movie
    --to <position>         End position, hh:mm:ss or seconds, defaults to end of movie

如果有报错缺少gifsicle,执行brew install giflossy.就可以了

使用

进入到你要转换的文件的目录下,比如我的mov文件放在桌面上,执行

cd Desktop/

然后执行

gifify timer.mov -o timer.gif

OK,回到桌面,我们发现想要的gif文件已经在那了。timer.mov是你要转换的文件,timer.gif是转成功之后你要的文件。
通过gifify命令,我们还可以在转换的同时,往gif里插入字幕、副标题等等,具体可以参考vvo/gifify

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容