Skip to content

Instantly share code, notes, and snippets.

@yeti-detective
Last active July 22, 2021 15:59
Show Gist options
  • Save yeti-detective/0112d7d516dbd85a44ace9a31362f827 to your computer and use it in GitHub Desktop.
Save yeti-detective/0112d7d516dbd85a44ace9a31362f827 to your computer and use it in GitHub Desktop.
This function will let you make MacOs screen captures into .gif files by running `gifit <input_filename> <gif pixel size ie: 1200x800> <output_filename>`
function gifit {
gifthis=1
input_file=""
output_file=output.gif
gifsize=900x600
if [[ $# -eq 0 ]]; then
gifthis=0
echo "Usage: gifit <input_mov_file> <gif pixel size ie: 1200x800> <output_gif_filename>"
echo " converts mov files into <gif_size> gif files"
fi
if [ $# -ge 1 ]
then
gifthis=1
input_file="$(echo $1)"
fi
if [[ $# -ge 2 ]]; then
input_file="$(echo $1)"
gifsize=$2
fi
if [[ $# -ge 3 ]]; then
output_file="$(echo $3)"
fi
if [[ $gifthis -eq 1 ]]; then
ffmpeg -i "$(echo $input_file)" -s $gifsize -pix_fmt rgb24 -r 30 -f gif - | gifsicle --optimize=3 --delay=3 > "$(echo $output_file)"
fi
}
@yeti-detective
Copy link
Author

If you're on Mac, install ffmpeg and gifsicle and then copy this function into ~/.profile or ~/.bash_profile
You gotta restart the terminal after or do source or whatever.

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