Skip to content

Instantly share code, notes, and snippets.

@EHG613
Forked from cachapa/gif_creator.sh
Created May 11, 2020 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EHG613/172a2d347dbd055cdcb99d08d62206f7 to your computer and use it in GitHub Desktop.
Save EHG613/172a2d347dbd055cdcb99d08d62206f7 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