知識改變命運,擼碼使我快樂,2020繼續遊走在開源界<br/>
點贊再看,養成習慣<br/>
給我來個Star吧, 點擊瞭解下基於SpringBoot的組件化接口服務落地解決方案
Gifify
是一款工具類的開源框架,能夠將任何視頻文件轉換爲優化的動畫GIF。html
有些時候咱們須要將視頻轉換爲動畫GIF圖
,能夠更 生動形象的描述咱們想要說明的事物以及框架的使用方式,它對於程序員來講是一個不可或缺的工具
之一。
在安裝Gifify
以前首先咱們須要先安裝它所須要的運行環境:node
brew install node
)brew install ffmpeg
)brew install imagemagick
)brew install giflossy
)能夠經過npm
直接安裝Gifify
,以下所示:git
npm install -g gifify
下面是Gifify
所支持的命令行參數列表。程序員
➜ ~ gifify -h Usage: gifify [options] [file] Options: -V, --version output the version number --colors <n> Number of colors, up to 255, defaults to 80 (default: 80) --compress <n> Compression (quality) level, from 0 (no compression) to 100, defaults to 40 (default: 40) --from <position> Start position, hh:mm:ss or seconds, defaults to 0 --fps <n> Frames Per Second, defaults to 10 (default: 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` --reverse Reverses movie --speed <n> Movie speed, defaults to 1 (default: 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 --no-loop Will show every frame once without looping -h, --help output usage information
我使用Mac自帶的屏幕錄製軟件QuickTime Player
錄製了一個測試視頻,根據上面的命令行參數來看若是咱們不作一些其餘的自定義,只添加-o、--output
輸出的gif文件名便可,以下所示:github
➜ gifify 屏幕錄製2020-08-05\ 上午8.58.01.mov --output example.gif Generating GIF, please wait...
當咱們看到提示信息Generating GIF, please wait...
時,說明已經開始轉換了,由於視頻文件的大小有差別,因此轉換所須要的時間也全部不一樣。spring
自動建立的
example.gif
文件與轉換的視頻文件在同一目錄下。
若是你只須要轉換視頻中的一個時間段,咱們能夠經過指定--from
、--to
參數來配置,以下所示:npm
➜ gifify 屏幕錄製2020-08-05\ 上午8.58.01.mov --output example.gif --from 00:00:10 --to 00:00:15
Gifify
默認壓縮比例爲40%
,壓縮後的Gif圖可能會比較模糊,咱們能夠經過--compress
參數來修改壓縮比例,0表示無壓縮,取值範圍爲0~100
,以下所示:api
➜ gifify 屏幕錄製2020-08-05\ 上午8.58.01.mov --output example.gif --from 00:00:10 --to 00:00:12 --compress 0
Gifify
還有不少隱藏的功能,好比在GIF圖片上添加文字描述,縮放視頻比例,反轉視頻等功能,趕快去發掘它的隱藏功能吧。架構
做者我的 博客
使用開源框架 ApiBoot 助你成爲Api接口服務架構師