Fail to play sequence of MP4 videos across trials

I created 10 trials with two conditions, each condition plays a different movie (optic flow or random flow). I loaded the mp4 movies with the function visual.MovieStim3 and displayed the movies in my trials loop with the function movie.draw(). Since I have 10 trials, the videos should be shown randomly 10 times, but instead, the code is only displaying the first two videos in a loop of 10 trials. After showing a second video, the window stays black for some second then closes. There is no error thrown.

I added the lines optic_flow_movie.seek(0) and random_flow_movie.seek(0) following the answer to my question on StackOverflow provided by @Michael, and it worked on my Linux machine that had the Python Version (3.6.4) and the PsychoPy Version (3.2.0).

Now that I am trying it on a MAC computer that has the latest Python Version (3.7.4) and PsychoPy version (PsychoPy3, version 2020.1.2 ), I am running into the same bug, and there was no error thrown. There was only the warning:

WARNING We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use [‘sounddevice’, ‘PTB’, ‘pyo’, ‘pygame’] (in that order).

Therefore, I downgraded the PsychoPy version to 3.2.0, and it is still bugging.

Your help would be very precious because this recurrent bug is preventing me from moving forward with my experiment. :pray:

nTrials = 10

nb_conditions = np.arange(1,3)                                        # We have two conditions : Optic flow and Random flow

conditions = nb_conditions.repeat(nTrials/2)                     # 5 times condition_1 and 5 times condition_2
conditions_rand = np.random.permutation(conditions)      # Randomize the order of the conditions

# Load optic flow and random flow movies (duration of each movie is 200 frames)
optic_flow_movie    = visual.MovieStim3(win, 'optic_flow.mp4')
random_flow_movie   = visual.MovieStim3(win, 'random_flow.mp4')

# iterate through trials and play movies
for trialcount in range(nTrials):
    
    optic_flow_movie.seek(0)
    random_flow_movie.seek(0)
    
    for Nframes in range(200):
        
        if conditions_rand[trialcount] == 1:
            optic_flow_movie.draw()


        elif conditions_rand[trialcount] == 2:
            random_flow_movie.draw()

        win.flip()


win.close()

Did you sort this out? I also encountered similar errors even though I have no video/audio stimuli…

image

Unfortunately, I haven’t got an answer or solution, and it is really blocking me from moving forward with my code and experiment… I thought about using another library with Psychopy, at least to read and draw the videos, but it’s messy to implement and use it with PsychoPy, I’d prefer continuing with this library…

Okay - I’ll let you know how I go too.

I was asked about and suggested to try the following:

  • Have you done the usual first line fixes of uninstalling/reinstalling your psychopy?
  • Are you also using apple products? May be related to problems.
  • Have you done the usual first-line fixes of uninstalling/reinstalling your psychopy? --> I have tried uninstalling/reinstalling and it was still bugging.

  • Are you also using apple products? May be related to problems. --> I tried it on Linux and Macbook, and I ran into the same problem, unfortunately …

Yeh, reinstalling didn’t work for me either. I am using an apple laptop…Not sure what to try next…

I tried changing the order or audio libraries:
In PychoPy3>Preferences>Hardware I changed from [‘sounddevice’, ‘PTB’, ‘pyo’, ‘pygame’, ] to [‘PTB’, ‘sounddevice’, ‘pyo’, ‘pygame’, ].

This got rid of that error message. I still have another error message: ApplePersistenceIgnoreState: Existing state will not be touched. Anyway, I’m not sure if this is a related error message, but hopefully the above works for you.

I added movie.play() before each movie.draw() and it fixed the previous problem I had but creates a new one! Now it is playing the right number of animations per condition (5 times the video optic_flow and 5 times the video random_flow). However, each video freezes for 2seconds before starting the animation…