VlcMovieStim causes experiment to crash by chance

Hello there,

I’m using VlcMovieStim to display videos in my experiment, but this seems to cause Psychopy to crash the whole experiment by chance. Out of the last 5 attempts it crashed 2 times at the point in the experiment where the movie was supposed to start. When it crashes, the experiment exits without producing any error message about what the issue was, it just exits with the code 3221225477.

Here some information about the environment I’m working in:

  • Psychopy version 2022.2.5
  • Python 3.8.10
  • Windows system 10.0.17763
  • Processor Intel Xeon E5-1620
  • RAM 16GB

I’m working in the Coder. This is how I intialize and load my video.

mov = visual.VlcMovieStim(win,
            size=(1920, 1080),

I then start the video and send EEG triggers via a parallel port throughout the video presentation.

# function for sending a trigger with a specific value
def trigger(wert=0):

#### Performance Run ####
# send trigger
win.callOnFlip(trigger, start_performance)
print(f"Trigger {start_performance}")

while mov.status != constants.FINISHED:
    currentFrame = mov.getCurrentFrameNumber()
    if (currentFrame in trigger_dict) and (currentFrame != lastTriggeredFrame):  
        win.callOnFlip(trigger, trigger_dict[currentFrame])
        lastTriggeredFrame = currentFrame
        print(f"Trigger {trigger_dict[currentFrame]}")

        # save timestamps
        thisExp.addData('trigger', trigger_dict[currentFrame])
        thisExp.timestampOnFlip(win, 'trigger.timestamp')

    # process keyboard input
    if testing:
        if event.getKeys('space'):   # quit routine

# send trigger
win.callOnFlip(trigger, end)
print(f"Trigger {end}")
# stop the movie

The print statement of the first call to the trigger function works but it does not seem to continue with displaying the first frame of the video. First it displays a grey background and then crashes completely.

I tried using both MovieStim2 and MovieStim3 instead but they both produce significantly worse video playback performance where the audio lags for multiple seconds at the end of the clip.

Do you have an idea what could cause these issues and how I could adapt the code?

Is there another way to play large HD video files (6GB) that works for you?

Thanks in advance!

I think that’s probably the fundamental problem. I find that things start breaking down when you have to play back more than a gig’s worth of movies. It’s just a lot to load into memory. Are the crashes giving you actual error messages or is it just crashing quietly?

Also, have you verified that vlcMovieStim works on your system at all? I believe there’s a demo in the “demos” menu that uses it, if you haven’t had a chance to check.

Hi, thanks for your reply!

I also figured that it’s probably the size of the video but unfortunately there is no way around it for my experiment. I am already loading the video before the resting state period (5mins) which improved the playback performance.

I don’t get any particular error message, just this exit code 3221225477, which leaves me wondering where the problem might be. If the experiment continues, the video playback works fine with VlcMoviestim (except for these random crashes) and it is a lot better than MovieStim2 and 3 which caused the audio to lag at the end of every video.

I have read before that this exit code means access violation but I don’t know which access is violated here because the same lines of code succeed in playing the videos sometimes.

Really appreciate the help!

Yeah, that sounds like a memory issue. “Access violation” errors like that generally mean that it hits a location in memory that breaks it for some reason. It’s an unpredictable issue because it depends on how much RAM is in use at that exact moment and possibly even which sectors of the RAM the movie is being loaded into, which is basically not something you can control. It might behave somewhat consistently if you reboot and ONLY open PsychoPy and immediately run the experiment, but even that’s not a guarantee. Trying on a computer with 32GB+ of RAM would help, but again, no promises.

Thanks again for the quick reply! Unfortunately, my first and longer response was not sent.

I will try your recommendation, however I cannot change the computers RAM. I was also thinking about starting the experiment from the terminal, do you think that will make a difference?

I will also convert the video to a smaller size and try its behavior again.

It might help in that it will mean the PsychoPy app itself doesn’t take up any RAM, but I don’t know how much of a difference it will make.