Skip to content

Instantly share code, notes, and snippets.

@cnunciato
Created April 22, 2020 00:22
Show Gist options
  • Select an option

  • Save cnunciato/cf7fcc2ed547efb729a0406b17e307f6 to your computer and use it in GitHub Desktop.

Select an option

Save cnunciato/cf7fcc2ed547efb729a0406b17e307f6 to your computer and use it in GitHub Desktop.
gif.sh
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
}
@cnunciato
Copy link
Author

Usage:

$ gif ~/path/to/some.mov 
$ gif ~/path/to/some.mov 640
$ gif ~/path/to/some.mov 640 12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment