HOWTO: Time-lapse capture your Linux desktop

in code

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.

Done? Great.

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.


  1. Get scrot and mplayer on your system if you don’t already have them. Under Ubuntu, conveniently, it is:

    apt-get install scrot mplayer

  2. 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.

  3. Make a list for mencoder to read:

    ls -1tr *.jpg > files.txt

    Simple, eh?

  4. 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:

It was, for the record:

in technology

[mark][Screenlapse] # mencoder -ovc copy -oac mp3lame -audiofile basket_case.mp3 -mf w=1024:h=600:fps=20:type=jpg 'mf://@files.txt' -o screenlapse.avi

This also worked perfectly well to get a YouTube video:

[mark][Screenlapse] # mencoder -ovc x264 -oac mp3lame -audiofile basket_case.mp3 -mf w=1024:h=600:fps=20:type=jpg 'mf://@files.txt' -o screenlapse.avi

Timelapse, part 2 of 1

in 091 labs

Inspired by yesterday’s timelapse experiments at 091 Labs, I bought a cheap little PC Line webcam from Currys today (tenner for 1.3mp isn’t bad) and experimented some more with webcam. The results have been:

  1. I’ve eliminated the need for a external script to manage the capture operation. A simple webcam & dumps the process into the background until I come back to kill it.
  2. The external 1.3mp webcam, identified by lsusb as a Microdia Sonix USB 2.0 Camera, is much nicer to work with. The 1280x1024px image size is four times what my laptop’s webcam can achieve.

My biggest problem right now is maybe stability; I need to tape my webcam to a tripod or something to keep it steady.