[id] = GetVideoFrame(brushid, frame, videoid[, unit])
The optional argument
unit is used to specify how the value passed
frame should be interpreted. If
unit is set to 0, then the value
frame is interpreted as an absolute frame index. This is also
the default setting. If
unit is set to 1, then the value passed in
is interpreted as a time stamp in milliseconds and
grab the frame at this very timestamp. It is recommended to use unit 1
access to single frames because this is usually much faster. If you really
need to access single frames by their absolute index, please read the word
of warning below.
Please note that frame access by absolute index is usually a very expensive
operation because, for most video formats, Hollywood needs to traverse all
the way through the stream until it reaches the requested frame. Such a
traversal requires a lot of time and is thus of limited practical use. However,
there is one special case where
GetVideoFrame() can be used very efficiently and that is the sequential
grabbing of frames from a video stream. "Sequential grabbing" means that
you read one frame after the other from the video stream, i.e. first
frame 1, then frame 2, then frame 3, etc. This can be done very quickly.
The only thing that will take lots of time is reading frames in backward
direction (i.e. frame 10, frame 9, frame 8, etc.), or making huge leaps
between frame reads (i.e. frame 1, then frame 1000, then frame 5000, etc.).
This will take a lot of time. Sequential reading will be efficient,
To find out the exact number of frames inside a video stream, you can use the
GetAttribute() command and query the
#ATTRNUMFRAMES attribute using the
#VIDEO object type.
my_frame = GetVideoFrame(Nil, 1, 2) DisplayBrush(my_frame, #CENTER, #CENTER)The code above extracts frame 1 from video stream 2 and stores it in a new brush. The brush is then displayed at the center of the display.