Last active
February 7, 2017 01:23
-
-
Save kriscooke/aa0ddd6e3654b554b378fa6c51dc5b59 to your computer and use it in GitHub Desktop.
Color-optimized Video to GIF with ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Generates an infinitely looping GIF (-loop 0) from an input video with ffmpeg. | |
# Arguments, in order: input video file, output gif file, end time (seconds) | |
# Modify args in `filters` to change fps or size (height) in pixels. | |
# Credit for optimizing color palette quality goes to: | |
# http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html | |
palette="/tmp/palette.png" | |
filters="fps=20,scale=199:-1:flags=lanczos" | |
ffmpeg -v warning -i $1 -loop 0 -vf "$filters,palettegen" -to $3 -y $palette | |
ffmpeg -v warning -i $1 -loop 0 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -to $3 -y $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment