我创建了一个自定义相机,到目前为止效果很好。我可以录制视频并在没有错误或错误的情况下停止录制。我想为这款相机添加的一项功能是暂停录制的功能。
经过大量在线研究,我发现解决方案是在单击暂停按钮时实际停止录制,并在单击恢复按钮时开始另一次录制。之后,您应该将视频合并在一起。
我不确定如何合并视频,我在网上查了很多东西都没有找到解决办法。
谢谢!
这是我的录音按钮功能
@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
}
}
最佳答案
关于ios - 使用 AVFoundation 暂停视频录制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44895563/