Psychopy runs slow when using movies

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2020.2.10
Standard Standalone? (y/n) If not then what?:y
What are you trying to achieve?: displaying multiple movies, 3 blocks of 5 clips. each clip is about 5 minutes. mp4 files

What did you try to make it work?: I added a movie component in a loop

What specifically went wrong when you tried that?: the experiment runs very slowly. when I press it takes about 10 seconds to load the first introduction slide. when starting each video file, it needs about 5 seconds before it appears on screen and really starts playing.

How large are the movies? Both in file-size and resolution.

resolution: 1920x1080 30 frames per second
file size: varying from 300 mb to 1 gb

Hi mariette.

So I’ve been experiencing the exact same thing. I’m just using 400kb movies and it takes a while for them to load each trial. I’ve tried a million things, including changing movie formats, codecs, resolutions, etc. I’ve noticed that if i use “constant” instead of “set every repeat” in the movie component, the movies actually run fine. However, I realize that that might not be an ideal solution. Hoping to hear if anyone has any other solutions.

That’s really useful information. If you set the movie to constant and then update it in code at a point where you don’t mind a short delay (e.g. just after the previous trial), then you should get the behaviour you’v looking for.

I’m having a hard time updating a movie component that is set to “constant”. Even if I ask him in the next routine (following the previous trial) to update the filename of the movie, the next trial will display the same movie. Can you elaborate further?

Try movieComponentName.setMovie(fileNameVariableWithPath)

Thanks! It works, but now it moves my loading time to just before the routine where I have the code setting the new video. So, i see the first video (first trial) ok, but transitioning to the following routine (in this case the response screen) where i have a code chunk specifying the new movie name for the following trial, it takes 3s. So in the end I just moved this problem from on place to the other. Which still doesn’t work for me. :\

Hello,

loading times of videos seem to be a problem currently.

If you set the movie to constant, it will be preloaded at the beginning of the experiment. Thus no delay in the movie-routine.

You could insert an ISI-component at the beginning of the relevant routine. This ISI-component should last as long as the loading usually takes. Then you select the option to load a particular movie during this ISI-period. There should be no other components starting or running during the ISI-period. Notice, that the ISI-component does not accelerate loading. It is just that no other components interfere with loading the movie.

Best wishes Jens

thanks for the quick replies!

The movieComponentName.setMovie(fileNameVariableWithPath) does not work here. I get the message NameError: name ‘xxxx’ is not defined. What do I do wrong?

Hello Jens,

Thanks for the idea. It helps somewhat. Although it still forces me to have an ISI of >3s to account for movie loading. Ideally, to make the experiment shorter I wanted 1s inter-trial intervals at most. However, i recognize that this might just be impossible at the moment even with 400kb movie files. Strangely enough this whole issue just happens in some pcs but not others (regardless of computer power). Anyway, I’ll have to wait for a fix. Hopefully soon.

Thanks,
Fábio

Thanks Jens for replying.

I am not sure I completely understand you ( I am only a psychopy novice).
I inserted an ISI-component, but this doesn’t change the experiment. Participants will still see a black screen for a couple of seconds while waiting for the movie to start. Or did I understand you wrong?

Hi Falexs,

I tried switching from ‘set every repeat’ to ‘constant’ and indeed the movies run fine then. Thank you for mentioning this.
As I only have 15 movie clips, I could insert 15 movie components. but then, I don’t know how to randomise these. any ideas?

You could create a random list at the begging of your experiment with the video paths.
For instance:
list_paths = ['video1.mp4', 'video2.mp4'] then shuffle(list_paths).
Each movie would have an entry of the list as its movie path. For instance, movie1 would have list_paths[1] as its movie stimulus, movie2 component would have list_paths[2] and so on.
The important thing is to set the list_paths and randomization at the begging of the experiment so it can load before the movie components set their paths. Try to see if this works. :slight_smile:

Hello Mariette

as a matter of fact that is the intention of the ISI-component. The computer does nothing except loading stimuli if you instruct it do.

Notice that by preloading the videos at the beginning of experiment, you simply shift the loading delay to the beginning of the experiment. The run of experiment might be smoother though.

Best wishes Jens