Capture camera output

i want to make a little video of my animations and i like to capture the output of a camera.
Can anyone point me to a script or to a function that makes screenshots or videos of a camera?

Drop this script into your camera

You can then join the frames together into a video using, say, ffmpeg.