Created
June 18, 2014 22:03
-
-
Save vmrob/27e4de2295c253edb7b3 to your computer and use it in GitHub Desktop.
Converts a video to a gif
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 -e | |
# Converts a video to a gif | |
if [ "$#" -ne 2 ]; then | |
echo "usage: ${0##*/} [input video] [output gif]" | |
exit 1 | |
fi | |
VIDEO=$1 | |
GIF=$2 | |
# finds width and height of $VIDEO expressed as 123x456 | |
WIDTH_HEIGHT=$(ffprobe -loglevel warning -show_streams $VIDEO | grep -e "width\|height" | sed -E 's/(width|height)=//g' | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/x/g') | |
# converts the video | |
ffmpeg -i $VIDEO -s $WIDTH_HEIGHT -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $GIF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment