Capturing video (or at least one frame) inside Rev

Karl Petersen karlpet at
Thu May 16 10:36:01 EDT 2002

At 1:25 PM +0100 5/16/02, Ben Rubinstein wrote:
>Given a QuickTime-recognised video source, is there a built-in way in Rev to
>capture a frame and save it out as a file, named under program control?

This will capture any portion of the stack window:
   import snapshot from rect <playerRect> of window <yourWindowID>

As in this context:
   reset the templateImage
   put the windowID of this stack into winID
   set the name of the templateImage to "frameCapture"
   put the rect of player "your player name" into tFrameRect
   -- Adjust your frame edges here to remove borders, if required
   -- So the new image doesn't jump, force the new image to match the
   -- rect of frame being copied.
   -- Note the templateImage rect must fit within the rect of this card.
   set the rect of the templateImage to tFrameRect
   import snapshot from rect tFrameRect of window winID
   export image "frameCapture" to file "frameSample.JPEG" as JPEG
   -- or use this to export:
   -- export image nameOfSnapImage() to URL ("binfile:" & 
<yourFilePath>) as JPEG
   delete image "frameCapture"

Unfortunately, when that script exports the captured frame to a JPEG 
file, Rev refuses to relinquish the temporary memory it grabs, 
eventually causing your program to crash. If you can find a 
workaround for that problem, "import snapshot" should work nicely. 
(I've tested the memory problem only in Mac OS 9.1.)


More information about the use-livecode mailing list