Creating Animated GIFs using a Bash pipe

How I create superior-quality GIFs using FFMPEG and ImageMagic

A coding friend asked me recently how I created my superior quality animated GIF demos of running Cypress e2e testing my applications.

I have to confess - this one-liner truly gives me utmost pleasure in life.



  • FFMPEG audio/video swiss-army knife FFMPEG
  • ImageMagic convert - better aGIF generator than FFMPEG ImageMagick
  • Bash command line pipe Bash

The One-liner

ffmpeg -i screen_capture-01.mp4 -f image2pipe -vcodec ppm - | convert - -layers Optimize final.gif

Here is how I automatically convert to animated GIF the last video in my folder.

ffmpeg -i $(screen_capture*.mp4 | fold | tail -n 1) -f image2pipe -vcodec ppm - | convert - -layers Optimize final.gif