无论如何,我都想捕获1280x720。我使用以下代码:
guard let capturer = self.videoCapturer as? RTCCameraVideoCapturer else {
return
}
capturer.captureSession.sessionPreset = AVCaptureSession.Preset.hd1280x720
guard
let frontCamera = (RTCCameraVideoCapturer.captureDevices().first { $0.position == .front }),
// choose highest res
let format = (RTCCameraVideoCapturer.supportedFormats(for: frontCamera).sorted { (f1, f2) -> Bool in
let width1 = CMVideoFormatDescriptionGetDimensions(f1.formatDescription).width
let width2 = CMVideoFormatDescriptionGetDimensions(f2.formatDescription).width
return width1 < width2
}).last,
// choose highest fps
let fps = (format.videoSupportedFrameRateRanges.sorted { return $0.maxFrameRate < $1.maxFrameRate }.last) else {
return
}
// capturer.startCapture(with: frontCamera, format: AVCaptureSession.Preset.hd1280x720, fps: 10)
print(format)
capturer.startCapture(
with: frontCamera, format: format, fps: 10
)
但这确实捕获了可用的最佳分辨率,而不是顶部定义的AcCaptureSession.Preset.hd1280x720。如何使用该设置捕获它?