A class implementing a general video stimulus.
This class uses a background thread for playing the video! According to the Pygame documentation MPEG-1 movies are supported. However, it seems that Pygame’s video support is quite limited and poor.
When the audio from the video should be played as well, the audiosystem has to be stopped (by calling expyriment.control.stop_audiosystem() ) BEFORE the video stimulus is preloaded! After the stimulus has been played the audiosystem can be started again (by calling expyriment.control.start_audiosystem() ).
When showing videos in large dimensions, and your computer is not fast enough, frames might be dropped! When using Video.wait_frame() or Video.wait_end(), dropped video frames will be reported and logged.
This module will be exchanged with a more capable one in the long run.
Methods
Create a video stimulus.
Parameters : | filename : str
position : (int, int), optional
|
---|
Return a deep copy of the stimulus.
Getter for filename.
Advance playback position.
This will not forward immediately, but play a short period of the beginning of the file! This is a Pygame issue which we cannot fix right now.
Parameters : | seconds : int
|
---|
Property to get the current frame.
Property to check if movie has audio.
Property to check if movie has video.
Getter for id.
Property to check if movie is playing.
Getter for is_preloaded.
Property to get the length of the movie.
Pause the video stimulus.
Play the video stimulus from the current position.
Getter for position.
Preload stimulus to memory.
Play the video and present current frame.
This method starts video playback and presents a single frame (the current one). When using OpenGL, the method blocks until this frame is actually being written to the screen.
Rewind to start of video stimulus.
Property to get the resolution of the movie.
Stop the video stimulus.
Property to get the current playback time.
Unload stimulus from memory.
This removes the reference to the object in memory. It is up to the garbage collector to actually remove it from memory.
Update the screen on each new frame.
Wait until video has ended and constantly update screen.
Notes
This will also check for control keys (quit and pause). Thus, keyboard events will be cleared from the cue and cannot be received by a Keyboard().check() anymore! If keybaord events should not be cleared, a loop has to be created manually like:
movie.present()
while movie.is_playing:
movie.update()
key = exp.keyboard.check()
if key == ...
Wait until certain frame was shown and constantly update screen.
Parameters : | frame : int
|
---|
Notes
This function will also check for control keys (quit and pause). Thus, keyboard events will be cleared from the cue and cannot be received by a Keyboard().check() anymore! If keybaord events should not be cleared, a loop has to be created manually like:
movie.present()
while movie.is_playing:
movie.update()
key = exp.keyboard.check()
if key == ...