psychopy.org | Reference | Downloads | Github

Video stimulus unusually slow

Hello everyone,

I am using PsychoPy2 v1.85.1 on a Mac.

I am trying to use a video stimulus, with the setup that once the video plays in its entirety, PyschoPy should move on to the next routine. I am having some difficulties getting the video to play as intended. I have tried using various backends for movie playback, and each seem to have their own quirks in my environment:

moviepy: the video plays smoothly, but much slower compared to its original speed. The audio component plays at normal speed and stops, while the video plays much slower (past when the audio has stopped - i.e. audio and video are out of sync). The experiment then progresses to the next routine as intended.

avbin: the video plays at correct speed, but is choppy. Audio and video are in sync. However, when the video finishes playing, PsychoPy hangs, and I have to ‘Force Quit’ the experiment.

opencv: the video also plays at correct speed, but is extremely choppy (far greater choppiness than avbin). However, after the video finishes playing, the experiment does proceed to the next routine as intended.

At this point, I am unsure regarding how to get the system to play the movie at a correct speed. Am I missing something obvious? I would really appreciate any help. Thanks a lot in advance!

Cheers,

  • Dave

EDIT:
I have now checked my setup with multiple computers (both PC and Mac), and unfortunately this issue continues to persist. I am fairly certain that processing power is not the issue as I have tested with relatively powerful computers (>16GB RAM, dedicated graphics card, etc.).

To delve deeper, I looked into the initial configuration report, and didn’t find any sub-optimal values in the visual section:

openGL version	4.5.0 NVIDIA 382.33	
openGL vendor	NVIDIA Corporation	
screen size	1536 x 864	
have shaders	True	
visual sync (refresh)	33.78 ms/frame	during the drifting GratingStim
refresh stability (SD)	0.17 ms	SD < 0.5 ms is ideal (want low variability)
no dropped frames	0 / 180	during DotStim with 100 random dots
openGL max vertices	1048576	
GL_ARB_multitexture	True	
GL_EXT_framebuffer_object	True	
GL_ARB_fragment_program	True	
GL_ARB_shader_objects	True	
GL_ARB_vertex_shader	True	
GL_ARB_texture_float	True	
GL_ARB_texture_non_power_of_two	True	
GL_STEREO	False

I cannot seem to find a solution at this point. Any help would be much appreciated!

Hello davedey,

Having the issue across multiple computers/OS is unsettling. Have you tried playing a different video file, possibly with another codec? Just to rule out the video file/codec is causing the unexpected behavior.

Hi mdc,

Thanks a lot for the response! Good point - I haven’t done that. I will do that this evening and get back to you.

It’s still curious why simply playing the video should cause such a serious lag. But I’ll attempt to rule it out as you suggested.

Not sure, but we need to rule out it’s not a codec issue. Have you tried visual.movie3? I think that uses VLC as a backend.

Okay, I have now had the time to do some more debugging. The video container or codec wasn’t the issue.

It turns out that the screen size was scaled. Although the videos were shot in full HD (1920x1080), I was running the experiment in the resolution of my external monitor, which was 2560x1440. I believe this put a very heavy load on PsychoPy to scale the video to the correct resolution. The video played just fine in h.264 mp4 and moviepy backend at the native resolution.

Problem solved! Thanks a lot for the help though, mdc!

Glad this is solved. Quick point of info on Matthew’s comment:

movie2 uses VLC for just the sound component of movie files (it uses ffmpeg for the visual stream in the file)
movie3 uses moviepy, which in turn uses soundfile, for loading audio (doesn’t use VLC for anything)

Thanks Jon for clearing that up.

Hi Matthew/Jon,

Just a quick follow-up question for future reference:

How can I ensure that PsychoPy is using visual.movie3? Is there a way to specify that using the GUI?

Although the video is playing much more smoothly than before, as I continue to develop my experiment, I am noticing that there is still a minor choppiness (which I can neglect for my experiment, but would be nice to get rid of after all).

I looked at the output and there are a few warning messages saying that MovieStim2 dropped a number of video frames.What is the correct way to make it use visual.movie3/MovieStim3? I was wondering if I missed something obvious.

In Builder (I assume that’s what you mean by “the GUI”) the choice of Movie3 is determined by setting the “backend” to be moviepy

Yes, indeed. Got it; thanks Jon! :slight_smile: