Skip to content

Instantly share code, notes, and snippets.

@joaonsantos
Created March 29, 2021 15:15
Show Gist options
  • Save joaonsantos/1e4ad2d53a31076eca70e3d59f3a4177 to your computer and use it in GitHub Desktop.
Save joaonsantos/1e4ad2d53a31076eca70e3d59f3a4177 to your computer and use it in GitHub Desktop.
Create a gif from any file
#!/bin/bash
set -e
# In case there is no args given
if [ $# -lt 2 ]
then
echo "usage: $0 <input> <output>"
exit 1
fi
echo "Starting conversion to gif"
echo "Please wait a moment..."
echo ""
ffmpeg -v error -y -i $1 -pix_fmt rgb8 $2
name="`echo "$2"|cut -d. -f1`"
gifsicle --optimize=3 --output "${name}-opt.gif" --resize-height 720 $2
echo "Success!"
@joaonsantos
Copy link
Author

For clarity:

This script creates a gif and optimizes it, optimized gif is named <output-name>-opt.gif.

For example:

./giffy.sh screencast output.gif

outputs output.gif and output-opt.gif.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment