| Reference | Downloads | Github

Subprocess.Popen causing script to freeze

This pertains to a previous post of mine, where I collected audio and video simultaneously, and am now trying to add the audio to the video. I’ve found ffmpeg to be a good 3rd source software for this, so I’ve downloaded, but running it through Psychopy causes my script to fail. This forum post provides a solution, which I’ve decided to use:

from psychopy import locale_setup, visual, core, event, data, gui, microphone
import os
import subprocess as subp
win = visual.Window(size=(1200,1200), fullscr=Tru, pos=(0,0), units='height', color=[-1,-1,-1])

cmd = '{}/ffmpeg/bin/ffmpeg -i {}.wav -i {}.avi -shortest {}'.format(cwd, audio_path, video_path, video_path)
win.fullscr = False
subp.Popen(cmd, shell=False)
win.fullscr = True

While this does indeed work, it’s a bit jarring to have the window flip on and off like this. I was wondering if there is a workaround that doesn’t involve having to close and then reopen the window?



Actually, I just managed to solve this issue. Solution is to slightly change the subprocess command:

subp.Popen(cmd, shell=True)