Created
May 24, 2017 02:54
-
-
Save shivakar/0cc1474f9716dfaf643cb62a9365957e to your computer and use it in GitHub Desktop.
Create GIF from a video using ffmpeg and gifsicle
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
#!/usr/bin/env bash | |
if [ $# -ne 2 ]; then | |
echo "$0 - Creates a GIF from a video using ffmpeg and gifsicle" | |
echo "Usage: $0 <input-filename> <output-filename>" | |
exit | |
fi | |
infile="${1}" | |
outfile="${2}" | |
# Check if input file exists | |
if [ ! -f ${infile} ]; then | |
echo "Input file - ${infile} - does not exist. Aborting..." | |
exit | |
fi | |
# Check if output file exists | |
if [ -f ${outfile} ]; then | |
echo "Output file - ${outfile} - already exists." | |
echo "Please delete output file before proceeding. Aborting..." | |
exit | |
fi | |
## Run the conversion | |
ffmpeg -i "${infile}" -pix_fmt rgb24 -r 5 -f gif - | gifsicle --optimize=3 > "${outfile}" | |
echo "Done with conversion." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment