Hi Everyone,
I’m working on trying to repeat moviestim files that I preload ahead of time. This topic has been covered before, but none of the solutions are quite working out for me.
Basically, I first create all of my movies from a file archive:
CS_Loss_Files = glob.glob(os.path.join('CS','Loss','*mp4'))
for file in CS_Loss_Files:
CS_Loss.append(visual.MovieStim3(win=win, filename=file, name=file,
pos = [0,0], units = 'pix', loop = False))
Then, when I need a movie I call one randomly:
Movie = random.choice(CS_Loss)
Movie.setAutoDraw(True)
Movie.play()
Then the movie freezes on the last frame and waits for a response to continue:
while Movie.status != constants.FINISHED:
win.flip()
if Movie.getCurrentFrameTime() >= (Movie.duration - 0.05):
Movie.pause()
Movie.setAutoDraw(False)
The process will then loop back and repeat randomly selecting a movie and playing it. This setup works great… for the first play of a given movie. On a second play, it either fails to actually play, has a long initial stutter, or can lead to a crash. What I’ve tried so far from searching the forums:
Suggestion: add Movie.seek(0) in the end routine section
Problem: When you go to play that movie again, there will be a very noticeable lag where the movie displays the last frame from when it was played before. The movie then resets and plays normally after about a sub 1s delay.
Suggestion: Upload duplicate movies
Problem: I already have a very high number of movies (36) that makes duplicating videos untenable.
Suggestion: Use a static period to reload the movie
Problem: There really isn’t a static period built into my experiment without causing a fairly noticeable delay. I initially had the movies load on demand one at a time, but pilot data confirmed the load time lag was noticeable and annoying.
Suggestion: use Movie.reset() in the end routine section
Problem: This solution works great shortly but a crash always inevitable occurs. I will post the log file below as it’s rather long.
Most of the forums having issues repeating MovieStims were fairly old, so I’m hoping I’ve just missed something or there has been a new development I’m unaware of to get this working as I’m out ideas.
Log following crash using Movie.reset():
Blockquote
Traceback (most recent call last):
File “Psycho_Py\GamblingTask_HalfLoad_lastrun.py”, line 760, in
Movie.setAutoDraw(True)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py”, line 583, in setAutoDraw
self.play(log=False) # set to play in case stopped
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py”, line 271, in play
self._videoClock.reset(-self.getCurrentFrameTime())
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py”, line 348, in getCurrentFrameTime
return self._nextFrameT - self.frameInterval
TypeError: unsupported operand type(s) for -: ‘NoneType’ and ‘float’
Exception ignored in: <bound method MovieStim3.del of <psychopy.visual.movie3.MovieStim3 object at 0x0000020FABD1CF98>>
Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py”, line 568, in del
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py”, line 545, in _unload
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\basevisual.py”, line 1141, in clearTextures
OSError: exception: access violation reading 0x0000000000000000
Exception ignored in: <bound method MovieStim3.del of <psychopy.visual.movie3.MovieStim3 object at 0x0000020FABD3DCF8>>
Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py”, line 568, in del
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py”, line 545, in _unload
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\basevisual.py”, line 1141, in clearTextures
OSError: exception: access violation reading 0x0000000000000000
Exception ignored in: <bound method MovieStim3.del of <psychopy.visual.movie3.MovieStim3 object at 0x0000020FABD1C6A0>>
Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py”, line 568, in del
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py”, line 545, in _unload
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\basevisual.py”, line 1141, in clearTextures
OSError: exception: access violation reading 0x0000000000000000