MemoryError when playing MovieStim with Sound

Hi all - please see my current issue below.

OS (e.g. Win10): Windows 10
PsychoPy version (e.g. 1.84.x): 3.03
Standard Standalone? (y/n) Yes
What are you trying to achieve?: Play a movie with sound in experiment

What did you try to make it work?:

I have 3 routines in my experiment with movie stimuli - each of the stimuli have their backend set to “moviepy”. The experiment works as is on my mac (same PsychoPy 3.03 standalone version) but when I transferred it over to this Windows 10 machine I get the error below. Given the message is about audio, I tried ticking the “No Audio” box of each movie stimulus - and it works! All 3 movies play (one is a .wmv, two are .mp4’s) and I get no errors.

Unfortunately I’d really like to have the sound play. I did some searching and couldn’t find a solution to this problem, a related suggestion I tried was changing the “audio library” to each of the options individually (the default is “[‘sounddevice’, ‘pyo’, ‘pygame’]”), but no luck. Any advice or troubleshooting would be great! If you need more info let me know and I’ll try and get back ASAP.

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.

Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\visual\movie3.py”, line 187, in loadMovie
self._mov.audio.to_soundarray(),
File “”, line 2, in to_soundarray
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\moviepy\decorators.py”, line 54, in requires_duration
return f(clip, *a, **k)
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\moviepy\audio\AudioClip.py”, line 117, in to_soundarray
nbytes=2, chunksize=buffersize))
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\numpy\core\shape_base.py”, line 234, in vstack
return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
MemoryError

During handling of the above exception, another exception occurred:

File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\visual\movie3.py”, line 135, in init
self.loadMovie(self.filename)
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\visual\movie3.py”, line 196, in loadMovie
jwe_tmp.audio.to_soundarray(),
File “”, line 2, in to_soundarray
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\moviepy\decorators.py”, line 54, in requires_duration
return f(clip, *a, **k)
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\moviepy\audio\AudioClip.py”, line 117, in to_soundarray
nbytes=2, chunksize=buffersize))
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\numpy\core\shape_base.py”, line 234, in vstack
return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
MemoryError

Still looking for help here if anyone has advice!

1 Like

Hi,
Since the error indicated that you have run out of memory in your RAM,
how much RAM is installed in the Mac and in the windows machine?
It is possible that the error is caused by insufficient RAM of the windows machine.

Thanks for the suggestion - I don’t think it’s a limited RAM problem as the Mac that it works on has 8 GB of RAM and the Windows 10 machine has 16 GB.

Though the situation seemed to be caused by sounds, the error message was related to visual stimuli. It’s really werd…
I’ve encountered errors of sounddevice due to different sampling rate of the files.
Can you confirm the audio sampling rate of the videos?

One video’s audio sampling rate is 48000 Hz, the other is 44100 Hz - perhaps this is why? Is there any easy way to change the audio sampling rate of a video?

I used Shotcut to set the sampling rate of videos. You can use any video editor software to do that.
Though I’m not 100% sure that will solve the issue, it’s still a good practice to use the same sampling rate for the sounds.