# this is the basic glue script for running as a LiVES's effects script # open streams 1 "" "w" stream-open-fd constant stdout 2 "" "w" stream-open-fd constant stderr stdout >output # utility & lives protocol 0x0001 constant cap-fast 0x0002 constant cap-may-resize 0x8000 constant cap-reserved variable directory variable in-ext variable out-ext variable frame "current frame" , variable nb_frames "total number of frames" , variable width variable height : name-out "%08d" % out-ext @ + ; # convert number to filename : name-in "%08d" % in-ext @ + ; # ( num - filename ) : a args pop ; "pop one input argument" , : .debug stderr >output dup . .n output> drop ; "copy top of stack as debug message to stderr" , : check-pause "./pause" exists if 1000. sleep pass check-pause then ; "sleep if ./pause file exists" , : write-status "./.status" "w" stream-open-file >output frame @ . .n output> stream-close ; "write current frame to ./.status file" , : get-process-args a directory ! a in-ext ! a out-ext ! a int dup frame ! # set start frame a int swap - 1 + nb_frames ! # and nb frames from start and endi a int width ! a int height ! ; : interpret-args a drop a symbol interpret ; "interprete script args as a command from lives" , : next-frame frame dup @ 1 + swap ! ; : read-frame frame @ name-in import-jpeg image ; "( -- image )\tRead current input frame an convert to internal image type." , : write-frame bitmap frame @ name-out 75 export-jpeg ; "( image -- )\tConvert to standard bitmap and write current output frame." , defer iterator "user defined frame iterator object" , defer processor "user defined frame processor object" , : ack-process width @ . .s height @ . .n ; : process get-process-args directory @ chdir # first you should chdir to iterator # run the user defined iterator ack-process ; # some iterators # simply map input to output through xt : iterator-map nb_frames @ for check-pause write-status read-frame processor # this user defined processor write-frame next-frame next ; "default iterator: iterates over all images in sequence" , # :noname ; processor # default: do nothing # ' iterator-map iterator # default: basic mapping iterator