# Videos not loading properly on Chrome, Edge and Safari

**URL:** <https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506>\
**Category:** Online experiments\
**Created:** [April 17, 2020, 1:05pm UTC](https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506 "2020-04-17T13:05:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![f.cerpe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/f.cerpe/32/7594_2.png) [@f.cerpe](https://discourse.psychopy.org/u/f.cerpe)\
**Post date:** [April 17, 2020, 1:05pm UTC](https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506/1 "2020-04-17T13:05:26Z")

</div>

URL of experiment: [https://gitlab.pavlovia.org/f.cerpelloni/smi\_chrome](https://gitlab.pavlovia.org/f.cerpelloni/smi_chrome)

Hello all,

I created a small psychophysics experiment in which I present participants with videos of a visual and an auditory sitmuli.  
The experiment runs fine in Firefox, but on Chome, Edge and Safari presents issues with the video stimuli.  
The experiment itself runs, showing a following choice routine and the next iteration of the loop.  
In the psychopy experiment I made on Builder, there are two routines before and after the video routine with a static component of 1 second to allow loading of the video.  
All videos are .mp4.  
Does someone have the same issue or a possible solution for that?

Many thanks!

---

<div class="post-metadata">

**Author:** ![f.cerpe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/f.cerpe/32/7594_2.png) [@f.cerpe](https://discourse.psychopy.org/u/f.cerpe)\
**Post date:** [April 18, 2020, 4:07pm UTC](https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506/3 "2020-04-18T16:07:32Z")

</div>

EDIT: Sorry, I attached the wrong link. Here’s the pavlovia runable experiment [https://run.pavlovia.org/f.cerpelloni/smi\_chrome/html](https://run.pavlovia.org/f.cerpelloni/smi_chrome/html)

---

<div class="post-metadata">

**Author:** ![jonathan.kominsky](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jonathan.kominsky](https://discourse.psychopy.org/u/jonathan.kominsky)\
**Post date:** [April 18, 2020, 4:33pm UTC](https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506/4 "2020-04-18T16:33:27Z")

</div>

Odd. Edge I can understand, but something that works in Firefox but not Chrome is new to me. Most likely it has to do with something subtle about the video format. While they are all mp4, there are different ways to encode mp4s. There’s also this thread, which may be relevant: [Pavlovia experiment freezes during video playback](https://discourse.psychopy.org/t/pavlovia-experiment-freezes-during-video-playback/12290/5)

---

<div class="post-metadata">

**Author:** ![f.cerpe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/f.cerpe/32/7594_2.png) [@f.cerpe](https://discourse.psychopy.org/u/f.cerpe)\
**Post date:** [April 18, 2020, 6:52pm UTC](https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506/5 "2020-04-18T18:52:45Z")

</div>

The .play() and .stop() codes were necessary since the first trial. I previously added the .reset() part but didn’t seem to change much, probably one or two more conditions were displayed.

I also looked at [Pavlovia not playing movieStim](https://discourse.psychopy.org/t/pavlovia-not-playing-moviestim/11597) and [Pavlovia experiment freezes during video playback](https://discourse.psychopy.org/t/pavlovia-experiment-freezes-during-video-playback/12290)  
Stimuli in the current version are video encoded with MPEG-4. A previous try had h.264 encoded stimuli with the same results.

I made some adjustment during the day and it runs better in chrome, but it still skips a lot of stimuli, either video, audio, or both (around half).

---

<div class="post-metadata">

**Author:** ![jonathan.kominsky](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jonathan.kominsky](https://discourse.psychopy.org/u/jonathan.kominsky)\
**Post date:** [April 19, 2020, 1:12pm UTC](https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506/6 "2020-04-19T13:12:36Z")

</div>

Pavlovia is being difficult about letting me fork and test these, but I have two ideas you might try.

1. Move the “movie\_sim.play()” line to “each frame” instead of “begin routine”. The main reason for this is that the movie has not been drawn in the “begin routine” section of the code. If that doesn’t work, try removing it altogether, and leave only “reset” and “stop”.
2. Add a short delay before the start of the movie, say .1s. I have a suspicion that part of the issue might simply be a buffering issue, where it’s difficult for the browser to load and play the movie in the time window it has, so just giving it a little extra margin (if it doesn’t disrupt your experiment) might make it more consistent.

Otherwise, I don’t see any obvious reason this should have trouble. Is it now consistent about which movies it’s skipping or random every time?

---

<div class="post-metadata">

**Author:** ![f.cerpe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/f.cerpe/32/7594_2.png) [@f.cerpe](https://discourse.psychopy.org/u/f.cerpe)\
**Post date:** [April 19, 2020, 1:52pm UTC](https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506/7 "2020-04-19T13:52:24Z")

</div>

I tried both your options but unfortunately they didn’t work.

What helped me a bit was extending the duration of the movie component from 1 sec (video duration) to 1.2 secs. This resolved audio issues.  
I’m currently updating a new version with different attempts ([https://run.pavlovia.org/f.cerpelloni/sequential/html](https://run.pavlovia.org/f.cerpelloni/sequential/html)).

The probable cause of the issue is refresh rate. The video is composed of a fixation point and a gabor that flashes (1 frame duration) either left or right. In the missed trials, the fixation point is still displayed, the audio works, but the flash is skipped.

Also, errors are not consistentin which movie is skipped

---

<div class="post-metadata">

**Author:** ![f.cerpe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/f.cerpe/32/7594_2.png) [@f.cerpe](https://discourse.psychopy.org/u/f.cerpe)\
**Post date:** [April 19, 2020, 4:44pm UTC](https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506/8 "2020-04-19T16:44:43Z")

</div>

In addition to that, in pyschopy I use a routine “pre” with a static component ISI, and the movie file is set during that interval, but it’s not mentioned in the .js file. I tried extending it and moving it to the same routine as movie, but it doesn’t affect the visual part of the movie

---

<div class="post-metadata">

**Author:** ![jonathan.kominsky](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jonathan.kominsky](https://discourse.psychopy.org/u/jonathan.kominsky)\
**Post date:** [April 19, 2020, 7:41pm UTC](https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506/9 "2020-04-19T19:41:46Z")

</div>

Yeah, this seems like an issue of how movies are played in browsers. It may not be possible for a browser to play a movie file with frame-level precision. However, in principle, you could get PsychoPy to display the object and play the sound with its own built-in tools rather than making it a bunch of separate image files. Did you already try this and find that it got desynced? Is there are a reason you need these as movie files in particular?

---

<div class="post-metadata">

**Author:** ![f.cerpe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/f.cerpe/32/7594_2.png) [@f.cerpe](https://discourse.psychopy.org/u/f.cerpe)\
**Post date:** [April 19, 2020, 8:01pm UTC](https://discourse.psychopy.org/t/videos-not-loading-properly-on-chrome-edge-and-safari/12506/10 "2020-04-19T20:01:55Z")

</div>

I’m not attached to movies per se, however I tried using polygons and audio components but I had more issues in displaying them and checking for synchronization.  
At this point I have to give up. Fortunately on firefox I don’t have all these issues, so I will probably just put it as a requirement.  
Thank you
