Skip to content

Instantly share code, notes, and snippets.

@edsu
Last active May 24, 2022 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edsu/c30a615400515535e02bf67bd8f8274a to your computer and use it in GitHub Desktop.
Save edsu/c30a615400515535e02bf67bd8f8274a to your computer and use it in GitHub Desktop.
#!/bin/sh
# Turn a video file into an animated GIF
USAGE="usage: gif video_file [gif_file]"
video_file=$1
if [ "$video_file" = "" ]; then
echo $USAGE
exit 1
elif [ $2 ]; then
gif_file=$2
else
gif_file="${video_file%.*}.gif"
fi
echo "converting ${video_file} to ${gif_file} ..."
ffmpeg -i "${video_file}" -vf "fps=5,scale=1000:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 "${gif_file}" -loglevel error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment