Programster's Blog

Tutorials focusing on Linux, programming, and open-source

FFmpeg - Create GIF Animated Images

Below is my really simple script for creating GIFs quickly and easily. If you want to put in a lot of effort to get them nicer looking there is this post at engineering.giphy.com.

Steps

# Set framerate of animated image.
FRAMERATE=30

# Set output width/height
WIDTH=800
HEIGHT=450

# Set the number of times to loop.
# 0 = infinite
# 1+ = that many times.
# -1 = no loop
LOOP=0


ffmpeg \
  -i output.mp4 \
  -loop $LOOP \
  -vf "fps=$FRAMERATE, scale=$WIDTH:$HEIGHT" \
  output.gif
Last updated: 28th February 2021
First published: 28th February 2021