Skip to content

Instantly share code, notes, and snippets.

@edsu
Last active October 21, 2021 18:29
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
A little shell script to put in your PATH if you forget the ffmpeg options to turn a video into an animated GIF.
#!/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
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=10,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