如果我实例化一个
AVCaptureSession
并使用 addInput
和 addOutput
添加视频输入和输出,那么 AVCaptureConnection
的实例就会自动形成(正如 Apple 文档所述,“贪婪地”)。
我想访问连接,以便可以更改
videoOrientation
属性。
如何访问连接?我本以为会是类似
captureSession.connections
的东西,但事实并非如此。
我像这样改变我的视频方向:
let stillImageOutput = AVCaptureStillImageOutput()
var previewLayer :AVCaptureVideoPreviewLayer?
let vidConnection :AVCaptureConnection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo)
stillImageOutput.connectionWithMediaType(AVMediaTypeVideo).videoOrientation = previewLayer!.connection.videoOrientation
stillImageOutput.captureStillImageAsynchronouslyFromConnection