In the forums I found an approach in which snapshots are taken from a running video. Based on this idea, I tried to advance the movie frame by frame (play step forward lClip; see below). This has the disadvantage that it is rather slow because apparently the video frame has first to be drawn, which requires time, and thus one needs to wait a bit before playing the next frame.
However, it is not necessary to store the frames into external video files, as is done in the handler below. This handler is intended at the moment to just be a proof of concept for the frame extraction process. It would suffice in the final version to take snapshot and then analyze it, then move to the next frame.
Any clever ideas as to how to speed this up?
Cheers,
Olli.
Code: Select all
on lH_extractFrames pVideoPlayer, pNoOfFramesToExtract
-- figure out where the snapshot files shall be stored
answer folder "Where shall the images be stored?"
put it into lFolder
-- get rid of the control bar
set the showController of player pVideoPlayer to false
-- this variable will be used to produce unique names for the snapshot files
put 1 into lCount
repeat pNoOfFramesToExtract
-- move the player one frame forward
play step forward pVideoPlayer
-- wait so the frame can be drawn on the screen
wait 500 milliseconds
-- take a snapshot from the player and store it into a file
export snapshot from player pVideoPlayer to file (lFolder&"/"&"snapshot"&lCount&".png") as png
-- increase the file name counter
add 1 to lCount
end repeat
set the showController of player pVideoPlayer to true
end lH_extractFrames