Playing small videos takes 10 sec to load

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2021.2.3
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?: Play a video, then collect keyboard response

What did you try to make it work?:
My videos are quite small (1-2 sec long; under 10 mb, most 4-5 mb). However, on each trial of the loop, it takes 10-11 sec before the video plays. There is nothing else going on in the experiment besides playing the video and collecting a single key press response at the end of each video.

I read a number of other related threads. Some suggestions provided include (which don’t work for me):

  • Set movie object to “constant” and include the list of videos in the code - but I have many different lists, all containing different sets of videos, so this does not scale well.
  • Insert an intentional ISI before each trial which lasts as long as the loading takes - but the loading is so long, it is far longer than any plausible ISI that I want. (I can only include two links, so here it is in plain text: https://discourse.psychopy.org/t/loading-times-for-routines-with-videos-are-slow/23789/2)

This suggestion about running the experiment in the resolution of the videos (which is 720 x 576) rather than the monitor’s resolution (which is 1920 x 1080) seemed promising, but I couldn’t figure out how to change that in the experiment.

So, any suggestions on how to reduce the huge loading lag for these relatively small videos (or how to change the resolution of the experiment so it matches that of the videos, if people think that might work), is much appreciated!

I am having the same issue. I have over almost 200 videos so using the “constant” option doesn’t work for me either.

Others have said that this issue is computer-specific, so I’m going to try running the experiment on a different computer to see if this fixes the lag at all.

I’m wondering why there isn’t any other “pre-compile” option for experiments like ours, so that we won’t experience delays in our trials.

Hopefully someone can come through with a solution for us both

I just dove into this a bit. Profiling an experiment showed that my code was spending a lot of time in win.getActualFrameRate: psychopy/movie3.py at 879376afbdc325c92ddf775f7a6e9e421fe48fc0 · psychopy/psychopy · GitHub

This happens when win._monitorFrameRate isn’t defined at the moment the MovieStim instance is created. Sadly, there’s what seems to be a small bug in the window constructor: it only sets the frame period and not its rate, so that variable _monitorFrameRate isn’t set by calling getActualFrameRate. See: psychopy/window.py at 0d21ea0a32040625966419fd8bfb7d3d6878ec45 · psychopy/psychopy · GitHub
This in turn means that for every movie stimulus you create, you will be polling the screen again, and again, and again, and this caused much of the delay in my experiment. The issue would be resolved by setting the _monitorFrameRate when calling getActualFrameRate, or you can illegally set the internal instance variable _monitorFrameRate yourself as a dirty hack.

Window does set _monitorFrameRate if it was created with checkTiming as True - so I’m guessing the problem here is that this is False for your windows. Though, the point of this parameter is to avoid calling getActualFrameRate, so I don’t see any reason why getActualFrameRate can’t set _monitorFrameRate to avoid unnecessary future calls to the function, so I’ll look into changing that. Thanks for catching this!

1 Like