Created
August 12, 2020 21:56
-
-
Save dcramps/8fd83ff115a2a81c290b3a4a43551884 to your computer and use it in GitHub Desktop.
Make a gif from an iOS simulator with this one weird trick.
This file contains hidden or 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 | |
| FILENAME=$1 | |
| TEMPDIR="/Users/dc/Documents/GIFs/temp" | |
| SAVEDIR="/Users/dc/Documents/GIFs" | |
| trap trapsigint INT | |
| function trapsigint { | |
| echo -e "\nMaking $FILENAME.gif" | |
| makegif | |
| echo "GIF is at $SAVEDIR/$FILENAME.gif" | |
| open -R $SAVEDIR/$FILENAME.gif | |
| } | |
| function recordgif { | |
| echo "Recording - CTRL+C to stop" | |
| xcrun simctl io booted recordVideo $TEMPDIR/$FILENAME.mov > /dev/null 2>&1 | |
| } | |
| function makegif { | |
| ffmpeg -nostats -loglevel 0 -y -i $TEMPDIR/$FILENAME.mov -vf fps=30,scale=320:-1:flags=lanczos,palettegen $TEMPDIR/palette.png | |
| ffmpeg -nostats -loglevel 0 -y -i $TEMPDIR/$FILENAME.mov -i $TEMPDIR/palette.png -filter_complex "fps=30,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" $SAVEDIR/$FILENAME.gif | |
| rm $TEMPDIR/$FILENAME.mov | |
| } | |
| if [ -z "${FILENAME}" ]; then | |
| echo "No name provided. Using wtf." | |
| FILENAME="wtf" | |
| fi | |
| recordgif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment