-
-
Save oskuhsiu/84bcd12ebc3d75a5f8fe to your computer and use it in GitHub Desktop.
Bash script to record screenshots on Android until interrupted, then assemble all screenshots to an animated GIF. Useful for demos etc.
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/sh | |
| echo "Press Ctrl + C to stop recording" | |
| PREFIX="Screenshot-$(date +%Y%m%d-%H%M%S)" | |
| BASE="/sdcard/$PREFIX" | |
| DELAY=300 | |
| trap ctrl_c INT | |
| function clean_up() { | |
| rm -f $PREFIX*.png | |
| echo "Cleaned up individual screenshots." | |
| } | |
| function pull_images() { | |
| echo "Downloading images." | |
| adb $1 $2 pull "$BASE/" | |
| find $PREFIX*.png -empty -delete | |
| } | |
| function assemble_gif() { | |
| convert -delay $DELAY -loop 0 $PREFIX*.png $PREFIX.gif | |
| echo "Assembled gif $PREFIX.gif" | |
| } | |
| running=1 | |
| function ctrl_c() { | |
| running=-1 | |
| } | |
| adb shell mkdir $BASE | |
| i=0 | |
| while [ $running -ge 0 ] | |
| do | |
| i=$(($i+1)) | |
| IMAGE="$BASE/$PREFIX-$i.png" | |
| adb $1 $2 shell screencap -p $IMAGE | |
| echo "Wrote screenshot to $IMAGE" | |
| done | |
| pull_images | |
| assemble_gif | |
| clean_up | |
| open $PREFIX.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment