# Video stimulus unusually slow

**URL:** <https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534>\
**Category:** Builder\
**Created:** [May 29, 2017, 11:52am UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534 "2017-05-29T11:52:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![davedey](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@davedey](https://discourse.psychopy.org/u/davedey)\
**Post date:** [May 29, 2017, 11:52am UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534/1 "2017-05-29T11:52:37Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![mdc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/mdc/32/3409_2.png) [@mdc](https://discourse.psychopy.org/u/mdc)\
**Post date:** [May 29, 2017, 10:49pm UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534/2 "2017-05-29T22:49:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![davedey](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@davedey](https://discourse.psychopy.org/u/davedey)\
**Post date:** [May 30, 2017, 3:19pm UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534/3 "2017-05-30T15:19:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mdc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/mdc/32/3409_2.png) [@mdc](https://discourse.psychopy.org/u/mdc)\
**Post date:** [May 30, 2017, 4:16pm UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534/4 "2017-05-30T16:16:56Z")

</div>

> [@davedey](#):
>
> It’s still curious why simply playing the video should cause such a serious lag.

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.

---

<div class="post-metadata">

**Author:** ![davedey](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@davedey](https://discourse.psychopy.org/u/davedey)\
**Post date:** [June 1, 2017, 3:04pm UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534/5 "2017-06-01T15:04:40Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [June 2, 2017, 10:39am UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534/6 "2017-06-02T10:39:53Z")

</div>

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

> [@mdc](#):
>
> Have you tried visual.movie3? I think that uses VLC as a backend.

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)

---

<div class="post-metadata">

**Author:** ![mdc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/mdc/32/3409_2.png) [@mdc](https://discourse.psychopy.org/u/mdc)\
**Post date:** [June 2, 2017, 2:15pm UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534/7 "2017-06-02T14:15:15Z")

</div>

Thanks Jon for clearing that up.

---

<div class="post-metadata">

**Author:** ![davedey](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@davedey](https://discourse.psychopy.org/u/davedey)\
**Post date:** [June 4, 2017, 7:38pm UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534/8 "2017-06-04T19:38:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [June 5, 2017, 4:40pm UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534/9 "2017-06-05T16:40:10Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![davedey](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@davedey](https://discourse.psychopy.org/u/davedey)\
**Post date:** [June 5, 2017, 7:43pm UTC](https://discourse.psychopy.org/t/video-stimulus-unusually-slow/2534/10 "2017-06-05T19:43:57Z")

</div>

Yes, indeed. Got it; thanks Jon! 🙂
