我正在尝试以120xps录制视频,格式为640x480。
我可以设置fps:
// currentCamera is an AVCaptureDevice, session is an AVCaptureSession
let input = try AVCaptureDeviceInput(device: currentCamera)
session.addInput(input)
let targetFrameRate = CMTimeMake(1, 120)
if let slowMoFormat = currentCamera.formats
.flatMap({ return ($0 as? AVCaptureDeviceFormat) })
.filter({ format in
for x in format.videoSupportedFrameRateRanges {
if let range = x as? AVFrameRateRange {
if range.minFrameDuration <= targetFrameRate {
return true
}
}
}
return false
}).first {
try currentCamera.lockForConfiguration()
currentCamera.activeFormat = slowMoFormat
currentCamera.activeVideoMinFrameDuration = targetFrameRate
currentCamera.activeVideoMaxFrameDuration = targetFrameRate
currentCamera.unlockForConfiguration()
}
或带
的视频尺寸// session is an AVCaptureSession
session.sessionPreset = AVCaptureSessionPreset640x480
但我不能同时做到这两点,因为更改activeFormat
或会话预设会覆盖其他更改。有什么明显的东西我不见了吗?