Skip to content

Instantly share code, notes, and snippets.

@jorgemf
Created January 30, 2015 01:51
Show Gist options
  • Save jorgemf/a7be22abdc60aebacf1f to your computer and use it in GitHub Desktop.
Save jorgemf/a7be22abdc60aebacf1f to your computer and use it in GitHub Desktop.
Shell script that converts a video to a gif file using ffmpeg and convert commands
#!/bin/sh
if [ $# -eq 0 ]; then
echo "video2gif.sh [INPUT] [HEIGHT] [START] [LENGTH]"
exit
fi
INPUT=$1
HEIGHT=$2
INIT=$3
LENGTH=$4
ffmpeg -i $INPUT -vf scale=-1:$HEIGHT -ss $INIT -t $LENGTH -r 14 -f image2pipe -vcodec ppm - | convert -delay 7 -loop 0 -dither None -colors 80 -fuzz "40%" - gif:- | convert -layers Optimize - $INPUT-optimized.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment