Skip to content

Instantly share code, notes, and snippets.

@wteuber
Last active January 27, 2017 10:31
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 wteuber/e6371343af48ad0f61eec0c13b872f6f to your computer and use it in GitHub Desktop.
Save wteuber/e6371343af48ad0f61eec0c13b872f6f to your computer and use it in GitHub Desktop.
Convert mov to gif (made for QuickTime Player screen recordings)
#! /usr/bin/env bash
if [ -f "$1" ]; then
echo "ffmpeg -i $1 -vcodec copy -acodec copy $1.mp4 ..."
ffmpeg -i $1 -vcodec copy -acodec copy $1.mp4
else
echo "ERROR: Could not find $1"
fi
if [ \( $? -eq 0 \) -a \( -f $1.mp4 \) ]; then
echo "ffmpeg -y -i $1.mp4 -vf fps=1,scale=600:-1:flags=lanczos,palettegen $1.mp4.palette.png ..."
ffmpeg -y -i $1.mp4 -vf fps=1,scale=600:-1:flags=lanczos,palettegen $1.mp4.palette.png
else
echo "ERROR"
fi
if [ \( $? -eq 0 \) -a \( -f $1.mp4.palette.png \) -a \( -f $1.mp4 \) ]; then
echo "ffmpeg -i $1.mp4 -i $1.mp4.palette.png -filter_complex "setpts=0.125*PTS,fps=60,scale=720:-1:flags=lanczos[x];[x][1:v]paletteuse" $1.mp4.gif ..."
ffmpeg -i $1.mp4 -i $1.mp4.palette.png -filter_complex "setpts=0.125*PTS,fps=60,scale=720:-1:flags=lanczos[x];[x][1:v]paletteuse" $1.mp4.gif
else
echo "ERROR"
fi
if [ \( $? -eq 0 \) -a \( -f $1.mp4.gif \) ]; then
echo "$1.mp4.gif successfully created."
else
echo "ERROR: $1.mp4.gif counld mot be be created."
fi
@wteuber
Copy link
Author

wteuber commented Jan 27, 2017

Get mov2gif.sh

wget https://gist.githubusercontent.com/wteuber/e6371343af48ad0f61eec0c13b872f6f/raw/ef359802bd723eee13553a85b255a6ca66770f73/mov2gif.sh && chmod +x mov2gif.sh

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