psychopy.org | Reference | Downloads | Github

Error with demo code moviestim2 on psychopy 1.90.3 (on windows OS)

movies

#1

StandalonePsychoPy2-1.90.3-win32 installed on 64bit window 10

cv2 and vlc installed

moviestim2 can run, but the error occured when press stop or pause.

moviestim2 is needed for my experiment because moviestim3 response slowly when playing movie forward or backward.

Does anyone have any ideas on this? really appreciate it.

Traceback (most recent call last):
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\demos\coder\stimuli\MovieStim2.py", line 72, in <module>
    if mov.status in [visual.PLAYING, visual.PAUSED]:
AttributeError: 'module' object has no attribute 'PAUSED'
Exception WindowsError: 'exception: access violation reading 0x00000028' in <bound method MovieStim2.__del__ of <psychopy.visual.movie2.MovieStim2 object at 0x201524B0>> ignored

#2

Hi,

Can you try using MovieStim3? It’s newer and may be less problematic.
My experiments used MovieStim3 to play videos and it worked without problems with sounddevice as the sound backend.

Yuhan


#3

Hi Yuhan,

thank you for your reply.

however, with MovieStim3, I got this below error when moviestim run several trials

Traceback (most recent call last):
  File "D:\Research\PsychoPy2实验\AcqExp.py", line 634, in <module>
    depth=0.0,
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\visual\movie3.py", line 134, in __init__
    self.loadMovie(self.filename)
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\visual\movie3.py", line 194, in loadMovie
    jwe_tmp.audio.to_soundarray(),
  File "<decorator-gen-72>", line 2, in to_soundarray
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\audio\AudioClip.py", line 114, in to_soundarray
    chunksize=buffersize))
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\numpy\core\shape_base.py", line 237, in vstack
    return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
MemoryError

#4

Hi,
The error message indicated that the program is running out of memory.
It may relate to the size of videos, because videos require much larger memory than images.
Here’s some possible solutions:

  • Close other applications when running the experiment to decrease the memory usage.
  • Use “smaller” videos. If the original videos are 1280x1024 or something like that, transform them to lower resolution, like 640x480, may help.
  • Delete the used MovieStim3 objects. If the videos will not be used again. Try to delete them after playing to release memory. e.g.,
    timer = core.Clock()
    vid1 = visual.MovieStim3(win, "video1.mp4")
    dur = vid1.duration
    # play the video
    timer.reset()
    vid1.play()
    while timer.getTime() <= dur:
        vid1.draw()
        win.flip()
    # remove the video to release memory
    del vid1
    
  • Increase the RAM of your computer (My computer has 16GB of RAM)

Hope that helps!
Yuhan


#5

Hi Yuhan
my pc also has 16GB RAM and the size of all my videos adds up to about 256M,


#6

Hi,
The memory usage is not the sum of the video size. It’s the resolution that matters.

If you don’t find a way to release the memory occupied by the MovieStim objects (or add more memory), Python will crash.