我彻底检查了我的代码以使用popen但仍未获得新的MP4文件。
如果我在终端MP4Box中手动输入它。
但是当我运行下面的代码时,它不会引发任何错误。所以我感到很困惑,因为那些不起作用。
这两个定义适用于tkinter GUI按钮。
global now
#put widgets here
def picapture():
try:
global now
debugLog.insert(0.0, "Date Initialization Done\n")
now = datetime.datetime.now().strftime("%F_%X")
debugLog.insert(0.0, now + "\n")
camera.start_preview(fullscreen=False,window = (200,0,1100,640))
camera.start_recording('/home/pi/' + now + '.h264')
except:
print(traceback.format_exc(limit=10))
def stopcapture():
try:
global now
camera.stop_recording()
camera.stop_preview()
MP4Box_Command = ['MP4Box', '-add', now + '.h264', '-0', now + '.mp4']
convert = subprocess.Popen(MP4Box_Command, stdout=PIPE, bufsize=1, universal_newlines=True)
except subprocess.CalledProcessError as e:
raise RunTimeError("Commmand '{}'return with error (code {}): {}".format(e.cmd,e.returncode,e.output))
except:
print(traceback.format_exc(limit=10))