index rss mastodon twitter github linkedin email
Álvaro Ramírez
sponsor

Álvaro Ramírez

09 July 2015 mp4 to gif

Converting mp4 to gif is handy for posting short screencasts. You can convert to gif using ffmpeg and optimize with imagemagick. To install:

apt-get install ffmpeg imagemagick (linux)
brew install ffmpeg imagemagick (Mac)

Convert to gif:

ffmpeg -i my.mp4 -pix_fmt rgb24 -r 5 my.gif

Optimize with:

convert -dither none -layers Optimize my.gif my_optimized.gif

UPDATE: There's also licecap and subsequently optimize with:

cat source.gif | gifsicle --colors 256 --optimize=3 --delay=15 > target.gif

UPDATE: Also consider for .mov:

ffmpeg -i in.mov -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif