Previous topic

Line

Next topic

PatchStim - the main stimulus class for presenting images

This Page

Quick links

MovieStim

class psychopy.visual.MovieStim(win, filename='', units='pix', size=None, pos=(0.0, 0.0), ori=0.0, flipVert=False, flipHoriz=False, opacity=1.0, name='', loop=False, autoLog=True, depth=0.0)

A stimulus class for playing movies (mpeg, avi, etc...) in PsychoPy.

Example:

mov = visual.MovieStim(myWin, 'testMovie.mp4', flipVert=False)
print mov.duration
print mov.format.width, mov.format.height #give the original size of the movie in pixels

mov.draw() #draw the current frame (automagically determined)

See MovieStim.py for demo.

Parameters :
win :

a Window object (required)

filename :

a string giving the relative or absolute path to the movie. Can be any movie that AVbin can read (e.g. mpeg, DivX)

units : None, ‘height’, ‘norm’, ‘cm’, ‘deg’ or ‘pix’

If None then the current units of the Window will be used. See Units for the window and stimuli for explanation of other options.

pos :

position of the centre of the movie, given in the units specified

flipVert : True or False

If True then the movie will be top-bottom flipped

flipHoriz : True or False

If True then the movie will be right-left flipped

ori :

Orientation of the stimulus in degrees

size :

Size of the stimulus in units given. If not specified then the movie will take its original dimensions.

opacity :

the movie can be made transparent by reducing this

name : string

The name of the object to be using during logged messages about this stim

loop : bool, optional

Whether to start the movie over from the beginning if draw is called and the movie is done.

draw(win=None)

Draw the current frame to a particular visual.Window (or to the default win for this object if not specified). The current position in the movie will be determined automatically.

This method should be called on every frame that the movie is meant to appear

loadMovie(filename)

Load a movie from file

Parameters :
filename: string

The name of the file, including path if necessary

Brings up a warning if avbin is not found on the computer. After the file is loaded MovieStim.duration is updated with the movie duration (in seconds).

pause()

Pause the current point in the movie (sound will stop, current frame will not advance). If play() is called again both will restart.

play()

Continue a paused movie from current position

seek(timestamp)

Seek to a particular timestamp in the movie. NB this does not seem very robust as at version 1.62 and may cause crashes!

setAutoDraw(val)

Add or remove a stimulus from the list of stimuli that will be automatically drawn on each flip

Parameters :
  • val: True/False

    True to add the stimulus to the draw list, False to remove it

setMovie(filename)

See ~MovieStim.loadMovie (the functions are identical). This form is provided for syntactic consistency with other visual stimuli.

setOpacity(newOpacity, operation='')

Sets the opacity of the movie to newOpacity

stop()

Stop the current point in the movie (sound will stop, current frame will not advance). Once stopped the movie cannot be restarted - it must be loaded again. Use pause() if you may need to restart the movie.