Created
August 6, 2017 17:22
-
-
Save axynos/1bdae00a586a84bf2802d37576c66946 to your computer and use it in GitHub Desktop.
Generates gif palettes dynamically to increase quality. Nicked (and modified a bit) from http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
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 | |
# original script from http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html | |
palette="/tmp/palette.png" | |
# the scale here refers to the horizontal size which then gets used to scale the output | |
# variables: | |
# fps: Frames Per Second | |
# scale: horizontal width in pixels | |
filters="fps=30,scale=728:-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 | |
# Usage: ./palettemagic.sh inputvideo.extension outputfile.gif | |
# Example: ./palettemagic.sh final.mp4 output.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment