【发布时间】:2020-06-09 17:09:41
【问题描述】:
我正在尝试通过修改 AVCAM 应用程序来录制 60 fps 视频,该应用程序位于:
https://github.com/Lax/Learn-iOS-Swift-by-Examples/tree/master/AVCam/Swift/AVCam
因此,我的手机 (iPhone X) 通常可以达到 2-30 fps,我尝试更改它捕获视频的格式。
'''
do {
// Choose the back dual camera if available, otherwise default to a wide angle camera.
if let dualCameraDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front) {
defaultVideoDevice = dualCameraDevice
do{
if let formats = defaultVideoDevice?.formats {
for format in formats{
let formatDesc = format.formatDescription
print(format.videoSupportedFrameRateRanges)
let frameRate = format.videoSupportedFrameRateRanges.first
print(format.formatDescription)
if let frameRate = frameRate, frameRate.maxFrameRate == 60.0 {
try defaultVideoDevice?.lockForConfiguration()
print(frameRate.maxFrameRate) //here prints 60.0
defaultVideoDevice?.activeVideoMaxFrameDuration = CMTimeMake(1,60)
defaultVideoDevice?.activeVideoMinFrameDuration = CMTimeMake(1,60)
defaultVideoDevice?.unlockForConfiguration()
}
}
}
}
'''
在 'defaultVideoDevice?.activeVideoMaxFrameDuration = CMTimeMake(1,60)' 行我收到此错误:
2019-11-21 09:23:50.225376+0300 AVCam[1250:667986] * 由于未捕获的异常 'NSInvalidArgumentException' 导致应用程序终止,原因:'* -[AVCaptureDevice setActiveVideoMaxFrameDuration:] 不支持帧持续时间 - 使用 -activeFormat.videoSupportedFrameRateRanges 发现有效范围'
提前致谢。
【问题讨论】: