Last active
February 4, 2016 17:24
-
-
Save riccardobl/a0a07a94e32e11e84df7 to your computer and use it in GitHub Desktop.
Convert a video to a gif file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: video2gif myvideo.mp4 | |
# | |
temp_dir=/tmp/video2gif-`tr -dc A-Za-z0-9 < /dev/urandom | head -c 8` | |
echo "Using temp directory $temp_dir" | |
mkdir "$temp_dir" | |
ffmpeg -i "$1" -r 15 -vf scale=-1:-1 "$temp_dir/frame-%04d.gif" | |
convert -delay 1x15 -loop 0 "$temp_dir/frame-*.gif" "$temp_dir/animation.gif" | |
mv "$temp_dir/animation.gif" "$1.gif" | |
rm -Rf "$temp_dir" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment