Skip to content

Instantly share code, notes, and snippets.

@porty
Created December 22, 2021 20:31
Show Gist options
  • Save porty/9d6c78295cdec81e48e3b6d7a8a21ba1 to your computer and use it in GitHub Desktop.
Save porty/9d6c78295cdec81e48e3b6d7a8a21ba1 to your computer and use it in GitHub Desktop.
FFMpeg mov to gif
#!/bin/bash
set -euo pipefail
# https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/
# convert *.mov to *.gif
for f in *.mov; do
out=${f//.mov/.gif}
rm -rf "$out"
# -i: the input filename
# -r 5: bump the framerate down to 5 fps (save space)
# palettegen stuff: better quality for hopefully similar space
ffmpeg \
-i "$f" \
-r 5 \
-filter_complex "[0:v] fps=12,split [a][b];[a] palettegen [p];[b][p] paletteuse" \
"$out"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment