Movie loop psychopy error 3221225477

Hi everyone,

I’m having an issue with a PsychoPy experiment using Movie components inside a loop.

I’m using PsychoPy Standalone 2026.1.0 on Windows.

The experiment starts normally and some videos play correctly, but after a certain number of videos, PsychoPy suddenly crashes. It does not display a Python error or traceback. The Runner only shows:

Generating PsychoPy script...

## Running: C:\Users\7robe\OneDrive - unine.ch\...\PsychoPy2\Experiment_01_lastrun.py ##
3025.6960     INFO     Loaded monitor calibration from ['2026_09_17 18:28']
3025.7832     INFO     Loaded monitor calibration from ['2026_09_17 18:28']
#### Experiment ended with exit code 3221225477 [pid:19152] ####

The same crash happens repeatedly, with a different PID each time:

Experiment ended with exit code 3221225477

The important point is that the videos are not all failing immediately. Some videos play successfully, and then the experiment crashes when it reaches another video in the loop.

The videos are being selected through an Excel conditions file, and the Movie component is inside a loop.

The experiment files are currently stored in a OneDrive folder.

Has anyone experienced this type of crash (3221225477 / 0xC0000005) when playing multiple videos sequentially in a PsychoPy loop?

I’m wondering whether this could be related to:

  • the Movie component/video backend,

  • specific video files or codecs,

  • loading/unloading multiple videos during the loop,

  • memory usage,

  • or another PsychoPy/Windows issue.

Any advice on how to identify what is causing the crash would be greatly appreciated.Absolutely — here is a cleaner version focused only on the current problem.

Hi everyone,

I’m having an issue with a PsychoPy experiment using Movie components inside a loop.

I’m using PsychoPy Standalone 2026.1.0 on Windows.

The experiment starts normally and some videos play correctly, but after a certain number of videos, PsychoPy suddenly crashes. It does not display a Python error or traceback. The Runner only shows:

Generating PsychoPy script...

## Running: C:\Users\7robe\OneDrive - unine.ch\...\PsychoPy2\Experiment_01_lastrun.py ##
3025.6960     INFO     Loaded monitor calibration from ['2026_09_17 18:28']
3025.7832     INFO     Loaded monitor calibration from ['2026_09_17 18:28']
#### Experiment ended with exit code 3221225477 [pid:19152] ####

The same crash happens repeatedly, with a different PID each time:

Experiment ended with exit code 3221225477

The important point is that the videos are not all failing immediately. Some videos play successfully, and then the experiment crashes when it reaches another video in the loop.

The videos are being selected through an Excel conditions file, and the Movie component is inside a loop.

The experiment files are currently stored in a OneDrive folder.

Has anyone experienced this type of crash (3221225477 / 0xC0000005) when playing multiple videos sequentially in a PsychoPy loop?

I’m wondering whether this could be related to:

  • the Movie component/video backend,

  • specific video files or codecs,

  • loading/unloading multiple videos during the loop,

  • memory usage,

  • or another PsychoPy/Windows issue.

Any advice on how to identify what is causing the crash would be greatly appreciated.

Hi lele,

Honestly, I would just get rid of the loop. You’re making this way more complicated than it needs to be.

Loops are obviously the problem here because PsychoPy has to keep loading and unloading different videos. Just create a separate Routine for every single video and put them one after another in the Flow. If you have 16 videos, make 16 Routines. Don’t use an Excel conditions file at all.

There’s really no reason to dynamically select videos when you already know which videos you want to show. Manually adding them is much more reliable and eliminates all the potential problems caused by the loop.

Hello

Honestly, this suggestion makes the structure of the result file much more complicated. It also makes changes to your experiment more complicated.

Are all the movies in the same format, with the same codec, frame rate and audio sampling rate? Despite the fact that you are using a OneDrive folder for your experiment, which is not recommended, are you sure that all videos are available locally? It would be better to move everything to a local folder. Finally, change the audio backend.

Best wishes Jens

Hi Jens, thank you for your reply. I agree with you, and I need the loop for the randomization of the videos.

Yes, all movies are the same format and even the same length. And there is no audio.

I tried putting everything in a local file but it didn’t change anything.

What do you think the problem could be ?

Thanks

Best wishes Lele

Hello @lele

Did you try a different video backend?

Best wishes Jens

Do you have duplication of a routine name?

Hi

Yes, I tried all of them and only ffpyplayer works

Best wishes Lele

I’m not sure I understand what you mean by “duplication of a routine name”.

Here’s a photo of my experiment structure if it can help

Thank you

Lele

My issue seems to be similar to fei’s, but the program crashes after a random number of videos shown. I wondered if the error was due to one corrupted video, but I tried multiple times and they all worked at least once. I have a total of 32 videos, and the loop should show 16 random to the participant.

Try removing the randomisation to see if it always crashes at the same place.

Good idea, I tried and it still crashes random

Hi all,

The problem was with the audio on the videos. Chat GPT created a long code that solved this problem.

Thank you for your answers!

Here’s the code if someone hase the same problem

Before exp:

# Experimental workaround: silent movies only, PsychoPy 2026.1.0.
# Applied only to this Python process; no installed files are changed.
import psychopy as silent_psychopy
from psychopy.visual import movies as silent_movie_module

if silent_psychopy.__version__ != '2026.1.0':
    raise RuntimeError('Ce contournement est reserve a PsychoPy 2026.1.0.')

SilentOriginalReader = getattr(silent_movie_module, 'MovieFileReader', None)
if SilentOriginalReader is None or not hasattr(SilentOriginalReader, '_setVolumeFFPyPlayer'):
    raise RuntimeError('Lecteur video incompatible avec le contournement audio.')

class SilentExperimentReader(SilentOriginalReader):
    def __init__(self, filename, decoderLib='ffpyplayer', decoderOpts=None):
        opts = dict(decoderOpts or {})
        if decoderLib == 'ffpyplayer':
            opts.update({'an': True, 'volume': 0.0, 'sync': 'video'})
        super().__init__(filename, decoderLib=decoderLib, decoderOpts=opts)

    def _setVolumeFFPyPlayer(self, volume):
        # Audio is disabled at decoder creation. Do not call native set_volume.
        return None

    def _getVolumeFFPyPlayer(self):
        return 0.0

silent_movie_module.MovieFileReader = SilentExperimentReader
print('SILENT VIDEO PATCH | audio decoding off | native volume calls off', flush=True)

Begin exp:

import random as pyrandom
from pathlib import Path as VideoPath
import faulthandler
faulthandler.enable()

Begin routine:

side = pyrandom.choice(['left', 'right'])
video_file = video_left if side == 'left' else video_right
print(f"VIDEO LOAD | essai {trials.thisN + 1} | {video_file}", flush=True)
if not VideoPath(video_file).is_file():
    raise FileNotFoundError(f"Video introuvable : {VideoPath(video_file).resolve()}")
thisExp.addData('side_shown', side)
thisExp.addData('video_shown', video_file)

End routine:

print(f"VIDEO END | {video_file}", flush=True)

Hello

One way to code all videos in the same manner is to use ffpmeg.

ffmpeg -i input.mp4 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac output.mp4

Best wishes Jens

Thank you. I’ve checked in with our developers and this issue should be fixed in 2027.1.0 (i.e. it is already fixed in the dev branch)