[solved] MovieStim freeze after playing avi

Hi everybody

I simply want to play a short avi video (between 800ms and 2s) without sound, from start to end.

I use psychopy v1.83.03 with windows7
and my english is poor :wink:

I tried with movieStim but sometimes it freezes at the end of the movie, and sometimes not. when I run the script several times consecutively without change, some times it freezes without logic.

here is my code


from __future__ import division

from psychopy import visual, core, event
import time

win = visual.Window(fullscr=True)
mov = visual.MovieStim(win, '2000ms8R_ll.avi')#, size=(1920,1080),2000ms8R_ll.avi800ms8L.avi
   # flipVert=False, flipHoriz=False, loop=False)
img=visual.ImageStim(win,"CXL_xl.jpg")
print('orig movie size=%s' % mov.size)
print('duration=%.2fs' % mov.duration)
globalClock = core.Clock()
start=globalClock.getTime()

temps=globalClock.getTime()-start
while  globalClock.getTime()-start<=mov.duration:
    temps=globalClock.getTime()-start
    print temps
    mov.draw()
    win.flip()
print "exit loop"
win.flip()  
print "videok"

output when it works

...
1.90218114352
1.93437808027
1.96849734988
exit loop
videok

output when it doesn’t works

...
1.89641100856
1.92962157529
1.96301975623
1.9966506016

With MovieStim2 i only have the first frame,but the loop stops at good time

from psychopy import visual, core, event
import time

win = visual.Window(fullscr=True)
mov = visual.MovieStim2(win, '2000ms8R_ll.avi')#, size=(1920,1080),2000ms8R_ll.avi800ms8L.avi
   # flipVert=False, flipHoriz=False, loop=False)
img=visual.ImageStim(win,"CXL_xl.jpg")
print('orig movie size=%s' % mov.size)
print('duration=%.2fs' % mov.duration)
globalClock = core.Clock()
start=globalClock.getTime()

temps=globalClock.getTime()-start
mov.play()
win.flip()
mov.draw()
while  globalClock.getTime()-start<=mov.duration:
    temps=globalClock.getTime()-start
    print temps
    mov.draw()
    win.flip()
print "exit loop"
win.flip()  

print "videok"

with movieStim3 i have this error

Traceback (most recent call last):
  File "F:\Work\Work\Jenny\tests videos\test_moviestm3.py", line 22, in <module>
    mov.draw()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.83.03-py2.7.egg\psychopy\visual\movie3.py", line 369, in draw
    GL.glPopClientAttrib(GL.GL_CLIENT_ALL_ATTRIB_BITS)
TypeError: this function takes 0 arguments (1 given)
2.7183 	WARNING 	Monitor specification not


I have problems with demo too

demo MovieStim.py :

Traceback (most recent call last):
  File "C:\Users\simon\Desktop\MovieStim.py", line 11, in <module>
    mov.draw()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.83.03-py2.7.egg\psychopy\visual\movie3.py", line 369, in draw
    GL.glPopClientAttrib(GL.GL_CLIENT_ALL_ATTRIB_BITS)
TypeError: this function takes 0 arguments (1 given)

with demo movieStim2.py,It starts to play without action keys but stop quickly.
Sometimes after 57 loops, sometimes after 19
I tried to replace “while mov.status != visual.FINISHED:” with “while 1”–> it show only the first frame

If SomeOne has simple code to play an avi from start to end without pause, without sound, i will be eternaly gratefull.
here is an example of video : https://amubox.univ-amu.fr/index.php/s/ivFIf8zizShN8D5

thanks

The error with moviestim3 was fixed. Please upgrade to a newer version of PsychoPy

Hi Jon,
That’s right.
I tried this morning and it works well with movieStim3 and psychopy 1.84.2
Thanks !

Hello,

I’m currently also not able to play avi videos using MovieStim3 (on Windows 10, PsychoPy 2022.1.4). The videos are 15 seconds long and the sound works fine, but the video seemed to be frozen on the first frame. At the moment I am trying to get the code to run using just one 15-second video, but I will have to create a loop to show 48 of these videos later on.

I’ve already tried:
MovieStim → the whole experiment won’t start
MovieStim2 → audio works, video is frozen on the first frame
MovieStim3 → audio works, video is frozen on the first frame
VlcMovieStim → starts the experiment, but crashes just before the video is meant to start

I’ve also tried changing the units and the audio still plays with the video remaining frozen (tried: “pix” with size=(500,500), “deg” with size=(10,10), “norm” with size=(0.5,0.5))

I’ve also tried the code with a 15 second .mp4 video with MovieStim3 and the audio works fine, but the video is also frozen on the first frame.

Do you have any suggestions what else I could try or what might be causing this issue?

Unfortunately I can’t upload the videos here due to GDPR, as they are of participants… but here is the code I’m using:

#imports
from psychopy import visual, core, event, prefs
import os

#load assets
fp= 'C:\\Users\\ning625d\\Documents\\Experiment\\ET\\Assets\\Stimuli\\Leo1.avi' #filepath 

#create window, fixation cross
win= visual.Window([1680, 1050], color= (0,0,0), monitor= 'testMonitor', fullscr= False, allowGUI= False)
cross= visual.TextStim(win, '+', color= (1,1,1))

welcome= visual.TextStim(win, 'Thank you for participating our experiment.\n\nPress any key to continue.', color= (1,1,1))
video_fp= 'C:\\Users\\ning625d\\Documents\\Experiment\\ET\\Assets\\Stimuli\\Leo1.avi'
video= visual.MovieStim3(win, video_fp) # test with 1 video
dur= video.duration

person_name=os.path.basename(video_fp[0:-5]) #name, no number, no file extension
name= visual.TextStim(win, '%s'% (person_name), color= (1,1,1))

#Welcome screen
welcome.draw()
win.flip()
event.waitKeys()
win.flip()

#Start experiment
cross.draw()
win.flip()
core.wait(1)
win.flip()

#Show name
name.draw()
win.flip()
core.wait(2)
win.flip()

#Show video
video.draw()
video.play()
win.flip()
core.wait(dur) #wait duration of each video
video.stop()
win.flip()

Hi Karen, did it by any chance work out in the end? Would you be willing to share your solution?