新版本scrcpy,使用TASKKILL /im scrcpy.exe"强制结束进程会出现录屏损坏
经过一天的谷歌终于在github上发现了一个解决方案
pip install console-ctrl
command = f"{SCRCPY_PATH} --serial {self.serial} --no-display --record {TMP_PATH}\\file.mp4"
self.record_proc = subprocess.Popen(command,
shell=True,
creationflags=subprocess.CREATE_NEW_CONSOLE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
def closeEvent(self, event):
if self.record_proc:
if self.record_proc.poll() is None:
console_ctrl.send_ctrl_c(self.record_proc.pid)