psychopy.org | Reference | Downloads | Github

No Audio During Movie

I’ve been trying to get the audio to play when I present my movie. I’ve used .mp4, .avi, and .mov formats, all to no avail. Would this have something to do with needing the movie formatted in linear PCM? Here is what I’ve currently been doing:

from psychopy import locale_setup, visual, core, event, data, gui
import os

cwd = os.path.dirname(__file__)

win = visual.Window(fullscr=True, pos=(0,0), units="norm", color="Black")
event.Mouse(visible=False)
    
movie = visual.MovieStim(win, 'Monty_Python.mov', units='norm', size=(1.5,1.5))
movie.setAutoDraw(True)

while movie.status != visual.FINISHED:    
    thesekeys = event.getKeys(keyList=['escape','p','g'])
    if 'escape' in thesekeys:
        break
    elif 'p' in thesekeys:
        movie.pause()
    elif 'g' in thesekeys:
        movie.play()
        
    win.flip()

#Finish
win.close()
core.quit()

If the audio is compressed (e.g. AAC) then, yes, it won’t be played. I think that would raise an error about failing to decode though