如何设置AVCaptureFileOutput
的方向?我指的是最终输出,它必须是风景。
答案 0 :(得分:0)
设置相机时,您有AVCaptureVideoDataOutput videoDataOutput和AVCaptureVideoPreviewLayer previewLayer。您可以通过以下方式配置它们。
//set the orientation of previewlayer, which is presented to user
AVCaptureConnection *conncetion = self.previewLayer.connection;
conncetion.videoOrientation = AVCaptureVideoOrientationLandscapeRight;
//set the output frame orientation
AVCaptureConnection *conn = [self.videoDataOutput connectionWithMediaType:AVMediaTypeVideo];
conn.videoOrientation = AVCaptureVideoOrientationLandscapeRight;
在AVCam示例代码中,录制并保存为文件时。以上两个设置为相同的方向,即viewcontroller的interfaceOrientation:
[[[self movieFileOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] videoOrientation]];
它观察设备方向,这很好。