public
Last active

screencaps to video

  • Download Gist
screc.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#!/bin/bash
# OSX requires Quicktime Pro, linux requires scrot and mencoder
 
# jpg faster/png higher quality
FORMAT=jpg
 
usage() {
cat <<!
use: $(basename $0) -c <path/to/empty/folder> [seconds]
$(basename $0) -o <path/to/empty/folder>
 
-c take screenshot every n seconds in a 1 hour loop
default 5 seconds
-o make 12fps video of stored screenshots
OSX: must specify absolute path to folder
!
exit
}
 
capture() {
[ -d "$1" ] || return
case $(uname) in
Darwin) CAP="screencapture -Cm";;
Linux) CAP="scrot";;
*) return;;
esac
while :; do
local i="$1"/$(date +%s).$FORMAT
$CAP "$i"
# delete *.$FORMAT older than 1 hour (be careful!!)
find "$1" -name *.$FORMAT -mmin +60 -delete
sleep ${2:-5}
# maximum res mplayer will play is 2046x2046
[ "$(identify -format "%w" $i)" -gt 2046 ] && mogrify -resize 2046 $i
done
}
 
Darwin_mkvid() {
[ -d "$1" ] || return
[ "${1:0:1}" = "/" ] || {
echo "path to folder [$1] must be absolute"
return
}
osascript -e "tell application \"Finder\" to set f to first file of folder (POSIX file \"$1\" as string) as string" -e "tell application \"QuickTime Player\"" -e "open image sequence f frames per second 12" -e "save self contained document \"Untitled\" in \"$1/output.mov\"" -e "quit" -e "end tell"
echo $1/output.mov | pbcopy | pbpaste
}
 
Linux_mkvid() {
[ -d "$1" ] || return
cd $1
# motion png/jpg - fast, good quality, relatively small
mencoder mf://*.$FORMAT -mf fps=12:type=$FORMAT -ovc copy -oac copy -o output.avi
echo $1/output.avi
# xclip?
}
 
if [ $1 ]; then
case $1 in
-c) shift; capture $*;;
-o) shift; $(uname)_mkvid $*;;
*) usage;;
esac
else
usage
fi

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.