Skip to content

Instantly share code, notes, and snippets.

@sndsgd
Created February 4, 2015 23:06
Show Gist options
  • Save sndsgd/ef4e3391d34dc461acf6 to your computer and use it in GitHub Desktop.
Save sndsgd/ef4e3391d34dc461acf6 to your computer and use it in GitHub Desktop.
Convert a gif to a video for use on the web
#!/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