Animated gifs from the command line in MacOS
quick little command line for MP4 to GIF
Sometimes you need a gif from a video you made in Blender or heck even from an online video. Luckily, there is ffmpeg
to help us out. Here is a quick little command line that will turn your fancy HD video into a 320p gif for your meme sending ways.
ffmpeg -i input.mp4 -filter_complex "scale=320:-1" output.gif
This takes an input video input.mp4
and scales it down to 320 pixels on the width while keeping the aspect ratio, then saves it as output.mp4

More
You can generate a palette of colors for you video with the following command:
ffmpeg -i input.mp4 -filter_complex "[0:v] palettegen" palette.png
Then use that palette in your GIF
ffmpeg -i input.mp4 -i palette.png -r 12 -s 256x256 -filter_complex "[0:v][1:v] paletteuse" fancy.gif
Since the default palette in ffmpeg is 256, we are forcing it to use our colors.
Hot tip on GIF palette from:
https://homehack.nl/create-animated-gifs-from-mp4-with-ffmpeg/
Bonus Content
You can take a few seconds from a video to create memes with this super power.
You will need a tool like yt_dlp
to get the video, but I will leave that for another post.
ffmpeg -ss 6 -t 1.2 -i RickAstley.mp4 -filter_complex "scale=320:-1" dance.gif
-ss
is the start time [6 seconds in]
-t
is the total number of seconds to capture [1.2 seconds to capture the dance]
This command will output the following gif:

Now go out and shower the world with the love of Rick Astley