Skip to content

Instantly share code, notes, and snippets.

@artursapek
Last active August 29, 2015 14:17
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save artursapek/5b3d15ecac5ff75593c4 to your computer and use it in GitHub Desktop.
Save artursapek/5b3d15ecac5ff75593c4 to your computer and use it in GitHub Desktop.
mov2gif
#!/bin/bash
# mov2giv in out width
# mov2gif video_file_in.mov gif_file_out.gif 300
tmp_dir=/tmp/frames_$(date +%s)
mkdir $tmp_dir
if [ -z "$3" ]
then
size=600
else
size=$3
fi
echo "Converting $1 => $2 ($3 px wide)"
echo "Generating frames"
(ffmpeg -i $1 -vf scale=$size:-1 -r 10 $tmp_dir/ffout%03d.png) >& /dev/null
echo "Building gif from frames"
(convert -delay 5 -loop 0 $tmp_dir/ffout*.png $2) >& /dev/null
echo "Cleaning up"
rm -rf $tmp_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment