GIFs

November 11, 2019 — September 17, 2021

computers are awful
photon choreography
premature optimization
standards

1 FFMPEG is your friend

GIF is one of the output formats of FFMPEG.

1.1 Convert GIF to movie

Google advises on converting animated GIFs to movies:

ffmpeg -i input.gif -b:v 0 -crf 25 output.mp4

The evil martians version is lengthier:

ffmpeg -i input.gif -map_metadata -1 -c:a libfdk_aac -c:v libx264 -cfr 24 -preset veryslow -profile:v mail -px_fmt yuv420p -movflags +faststart -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" image.h264.mp4

1.2 Convert movie to GIF

10fps, low resolution, seconds 5-8:

``bash ffmpeg -i movie.mp4 -ss 5 -to 8 -vf scale=480:-1 -r 10 movie.gif ```

2 FFMPEG alternatives

3 Examples