Skip to content

Instantly share code, notes, and snippets.

@vladkorotnev
Created June 10, 2016 17:19
Show Gist options
  • Save vladkorotnev/10e7878d597d4e8298cd4a5fc59c9fd7 to your computer and use it in GitHub Desktop.
Save vladkorotnev/10e7878d597d4e8298cd4a5fc59c9fd7 to your computer and use it in GitHub Desktop.
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