使用AVFoundation暂停视频录制
问题描述:
我创建了一个自定义相机,迄今为止完美。我可以录制视频并停止录制,不会出现任何错误或错误。我想添加到此相机的功能是暂停录制的功能。使用AVFoundation暂停视频录制
经过大量的在线研究,我发现解决方案是在单击暂停按钮时实际停止录制,并在单击继续按钮时开始另一个录制。之后,您应该将视频合并到一起。
我不知道如何合并视频,我在网上查了很多东西,一直没能找到解决方案。
谢谢!
这是我的录音按钮功能
@IBAction func recordVideoButtonPressed(sender:AnyObject) {
if self.movieFileOutput.isRecording {
isRecording = false
self.movieFileOutput.stopRecording()
} else {
isRecording = true
self.movieFileOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = self.videoOrientation()
self.movieFileOutput.maxRecordedDuration = self.maxRecordedDuration()
self.movieFileOutput.startRecording(toOutputFileURL: URL(fileURLWithPath: self.videoFileLocation()), recordingDelegate: self)
}
self.updateRecordButtonTitle()
}
这是我的暂停按钮功能
func pauseVideo() {
if isRecording {
if isPaused == false {
isPaused = true
recordButton.isEnabled = false
recordButton.backgroundColor = UIColor.wetAsphalt
recordButton.setTitle("Paused", for: .normal)
} else {
isPaused = false
recordButton.isEnabled = true
recordButton.backgroundColor = UIColor.red
updateRecordButtonTitle()
}
} else {
return
}
}
你能提供:func captureOutput(_ captureOutput:AVCaptureOutput !, didOutputSampleBuffer sampleBuffer:CMSampleBuffer !,来自连接:AVCaptureConnection!)方法代码? – ninjaproger