Video stimuli not resetting to beginning in online experiment

URL of experiment: https://pavlovia.org/gareth/pvt2

Description of the problem: I’m trying to implement a psychomotor vigilance test, which works in PsychoPy locally, but not when I try to run it online. In each trial the stimulus is a video of a stopwatch counting up to 5 secs, and the participant has to respond as quickly as possible.

Locally this works fine, with the stopwatch resetting on each trial, but online the stopwatch never resets, so after a few trials it just presents the final frame of the video as a still.

Previously I’ve had problems with setting the dimensions of the video but this seems to work OK now.

Any ideas?

Thanks,

Gareth

I encountered the same problem! I did not manage to restart the videos but I solved it by copying the video into multiple files so that each time a new video file has to be loaded…

1 Like

Thanks @scd we’ll look into this. There’s probably something like a seek(0) that needs to be added when the same video is reloaded @apitiot

Thanks to both of you for your advice. It looks like duplicating the video file would be a good workaround (@scd) , but I’ll hang on to see whether a quick fix is on the cards (@jon).

Much appreciated!

Hey Gareth, did you manage to get the PVT up and running online? Would be interested!

Actually, although we haven’t had a chance to get in an d fix the reset() command, another user pointed out there is where you include a nameOfMovie.stop() in an End Routine Code Component. Easier (and less heavy on the download) than duplicating movies

No I never got round to it; I shifted to an alternative for the time being. I will probably try again next time I have a project that needs it - it wouldn’t need much doing to get it finished.

Gareth

Hi Jon,
Can you explain a bit more about this solution? I am having the same problem, and duplicating movies would mean I would need about 260 video files for participants.
Thanks,
Sam

If you have a movie component called myMovie then add a Code Component to your Routine with this in the End Routine code block:

myMovie.stop()

Thanks for the reply, I have tried this, as well as adding nameOfMyMovie.play(); at the start routine block (tried with both .stop only, .play only and both, both works best):

Begin routine: movie.play();
End routine movie.stop();

This sort of changes things, however the videos now start sometimes in the middle, or sometimes at the start, and then play to the end, and then show the start again if they began in the middle. My movies runs for 3.75s
Is there anything I can add to make it start the video at 00ms?

That’s weird. movie.stop() should implicitly reset the movie as well.
There is also a seek function that you might be able to make use of:

myMovie.seek(0)

Make sure you put that in a code component below the movie itself so that it does teh seek after loading the movie from file.

Yes. I have have been successfully using something similar as a workaround, until a fixed version of the Builder is available.

Assuming you have a movie called myMovie, add a single code component below it, with:

Begin routine: myMovie.play();
End routine: myMovie.seek(0);

This ensures that the movie resumes at its beginning on its next presentation. But has the limitation of requiring the movie to start only at the beginning of a trial, which may not allow enough time for the movie time to pre-load before its first presentation, leading to slight timing errors.

Couldn’t you do something like the following…?

Begin Routine
moviestarted=0

Each Frame
if t > .5 and moviestarted == 0:
     moviestarted = t
     myMovie.play()

End Routine
myMovie.stop()
myMovie.seek(0)

Best wishes,

Wakefield

@jon @d.govan @wakecarter
Thanks for the replies. Movie.seek(0) works great, as did the previous movie.stop - my issue turned out to be that I had ticked loop playback in one of my earlier attempts to get it to reset.

However, now it is failing to show some of the videos some times- they are all loaded and play when clicked on in the GitLab, and they also play when the experiment is run through psychopy. They also all seem to manage to play at some point during the run, there are just occasional blank sections where the video should be. The rest of the trial runs fine. If anyone has any ideas they would be greatly appreciated.
Thanks,
Sam

So, I don’t know why the problem was happening, but I fixed it by taking my videos out of their folder and just having them in the main folder - basically removing the need for a file path.
I have no idea why this worked, as it managed the play every video, just not every time, but problem solved! Thanks.

Spoke too soon, the issue is still there - just less frequent - basically it occasionally fails to show the video - but the trial continues as normal. All videos successfully play over the course of the study - so it isn’t an error with a specific video, and all trials are the same routine, so it isn’t a particular routine. The issue occurs both on Chrome and on Edge (I haven’t tried other browsers). Any ideas appreciated.

How big are the videos? Could it be a memory overload issue – could you try a lower resolution or higher compression?

Thanks for the reply, videos are about 754 KB … this shouldn’t be an issue on my machine, but if this might be an issue on others I should lower the resolution (let me know if you think this might be too high, though I plan to get a few people to test before I start recruiting).

I do seem to have fixed the issue though (this may be another spoke too soon, but I have done 2 full runs and it seems fine) my solution was to add a blank routine before the trial routine in the loop, this last 100ms, and then add a blank image at the start of my main trial routine which does nothing, and is ‘shown’ for 100ms. I am not sure which of these helps, or if it is both. Also, I don’t know why this might have worked!

Maybe it gives PsychoPy time to load the movie.

That sounds a bit like my earlier suggestion on this thread:

if t > .5 and moviestarted == 0:
     moviestarted = t
     myMovie.play()

That was the solution I eventually used to overcome one of the limitation of being able to present the movies at only the beginning of a trial. That is, I added a blank text inter-trial interval of a few seconds before the movie trial (within the trial loop), delaying the start of the movie (it works well where precise timing is not required).

I was using PsychoPy v2020.1.3 and I was not able to get .stop() working at all, the movies still remained static after their first presentation, hence substituting .seek(0) as the minimal solution.

I also had a series of movie clips with different run times, and I found that if I truncated their duration, then the remaining audio would continue to play to the end, after the movie had disappeared, even continuing after the end of the trial. The solution was to not specify duration for the movies, so that they always played to the end (collecting responses can also truncate trials early). To avoid this happening, a response collection routine can be added just after the movie trial, inside the trial loop (with the ITI mentioned above; again it works well where precise timing is not required).