Last active
January 24, 2020 20:57
-
-
Save mikew/d2e146a8c5ad5a3db5c2b95a38830594 to your computer and use it in GitHub Desktop.
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 | |
# http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html | |
_convert() { | |
palette="$(mktemp).png" | |
fps="15" | |
width="800" | |
# width="300" | |
dither="dither=bayer:bayer_scale=3" | |
filters="fps=$fps,scale=$width:-1:flags=lanczos" | |
output="$1.gif" | |
export PATH="$HOME/Downloads:$PATH" | |
ffmpeg -i "$1" -vf "$filters,palettegen=stats_mode=diff" -y "$palette" | |
ffmpeg -i "$1" -i "$palette" -lavfi "$filters [x]; [x][1:v] paletteuse=$dither" -y "$output" | |
rm "$palette" | |
} | |
for f in "$@"; do | |
_convert "$f" | |
done |
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 | |
export PATH="$HOME/Downloads:$PATH" | |
_convert() { | |
output="$1.mp4" | |
ffmpeg -i "$1" -vcodec h264 -an "$output" | |
} | |
for f in "$@"; do | |
_convert "$f" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment