Created
April 22, 2020 00:22
-
-
Save cnunciato/cf7fcc2ed547efb729a0406b17e307f6 to your computer and use it in GitHub Desktop.
gif.sh
This file contains hidden or 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
| gif() { | |
| if [ ! "$(ffmpeg -version)" ]; then | |
| echo "It looks like ffmpeg isn't installed. Try installing with Homebrew (e.g., brew install ffmpeg)." | |
| return $? | |
| fi | |
| if [ -z $1 ]; then | |
| echo "Usage: " | |
| echo " gif /path/to/source.mov [width in pixels (640 default)] [frames per second (12 default)]" | |
| return 0 | |
| fi | |
| ffmpeg -y -i ${1} -filter_complex "[0:v] palettegen,scale=${2:-640}:-1" ${1}.png && \ | |
| ffmpeg -y -i ${1} -filter_complex "[0:v] fps=${3:-12},scale=w=${2:-640}:h=-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" ${1}.gif && \ | |
| open -R ${1}.gif | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: