I’ve done a couple of 3d printing timelapses using a little application called Iris for OSX. Iris doesn’t seem to like to save my movies for some reason, but it at least gets the output from my fin de siècle webcam onto my laptop’s display so I can do something with it, like capture the screen once a minute and write it to a file using a Python script.
I’ve written this script to be as simple as possible for a novice who knows very little about programming. Being familiar with the concepts of variables and loops before using this will help, but really you should be able to paint-by-the-numbers and get one screengrab a minute without any extra work.
Bonus: some version of Python comes pre-installed on OSX, so you don’t have to install anything to get this to run.
- Make a new folder on your Desktop named capture
- Open TextEdit.
- Copy this script into a new text file. Save it on your Desktop with the name capture.py
- Open the Terminal.
- In the Terminal type python ~/Desktop/capture.py
That’s it! You can stop the script from running by hitting Control-Z in the Terminal.
# everything following a hash sign is a comment. Python doesn't execute comments. They only exist to make your code more readable. # this script requires that you have a folder on your desktop called "capture" import os,time delay=60 # this number is measured in seconds. i=0 # i is a common variable used for loops. We'll use this in the infinite loop later. counter=0 while i<1: # this is an infinite loop! we never change the variable i, so i is always less than 1. # this script will run forever. You have to quit it with CTRL-Z. # see how everything inside this while loop is indented by one tab? # create a command that the Terminal will execute. screencapture is built into OSX. # str(counter) turns the integer "counter" into a string so that it can be added to the command string. # if you don't do this, Python will throw an error. # the -x option turns off the screenshot noise. # the -o option tells the OS where to save the captured image. # ~/Desktop is the command line shortcut to your Desktop. # this script will name the files capture.1.png, capture.2.png and overwrite those filenames in ~/Desktop/capture/ cmd='screencapture -x -o ~/Desktop/capture/capture.'+str(counter)+'.png' # have the OS execute the command. os.popen(cmd) # let the user know what you're doing by writing the command to the Terminal. print cmd # increase the file number by one. counter=counter+1 #wait a little bit. You've already defined delay up at the top of the script. time.sleep(delay) # this comment is outside of the while loop. # if our code were to continue, it would start here.