Created
July 23, 2014 23:45
-
-
Save greymeister/687a6ffd9f26777b88a7 to your computer and use it in GitHub Desktop.
gif_to_mpeg - convert gif to mpeg video file using imagemagick and ffmpeg
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
#!/bin/bash | |
## gif_to_mpeg | |
## Based on http://stackoverflow.com/a/3212958 and http://apple.stackexchange.com/a/103834 | |
## charles.erwin@vendscreen.com | |
## Take first argument which should be a filename | |
if [ -z "$1" ] | |
then | |
echo "Usage: $0 'filename.gif'" | |
exit 1 | |
else | |
filename=$1 | |
fi | |
## Use imagemagick to convert to individual frames | |
timestamp="$(date +%s)" | |
echo "Starting $filename gif --> mpeg processing at $(date)" | |
convert -coalesce "$filename" "/tmp/${timestamp}temp%05d.png" | |
## Use ffmpeg to convert frames into video | |
ffmpeg -f image2 -i "/tmp/${timestamp}temp%05d.png" "${filename}_video.mpg" -y | |
## Cleanup | |
rm /tmp/"${timestamp}temp"*.png | |
echo "DONE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment