Skip to content

Instantly share code, notes, and snippets.

@andreban
Last active January 15, 2021 12:31
Show Gist options
  • Save andreban/28a4ba3c3cf4e943e29d2ed79b088a38 to your computer and use it in GitHub Desktop.
Save andreban/28a4ba3c3cf4e943e29d2ed79b088a38 to your computer and use it in GitHub Desktop.
Using ffmpeg to transform a video to an animated gif
#!/bin/sh
#Usage: ./gifenc.sh video.mkv anim.gif
palette="/tmp/palette.png"
filters="fps=30,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 $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment