当我使用UIImagePickerController时,如何设置我想要录制的视频尺寸?
我正在开发一个应用程序,该应用程序使用UIImagePickerController,并在控件的顶部显示自定义视图。当我录制时,我发现视频的比例看起来是4:3,而不是我期待的16:4。
当我查看Apple文档时,它提供了example形式:
session.sessionPreset = AVCaptureSessionPreset1280x720;
问题在于,当我使用UIImagePickerController时,我似乎无法看到如何让会话能够设置此值。我的基于Swift 2的代码看起来有些如下(稍加编辑):
cameraController = UIImagePickerController()
if (cameraController != nil) {
cameraController!.mediaTypes = [kUTTypeMovie as String]
cameraController!.sourceType = .Camera
cameraController!.cameraCaptureMode = .Video
cameraController!.allowsEditing = false
cameraController!.delegate = self
cameraController!.showsCameraControls = false
self.recorderOverlayView = (NSBundle.mainBundle().loadNibNamed("VideoRecorderOverlayView", owner: self, options: nil)[0] as! VideoRecorderOverlayView)
if (self.recorderOverlayView != nil) {
self.recorderOverlayView!.frame = self.view!.frame
recorderOverlayView?.delegate = self;
locationLabel = recorderOverlayView?.viewWithTag(1) as? UILabel
} else {
print("view not loaded")
}
}
答案 0 :(得分:0)
虽然UIImagePickerController似乎不提供对会话的访问,但它确实有一个videoQuality属性,它似乎是设置此值的正确位置。就我而言:
cameraController!.videoQuality = .TypeIFrame1280x720