How do I set the video dimensions that I want to record with, when I use the UIImagePickerController?
I am developing an application that uses the UIImagePickerController with a custom view on top for the controls. When I record I am finding the proportions of the video look 4:3, rather than the 16:4 I am expecting.
When I look at the Apple documentation it provides an example of the form:
session.sessionPreset = AVCaptureSessionPreset1280x720;
The issue is that I can't seem to see how to get the session to be able to set this value, when I use the UIImagePickerController. My Swift 2 based code looks somewhat as follows (slightly edited):
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")
}
}
While UIImagePickerController doesn't seem to provide access to the session, it does have a videoQuality property, which seems to be the right place to set this value. In my case:
cameraController!.videoQuality = .TypeIFrame1280x720