#!/usr/bin/env pf # sample program to do averaging recording # create variables (with undefined contents) variable accum variable frames variable movie # print usage message : usage cr "ERROR: invalid number of arguments. USAGE:" . cr "\ttimelapse.pf " . cr cr ; : check-args args@ size 4 = not if usage 255 exit then unpack drop # skip script name (arg 0) >int 2 max frames ! >int 2 max accum ! movie ! "file = " . movie @ . .n "speedup = " . accum @ . .n "frames = " . frames @ . .n ; check-args # create object symbol binders (binders [word] are compile only) load-blit # load a default 'blit' word load-grab # load a default 'grab' word load-lqt # load quicktime support load-image # load image conversion support # make lqt recorder mov-recorder mov movie @ mov create : record >i420 mov record ; : finish mov close ; 1.0 accum @ >float / variable! scale : grab-scaled grab scale @ * ; # ( -- image ) : output dup record blit ; # ( image -- ) # : output record ; 0 variable! count : count++ count @ dup 1 + count ! ; : mainloop frames @ for grab-scaled "Frame " . count++ . ": ." . accum @ 1 - for "." . grab-scaled + next output "\n" . next finish "Done.\n" . ; mainloop