Skip to content

Instantly share code, notes, and snippets.

@huytd
Created February 3, 2022 00:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huytd/f0ccef0c3c572ba1afb72ecd43fdf1d5 to your computer and use it in GitHub Desktop.
Save huytd/f0ccef0c3c572ba1afb72ecd43fdf1d5 to your computer and use it in GitHub Desktop.
if [[ $1 == "-h" ]] || [ $# == 0 ]; then
echo "Convert video to GIF"
echo "Usage:"
echo " video2gif <file-name> [width] [fps]"
else
ffmpeg -y -i "${1}" -vf fps=${3:-10},scale=${2:-320}:-1:flags=lanczos,palettegen "${1}.png"
ffmpeg -i "${1}" -i "${1}.png" -filter_complex "fps=${3:-10},scale=${2:-320}:-1:flags=lanczos[x];[x][1:v]paletteuse" "${1}".gif
rm "${1}.png"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment