posted in code | 7 comments
OR: Playing with my scrot
I’ve been playing with my
scrot relentlessly for the past two or three days. Literally non-stop for hours a time. I’ve even been making videos and then putting those videos on YouTube.
Scrot – SCReen shOT – is a FOSS screen capture utility that cleaves to the old Unix philosophy: It does one thing and does it very well indeed. And that is take screenshots. So get your freaking mind out of the gutter, dear reader(s).
It’s cool, I can wait.
Scrot is something I’ve used for my screen capturing since 2003 or so, and while I’ve previously bowed to scrot’s scripting prowess, it has only been in the last four days that I’ve discovered another fun use for scrot: Simple, lite (resource-wise) time-lapse capture of my desktop. You can do it at home with just scrot and mplayer.
Get scrot and mplayer on your system if you don’t already have them. Under Ubuntu, conveniently, it is:
apt-get install scrot mplayer
- Type or copy and paste this command into the terminal while in the folder where you would like to capture the images
while [ 1 ]; do scrot -q 100 $(date +%Y%m%d%H%M%S).jpg; sleep 1; done
gives you an unending loop. Scrot will literally loop taking screensots until you finally decide to kill the program. As a quick rule of thumb, you need between 900 and 1,200 still images per minute of footage
(60 seconds@15 FPS=900; 60 seconds@20 FPS=1,200). This does seem like a whole lot of still images, but at ~300 stills per 10 minutes, you’ll generate
(300x6)1,800 per hour.
So about two hours of recording will net you a video that will go along very nicely to your average song track.
- Make a list for mencoder to read:
ls -1tr *.jpg > files.txt
Stitch together your still images with mencoder. While I noted my own preferences aloud yesterday, you really are free to look at mencoder’s options – and I freely encourage you to do this. So far as I can gather, mencoder can do anything you ask of it…if you know the correct account.
Encoding your video as-is (video raw, like still raw) is great for quality, but takes up a respectable chunk of hard-disk space. I settled on encoding with h.264 because it gave me a great balance of file-size and quality. Your frames per second in the video matter for two reasons: 1. Controlling video length (for fitting it to a soundtrack), and 2. controlling playback speed. Do you want events to whizz past, or be slower and more followable?
mencoder -ovc x264 -oac mp3lame -audiofile basket_case.mp3 -mf w=1400:h=900:fps=20:type=jpg 'mf://@files.txt' -o screenlapse.avi
I strongly encourage you to look up documentation on mencoder (such as here) so you can experiment and determine a solution that best fits your own needs.
And that’s it. For your pleasure, here’s one I made earlier: