Skip to content

Instantly share code, notes, and snippets.

@evantahler
Last active June 26, 2020 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evantahler/10d2c62ff47dc53b0fe0934233c995ad to your computer and use it in GitHub Desktop.
Save evantahler/10d2c62ff47dc53b0fe0934233c995ad to your computer and use it in GitHub Desktop.
Convert movies to animated gifs
#!/bin/bash
# This script required ffmpeg and gifsicle
# On OSX: `brew install ffmpeg gifsicle`
SECONDS=0
INPUT_FILE=$1
BASENAME="${INPUT_FILE%.*}"
OUTPUT_FILE="$BASENAME.gif"
echo "🎥 Converting $INPUT_FILE to $OUTPUT_FILE"
ffmpeg -i $INPUT_FILE -pix_fmt rgb8 -r 10 $OUTPUT_FILE -loglevel warning -stats && gifsicle -O3 $OUTPUT_FILE -o $OUTPUT_FILE
ELAPSED="$(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
echo "🎉 Complete in $ELAPSED"
@evantahler
Copy link
Author

Usage:

➜  Desktop ./gifit movie.mov

🎥 Converting movie.mov to movie.gif
frame=  177 fps= 22 q=-0.0 Lsize=    1644kB time=00:00:17.61 bitrate= 764.6kbits/s dup=0 drop=877 speed=2.16x
gifsicle: warning: huge GIF, conserving memory (processing may take a while)
🎉 Complete in 0hrs 0min 26sec

@evantahler
Copy link
Author

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