# \[solved\] MovieStim freeze after playing avi

**URL:** https://discourse.psychopy.org/t/solved-moviestim-freeze-after-playing-avi/2181
**Category:** Coding
**Tags:** screen, movies
**Created:** [March 23, 2017, 2:42pm UTC](https://discourse.psychopy.org/t/solved-moviestim-freeze-after-playing-avi/2181 "2017-03-23T14:42:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://discourse.psychopy.org/u/simon)
#### Post date: [March 23, 2017, 2:42pm UTC](https://discourse.psychopy.org/t/solved-moviestim-freeze-after-playing-avi/2181/1 "2017-03-23T14:42:37Z")

</div>

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 😉

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

```auto

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

```auto
...
1.90218114352
1.93437808027
1.96849734988
exit loop
videok

```

output when it doesn’t works

```auto
...
1.89641100856
1.92962157529
1.96301975623
1.9966506016

```

* * *

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

```auto
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

```auto
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](http://MovieStim.py) :

```auto
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](http://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](https://amubox.univ-amu.fr/index.php/s/ivFIf8zizShN8D5)

thanks

---

<div class="post-metadata">

### Author: ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)
#### Post date: [March 27, 2017, 12:07pm UTC](https://discourse.psychopy.org/t/solved-moviestim-freeze-after-playing-avi/2181/2 "2017-03-27T12:07:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://discourse.psychopy.org/u/simon)
#### Post date: [March 27, 2017, 1:03pm UTC](https://discourse.psychopy.org/t/solved-moviestim-freeze-after-playing-avi/2181/3 "2017-03-27T13:03:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Karen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/karen/32/12916_2.png) [@Karen](https://discourse.psychopy.org/u/Karen)
#### Post date: [November 4, 2022, 11:18am UTC](https://discourse.psychopy.org/t/solved-moviestim-freeze-after-playing-avi/2181/4 "2022-11-04T11:18:29Z")

</div>

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:

```auto
#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()

```

---

<div class="post-metadata">

### Author: ![SabineO](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/sabineo/32/37595_2.png) [@SabineO](https://discourse.psychopy.org/u/SabineO)
#### Post date: [March 29, 2023, 12:17pm UTC](https://discourse.psychopy.org/t/solved-moviestim-freeze-after-playing-avi/2181/5 "2023-03-29T12:17:52Z")

</div>

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