-
-
Save thiagogabriel/5843564 to your computer and use it in GitHub Desktop.
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 [[ ! -f "$1" ]]; then | |
echo "=> Movie file not found" | |
exit 1 | |
fi | |
tempfile=/tmp/output.gif | |
rm -f $tempfile | |
echo "=> Converting $1 to GIF" | |
ffmpeg -i "$1" -pix_fmt rgb24 "$tempfile" > /tmp/giffy.log 2>&1 | |
if [[ ! -f "$tempfile" ]]; then | |
echo "=> Error while converting $1 to GIF" | |
echo "=> Check the file /tmp/giffy.log" | |
exit 1 | |
fi | |
filename=$(basename "$1") | |
filename="${filename%.*}" | |
dir=$(dirname "$1") | |
output="$dir/$filename.gif" | |
echo "=> Exporting optimized GIF to $output" | |
convert -layers Optimize "$tempfile" "$output" > /tmp/giffy.log 2>&1 | |
if [[ ! -f "$output" ]]; then | |
echo "=> Error while exporting $output" | |
echo "=> Check the file /tmp/giffy.log" | |
exit 1 | |
fi | |
rm $tempfile | |
echo "=> Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment