Simple movieStim results in many dropped frames

I have a few simple mp4 videos. The videos are each created from 120 .png images with ffmpeg at 60 fps, at a size of around 2.5mb.

I pre load a number of visual.videoStim3 which I then assign to an array.

video = visual.MovieStim3(WIN, 
            os.path.join(VIDEO_PATH, stimulus), 
            units='pixels', 
            size = (100,100),
            pos = [0,0], 
            loop = True, 
        )
stimuli.append(video)

Then, for a given trial I access the video and present it as such:

video = sitmuli[curTrial]
while video.status != constants.FINISHED:
    video.draw()
    WIN.flip()

This results in visually noticable dropped frames/laggy video. The following output is generated showing the dropped frames. What can be causing these laggy frames?

I have tried this code on two separate systems and it gives a similar result in both. What can I do to combat dropped frames? The systems are 8 and 16GB memory respectively with nothing else running concurrently.

20.5015         WARNING         0.6987386000109836: Video catchup needed, advancing self._nextFrameT from 0.016666666666666666 to 0.03333333333333333
20.5016         WARNING         0.6987661000457592: Video catchup needed, advancing self._nextFrameT from 0.03333333333333333 to 0.05
20.5016         WARNING         0.6987795000313781: Video catchup needed, advancing self._nextFrameT from 0.05 to 0.06666666666666667
20.5016         WARNING         0.6988079000147991: Video catchup needed, advancing self._nextFrameT from 0.06666666666666667 to 0.08333333333333333
20.5016         WARNING         0.6988189000403509: Video catchup needed, advancing self._nextFrameT from 0.08333333333333333 to 0.09999999999999999
20.5016         WARNING         0.698829900007695: Video catchup needed, advancing self._nextFrameT from 0.09999999999999999 to 0.11666666666666665
20.5016         WARNING         0.6988406000309624: Video catchup needed, advancing self._nextFrameT from 0.11666666666666665 to 0.13333333333333333
20.5017         WARNING         0.6988510999944992: Video catchup needed, advancing self._nextFrameT from 0.13333333333333333 to 0.15
20.5017         WARNING         0.698861200013198: Video catchup needed, advancing self._nextFrameT from 0.15 to 0.16666666666666666
20.5017         WARNING         0.6988711000303738: Video catchup needed, advancing self._nextFrameT from 0.16666666666666666 to 0.18333333333333332
20.5017         WARNING         Max reportNDroppedFrames reached, will not log any more dropped frames
1 Like

Try using visual.VlcMovieStim, which seems to often work better.

Hi @mjpvz

Did you manage to sort out this issue? I’m getting exactly the same error message (on 2 different computers) whilst trying to present 2-3 second clips, all less than 1MB

1 Like

Same problems here.

1 Like

I am also having the same issue when I am trying to add a simple movie stimulus from the builder view. I am trying to add just 1 movie stimuli in and these are the errors I’m having:

Running: C:\Users\japneet\Bremen_experiment\final_trials2_lastrun.py

84620.0143 INFO Loaded monitor calibration from [‘2022_03_10 13:45’]
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Hello from the pygame community. https://www.pygame.org/contribute.html
21.3109 WARNING 0.456220599997323: Video catchup needed, advancing self._nextFrameT from 0.0 to 0.04
21.3110 WARNING 0.4562805999885313: Video catchup needed, advancing self._nextFrameT from 0.04 to 0.08
21.3110 WARNING 0.45632099999056663: Video catchup needed, advancing self._nextFrameT from 0.08 to 0.12
21.3110 WARNING 0.45635689998744056: Video catchup needed, advancing self._nextFrameT from 0.12 to 0.16
21.3111 WARNING 0.4563912000012351: Video catchup needed, advancing self._nextFrameT from 0.16 to 0.2
21.3111 WARNING 0.4564249999966705: Video catchup needed, advancing self._nextFrameT from 0.2 to 0.24000000000000002
21.3111 WARNING 0.45645909999439027: Video catchup needed, advancing self._nextFrameT from 0.24000000000000002 to 0.28
21.3112 WARNING 0.45649319999211: Video catchup needed, advancing self._nextFrameT from 0.28 to 0.32
21.3112 WARNING 0.4565256999921985: Video catchup needed, advancing self._nextFrameT from 0.32 to 0.36
21.3112 WARNING 0.45655919999990147: Video catchup needed, advancing self._nextFrameT from 0.36 to 0.39999999999999997
21.3112 WARNING Max reportNDroppedFrames reached, will not log any more dropped frames
1.7247 WARNING Monitor specification not found. Creating a temporary one…
ioHub Server Process Completed With Code: 0

1 Like

Same issue here. I had it when presenting the videos with the builder, as well as when using only code. I tried it on a MacBook Air 2020 and on a Windows computer, thinking it had to do with the graphic card of my Mac laptop, but the same issue persists.

This is the code I’m using:

outcome1 = visual.MovieStim3(win, video_filename, flipVert=False, pos = video_pos, size=(video_width, video_height), units='norm')
        # Also tried
        # outcome1 = visual.VlcMovieStim(win, video_filename, flipVert=False, pos = video_pos, size=(video_width, video_height), units='norm')
        # but that didn't work out well beucase of zsh: bus and zsh: abort, which is a memory-related issue

# Create the text outcome 
outcome2 = visual.ImageStim(win, image=os.path.join(stimuli_dir, text_filename), pos = text_pos, size=(0.5, 0.6))

# Display the outcomes for the specified duration
clock = core.Clock()
while clock.getTime() < 2:  # Change the duration as needed
        outcome1.draw()
        outcome2.draw()
        win.flip()

and tried many variations of it, but still the same issue persists. Any help?

Thank you!

1 Like

Same issue here

Anyone have a solution? I can’t get any videos to play with my setup.

Mac OS Monterey Version 12.3
Python 3.9

Code snippet:


stimPath =  '/Users/sysadmin/Documents/NeuroScape/MASC_FR/'
os.chdir(stimPath)
clip = glob.glob('20.wmv')
thisClip= os.path.join(stimPath, clip[0])
    
win = visual.Window([900, 600], [0, 0], monitor="testMonitor", units="deg")
thisMov = visual.MovieStim3(
    win=win, 
    filename=thisClip)
thisMov.draw()
win.flip()
event.waitKeys()
win.close()

I’ve tried using VlcMovieStim, MovieStim, MovieStim2.
Also tried converting the files to MP4 etc.
The best I get is reasonable audio and then the first frame of the video, and this only with MovieStim3.
I get the following assorted error with those parameters:

|3.3484 |WARNING |0.25634666718542576: Video catchup needed, advancing self._nextFrameT from 0.0 to 0.04|
|---|---|---|
|3.3484 |WARNING |0.2564312503673136: Video catchup needed, advancing self._nextFrameT from 0.04 to 0.08|
|3.3485 |WARNING |0.25644324999302626: Video catchup needed, advancing self._nextFrameT from 0.08 to 0.12|
|3.3485 |WARNING |0.2564531252719462: Video catchup needed, advancing self._nextFrameT from 0.12 to 0.16|
|3.3485 |WARNING |0.2564627090469003: Video catchup needed, advancing self._nextFrameT from 0.16 to 0.2|

The movies run just fine on moviepy.

Thanks so much for any advice.