Fail to play sequence of MP4 videos across trials

此生再无相见时 提交于 2021-01-29 03:01:41

问题


I have 10 trials and two conditions (randomized across the trials) that consist of playing either an optic flow mp4 movie or a random flow mp4 movie. To load and play the mp4 I used visual.MovieStim3

nBlocks = 4
nTrials = 10

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

conditions = nb_conditions.repeat(nTrials/2) # 5 times condition1 and 5 times condition2

conditions_rand = np.random.permutation(nb_conditions) # Randomize the order of the conditions

# --- Load optic flow and random flow movies ---

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):

   for Nframes in range(700):

       if conditions_rand[trialcount] == 1:
           optic_flow_movie.draw()


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

       win.flip()
win.close()

It starts playing the first video on the conditions_rand array, then at a random interval of time, it shows a second video and then the screen is black again for a long time as it freezes. Because it doesn’t throw any error, I have no idea why it is behaving this way. Your help would be highly appreciated thanks !!


回答1:


Try inserting:

optic_flow_movie.seek(0)
random_flow_movie.seek(0)

in between the two for loops, so each movie gets reset to its start frame before getting played again.



来源:https://stackoverflow.com/questions/60532960/fail-to-play-sequence-of-mp4-videos-across-trials

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!