Created
February 4, 2015 23:06
-
-
Save sndsgd/ef4e3391d34dc461acf6 to your computer and use it in GitHub Desktop.
Convert a gif to a video for use on the web
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 | |
if [[ -z "$1" ]]; then | |
echo "provide a path to the source gif file" | |
exit 1 | |
elif [ ! -f "$1" ]; then | |
echo "the provided path is not a file" | |
exit 1 | |
fi | |
filename=$(basename "$1") | |
extension="${filename##*.}" | |
if [[ "$extension" != "gif" ]]; then | |
echo "provided path must end in '.gif'" | |
exit 1 | |
fi | |
# mp4 for suitable for safari | |
# NOTE: both dimensions must be divisible by 2 | |
ffmpeg -f gif -i "$1" -c:v libx264 -movflags +faststart -pix_fmt yuv420p "${1%.*}".mp4 | |
# most other browsers | |
ffmpeg -f gif -i "$1" "${1%.*}".webm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment