Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Quick video to GIF converter
#!/bin/bash
me=`basename "$0"`
## i.e. mkgif Untitled.mov 640x360 20 2d.gif -vf "hflip,vflip"
usage="Usage: $me INFILE WxH FPS OUTFILE ffmpeg_opts.."
if [ -z "$1" ]
then
echo "No input file supplied."
echo $usage
exit 1
fi
if [ -z "$2" ]
then
echo "No resolution supplied."
echo $usage
exit 1
fi
if [ -z "$3" ]
then
echo "No FPS supplied."
echo $usage
exit 1
fi
if [ -z "$4" ]
then
echo "No output file supplied."
echo $usage
exit 1
fi
echo FPS: "$3"
ftime=`expr 95 / "$3"`
echo FTime: $ftime
ffmpeg -i "$1" -s "$2" -pix_fmt rgb24 -r "$3" -f gif "${@:5}" - | gifsicle --optimize=3 --delay=$ftime > "$4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment