本篇文章告诉你如何在 Mac OS X 上用免费的工具来将屏幕录制视频转成 GIF 动画, 这些免费的工具是: QuickTime, ffmpeg, and gifsicle.
首先, 使用系统自带的 "QuickTime Player" 程序来录制屏幕:
- 打开 "Quicktime Player",
- 从菜单选择 File -> New Screen Recording
- 点击红点准备录制, 然后用鼠标拖拽出一个你想录制的区域.
- 从菜单选择 File -> Export -> As Movie, 将视频保存成文件.
- 将你的视频保存为文件
in.mov
- 将你的视频保存为文件
To convert in.mov into out.gif (filesize: 48KB), open Terminal to the folder with in.mov
and run the following command:
ffmpeg -i in.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif
Notes on the arguments:
-r 10
告诉 ffmpeg 将视频的帧率转成 10fps, 这样可以减小视频体积-s 600x400
这是你的视频的尺寸, 600x400--delay=10
告诉 gifsicle GIF 每帧之间的时间间隔是 100ms(也就是帧率为 100fps, 1000ms/10fps = 100ms = 10x10ms), gifsicle 使用的单位是 10ms, 不是 ms--optimize=3
让 gifsicle 优化一下, 设置为 3 即可
To share the new GIF using Dropbox and Copy Public URL, run the following:
cp out.gif ~/Dropbox/Public/screenshots/Screencast-`date +"%Y.%m.%d-%H.%M"`.gif
The conversion process requires the following command-line tools:
- ffmpeg to process the video file
- gifsicle to create and optimize the an animated gif
If you use homebrew and homebrew-cask software packages, just type this in:
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
- http://schneems.com/post/41104255619/use-gifs-in-your-pull-request-for-good-not-evil (primary source!)
- http://www.reddit.com/r/programming/comments/16zu7d/use_gifs_in_your_pull_requests_for_good_not_evil/
- http://superuser.com/questions/436056/how-can-i-get-ffmpeg-to-convert-a-mov-to-a-gif#_=_
- http://gnuski.blogspot.ca/2012/06/creating-animate-gif-with-free-software.html
- Extend https://github.com/dergachev/copy-public-url folder action for this use case
- it would automate the conversion before copying Dropbox public URL
- assign the folder action to ~/Dropbox/Public/Screenshots/gif
- consider finding a way to simplify the dependency installation
打扰,问一下我倒出来的背景不透明,是什么原因