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

**URL:** <https://discourse.psychopy.org/t/error-with-demo-code-moviestim2-on-psychopy-1-90-3-on-windows-os/5417>\
**Category:** Coding\
**Tags:** movies\
**Created:** [September 27, 2018, 1:31am UTC](https://discourse.psychopy.org/t/error-with-demo-code-moviestim2-on-psychopy-1-90-3-on-windows-os/5417 "2018-09-27T01:31:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zoubochao](https://avatars.discourse-cdn.com/v4/letter/z/ee7513/32.png) [@zoubochao](https://discourse.psychopy.org/u/zoubochao)\
**Post date:** [September 27, 2018, 1:31am UTC](https://discourse.psychopy.org/t/error-with-demo-code-moviestim2-on-psychopy-1-90-3-on-windows-os/5417/1 "2018-09-27T01:31:46Z")

</div>

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.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![yh-luo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/yh-luo/32/2098_2.png) [@yh-luo](https://discourse.psychopy.org/u/yh-luo)\
**Post date:** [September 28, 2018, 8:56am UTC](https://discourse.psychopy.org/t/error-with-demo-code-moviestim2-on-psychopy-1-90-3-on-windows-os/5417/2 "2018-09-28T08:56:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zoubochao](https://avatars.discourse-cdn.com/v4/letter/z/ee7513/32.png) [@zoubochao](https://discourse.psychopy.org/u/zoubochao)\
**Post date:** [September 29, 2018, 2:03am UTC](https://discourse.psychopy.org/t/error-with-demo-code-moviestim2-on-psychopy-1-90-3-on-windows-os/5417/3 "2018-09-29T02:03:17Z")

</div>

Hi Yuhan,

thank you for your reply.

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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![yh-luo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/yh-luo/32/2098_2.png) [@yh-luo](https://discourse.psychopy.org/u/yh-luo)\
**Post date:** [September 29, 2018, 7:15am UTC](https://discourse.psychopy.org/t/error-with-demo-code-moviestim2-on-psychopy-1-90-3-on-windows-os/5417/4 "2018-09-29T07:15:53Z")

</div>

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.,

```python
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

---

<div class="post-metadata">

**Author:** ![zoubochao](https://avatars.discourse-cdn.com/v4/letter/z/ee7513/32.png) [@zoubochao](https://discourse.psychopy.org/u/zoubochao)\
**Post date:** [October 8, 2018, 9:23am UTC](https://discourse.psychopy.org/t/error-with-demo-code-moviestim2-on-psychopy-1-90-3-on-windows-os/5417/5 "2018-10-08T09:23:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yh-luo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/yh-luo/32/2098_2.png) [@yh-luo](https://discourse.psychopy.org/u/yh-luo)\
**Post date:** [October 9, 2018, 11:25am UTC](https://discourse.psychopy.org/t/error-with-demo-code-moviestim2-on-psychopy-1-90-3-on-windows-os/5417/6 "2018-10-09T11:25:51Z")

</div>

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

> [@Frame drop causing Audio/Video lag with moviestim3](https://discourse.psychopy.org/t/frame-drop-causing-audio-video-lag-with-moviestim3/3800/12):
>
> I don’t think the rescaling at render time will itself make a difference to rendering speed, but it does mean that you could resize your stimuli in advance to be that size and THAT will make a big difference. Note that the key to speed here is not the size of the image in Mb (that’s a matter of how much the codec is compressing your images). The key is the size of the image in pixels because that determines how many values have to be passed to the graphics card by PsychoPy. For example: an RG…

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