Created
January 27, 2017 07:36
-
-
Save hastebrot/a0a3f33734496486c016f2c651785305 to your computer and use it in GitHub Desktop.
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 | |
| # FILE: record-gif.sh | |
| # DEPS: sudo apt install byzanz gifsicle | |
| # SOURCE: http://askubuntu.com/questions/107726/how-to-create-animated-gif-images-of-a-screencast | |
| # delay in seconds before recording (defaults to 2s). | |
| DELAY=2 | |
| # duration in seconds of recording (defaults to 10s). | |
| if [ $# -gt 0 ]; then | |
| D="--duration=$@" | |
| else | |
| D="--duration=10" | |
| fi | |
| # output file base name (defaults to "recorded.gif" in current dir). | |
| F="$PWD/recorded" | |
| # use mouse cursor to retrieve window bounds. | |
| XWININFO=$(xwininfo) | |
| read X <<< $(awk -F: '/Absolute upper-left X/{print $2}' <<< "$XWININFO") | |
| read Y <<< $(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$XWININFO") | |
| read W <<< $(awk -F: '/Width/{print $2}' <<< "$XWININFO") | |
| read H <<< $(awk -F: '/Height/{print $2}' <<< "$XWININFO") | |
| # start pre-recording delay. | |
| echo Delaying $DELAY seconds. After that, byzanz will start | |
| for (( i=$DELAY; i>0; --i )) ; do | |
| echo $i | |
| sleep 1 | |
| done | |
| # start recording and save recorded gif. | |
| byzanz-record --verbose --delay=0 --x=$X --y=$Y --width=$W --height=$H $D $F.gif | |
| # optimize recorded gif. | |
| gifsicle -O $F.gif -o $F.opt.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment