Skip to content

Instantly share code, notes, and snippets.

@Firzen7
Forked from cachapa/gif_creator.sh
Created October 9, 2020 14:03
Show Gist options
  • Save Firzen7/e3ded30e39a496b27e08b13c2f06d6cf to your computer and use it in GitHub Desktop.
Save Firzen7/e3ded30e39a496b27e08b13c2f06d6cf 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