我正在用 PyQt 开发一个接口。按下按钮时,我想用 QMediaRecorder 录制视频。如果您能提供帮助,我会很高兴。
def openCameraFunction(self):
self.cameraName = self.availableCameras[self.cameraSelector.currentIndex()].description()
print(self.cameraName)
self.camera = QCamera(self.availableCameras[self.cameraSelector.currentIndex()])
# self.viewFinder.setMediaObject(self.camera)
self.camera.setViewfinder(self.viewFinder)
self.camera.setCaptureMode(QCamera.CaptureVideo)
self.camera.error.connect(lambda: self.cameraAlertFunction(self.camera.errorString()))
self.camera.start()
self.filePath = 0
def saveVideoFunction(self):
path = QFileDialog.getExistingDirectory(self, "Video Kaydet")
if path:
self.savePath = path
self.recorder = QMediaRecorder(self.camera)
self.recorder.record(os.path.join(self.savePath, "Deneme.avi" ))