Skip to content

Instantly share code, notes, and snippets.

@SlexAxton
Last active April 25, 2023 03:57
Show Gist options
  • Save SlexAxton/4989674 to your computer and use it in GitHub Desktop.
Save SlexAxton/4989674 to your computer and use it in GitHub Desktop.
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
echo "proper usage: gifify <input_movie.mov>. You DO need to include extension."
fi
}
brew install ffmpeg
brew tap phinze/homebrew-cask
brew install brew-cask
brew cask install x-quartz
open /usr/local/Cellar/x-quartz/2.7.4/XQuartz.pkg
# click through the stuff
brew install gifsicle
brew install imagemagick
# I had a weird problem with Convert/imagemagick where I had to do:
ln -s /usr/local/Cellar/libtool/2.4.2/lib/libltdl.7.dylib libltdl.7.dylib
# But hopefully you don't have to
# Take screencast using Quicktime. Export as high quality as possible.
gifify screencap.mov
gifify screencap.mov --good
@samarpanda
Copy link

Worked pretty good for me.

brew install ffmpeg gifsicle imagemagick

Thanks @paulirish & @SlexAxton

@nwinkler
Copy link

Wow, I like @tonycoco's solution. Well done!

@nwinkler
Copy link

I've added the gifify function to my bash-it fork: nwinkler/bash-it@e4bdad6

@vvo
Copy link

vvo commented Nov 24, 2014

There's now an installable binary for that, lots of options, optimized! https://github.com/vvo/gifify

@jeanmichelcote
Copy link

I get error on that command: brew install brew-cask

Error: Failed to download resource "brew-cask"
Failure while executing: git clone --depth 1 --branch v0.53.3 https://github.com/caskroom/homebrew-cask.git /Library/Caches/Homebrew/brew-cask--git

@thatryan
Copy link

Anyone come across this error?

Incompatible pixel format 'rgb24' for codec 'gif', auto-selecting format 'rgb8'

@CharlesSmart
Copy link

If this helps anyone, my XQuartz location ended up being:
open /opt/homebrew-cask/Caskroom/xquartz/2.7.7/XQuartz.pkg
I assume that's due to the update to 2.7.7?

@zentrope
Copy link

thatryan: Yes, I have that error (Yosemite). No idea what to do about it.

@nexdrew
Copy link

nexdrew commented Jun 18, 2015

For those looking to install @vvo's gifify with prerequisites:

# install pornel/giflossy (fork of gifsicle)
wget https://github.com/pornel/giflossy/releases/download/lossy%2F1.82.1/gifsicle-1.82.1-lossy.zip
unzip gifsicle-1.82.1-lossy.zip -d gifsicle-1.82.1-lossy
cp gifsicle-1.82.1-lossy/mac/gifsicle /usr/local/bin/
# install ffmpeg
brew install ffmpeg --with-fontconfig --with-libass
# install imagemagick
brew install imagemagick --with-fontconfig
# install gifify
npm install -g gifify

Thanks @vvo, @pornel, @paulirish, @SlexAxton, and internets.

@neuropass
Copy link

Please forgive my ignorance on the matter. I really want to use this as it seems the only method for high quality gifs.
I understand this is for MAC users only? I do have a mac pro. How can I use this script?
Thanks so much again!

@vvo
Copy link

vvo commented Feb 6, 2016

@nexdrew could you please add this to the gifify repo as a PR? very valuable

@mhulse
Copy link

mhulse commented Mar 27, 2016

@nexdrew could you please add this to the gifify repo as a PR? very valuable

@vvo and @nexdrew, here's a PR that does it in a curl one-liner: vvo/gifify#46. Feedback?

@mhulse
Copy link

mhulse commented Mar 27, 2016

For anyone else interested, installing gifify locally works pretty well too.

$ npm install --save-dev gifify

… in your package.json:

"scripts": {
  "gifify": "gifify"
}

And can be run from command line like so:

$ npm run gifify -- -o test.gif test.mp4

… or js script within package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment