Solution to Reloading MovieStim File that Works but I don't Understand Why

I’ve been working on an experiment where an individual makes a choice and then a short movie plays. However, like many on here, I’ve run into the problem where if you try to reuse a movie stimulus you’re unable to get a seamless replaying unless you reload the movie. That is, movies play fine the first time, but the second+ time often stutter at the beginning. I’ve created some code to reload a movie but don’t understand why it works.

First, we create a list of Movie Stims:

Movie_List = [MovieStim_A, MovieStim_B, etc.]

Then, I randomly pull from the list to play a movie and pause it at the end.

Movie = random.choice(Movie_List)
while Movie.status != constants.FINISHED:
    if Movie.getCurrentFrameTime() >= (Movie.duration - .05):

Finally, I reload the movie


My question is, why do you need to reload with this method? For instance, say Movie creates a copy of MovieStim_A on Trial 1, then on trial 2 it gets overwritten to create a copy of MovieStim_B, and then on Trial 3 again is overwritten to create a copy of MovieStim_A. In theory, Movie is creating a copy of MovieStim_A on the third trial that has never been played, so I would expect it to transition ok, but it doesn’t.

Instead, if Movie creates a copy of MovieStim_A, reloads, and then on the next trial creates and plays a copy of MovieStim_B, now the transition is seamless. Why? Theoretically, upon reloading Movie would have reloaded its copy of MovieStim_A even though on the next trial it plays MovieStim_B. It doesn’t make sense to me and I would appreciate it if anyone can help me understand the inner workings of MovieStim.

I’ve run into this too using MovieStim3. The issue is basically that something about the way MoviePy is put together (MoviePy is the underlying library for MovieStim3) or how FFMPEG works that makes it so that when you try to seek to a location in the movie that is distant from the current location (i.e., from end to beginning), it gets very unhappy and basically tries to reload the whole movie anyways, or at least re-decode it, but doesn’t do so correctly. If your movies are short enough that reloading them doesn’t chew a problematic amount of time or memory, it is a “safer” option. That said, I would very much prefer it if you could just seek your way back to the beginning reliably.

Does anyone know if this also happens if you use the vlc movie stim instead of MovieStim3?

For me VlcMovieStim just crashes if I try to do a seek that’s too distant from the current timestamp. For example if I wanted to loop back to the beginning of a video I basically have to call replay(), which functionally reloads the whole movie anyways.