Last active
August 29, 2015 14:21
-
-
Save andyman/c890f1f03696aae288dc to your computer and use it in GitHub Desktop.
Bash script for converting a video file to a small animated gif. Requires ffmpeg and imagemagick to be installed and accessible.
This file contains 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 | |
echo "USAGE" | |
echo "convert_to_gif.sh <video_file_name> <frames_per_second>" | |
echo "--------------------" | |
# from here: | |
# http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality | |
# add the "-ss 2 -t 6" arguments after the ffmpeg to skip 2 seconds and have a duration of 6 secs | |
ffmpeg -y -i $1 \ | |
-vf fps=$2,scale=320:-1:flags=lanczos,palettegen palette.png | |
ffmpeg -i $1 -i palette.png -filter_complex \ | |
"fps=$2,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif | |
rm palette.png | |
convert -layers Optimize output.gif $1.gif | |
rm output.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment