我正在使用ios 11,swift 4并使用av基础库捕获图片。我有一个自定义预览,如图所示,mysettings如建议。问题是当我捕获并保存CMSample缓冲区时,它是leftLandscape。我试图更改CapturePhotoOutput方向,但它不能改变?(更改photoOutputConnection.videoOrientation什么都不改变?)
if let photoOutputConnection = capturePhotoOutput.connection(with: AVMediaType.video) {
if(photoOutputConnection.isVideoOrientationSupported) {
print("video oryantasyonu = \(photoOutputConnection.videoOrientation)")
} else {
print("video oryantasyonu desteklenmiyor ?!")
}
}
这是从xcode调试快速视图中获取的捕获输出:
这是会话配置:
self.capturePhotoOutput = AVCapturePhotoOutput()
capturePhotoOutput.isHighResolutionCaptureEnabled = true
// A Live Photo captures both a still image and a short movie centered on the moment of capture,
// which are presented together in user interfaces such as the Photos app.
capturePhotoOutput.isLivePhotoCaptureEnabled = capturePhotoOutput.isLivePhotoCaptureSupported
guard self.captureSession.canAddOutput(capturePhotoOutput) else { return }
// The sessionPreset property of the capture session defines the resolution and quality level of the video output.
// For most photo capture purposes, it is best set to AVCaptureSessionPresetPhoto to deliver high resolution photo quality output.
self.captureSession.sessionPreset = AVCaptureSession.Preset.photo
self.captureSession.addOutput(capturePhotoOutput)
self.captureSession.commitConfiguration()