Skip to content

Instantly share code, notes, and snippets.

@cachapa
Last active April 1, 2022 12:07
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save cachapa/aa829bfc717fc4f1d52c568d7ae8521e to your computer and use it in GitHub Desktop.
Save cachapa/aa829bfc717fc4f1d52c568d7ae8521e to your computer and use it in GitHub Desktop.
Shell script to generate high-quality animated gifs from a video file
#!/bin/bash
# Based on http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
# Requires ffmpeg
filename="${1%.*}"
palette="/tmp/palette.png"
filters="scale=320:-1:flags=lanczos"
ffmpeg -v warning -i "$1" -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i "$1" -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y "$filename.gif"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment