Liron Liron - 5 months ago 16
iOS Question

iPhone 5 retina display aspect ratio from AVFoundation

AVFoundation provides different image aspect ratios that one can use when displaying video.

For example:

- NSString *const AVCaptureSessionPreset320x240;
- NSString *const AVCaptureSessionPreset352x288;
- NSString *const AVCaptureSessionPreset640x480;


http://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html#//apple_ref/doc/c_ref/AVCaptureSessionPresetHigh

On the iPhone4 and iPad, these resolutions are designed to be full-screen. But on an iPhone 5 with a retina display, the iPhone display is taller.

How is one supposed to handle displaying the video feed coming out of AvFoundation? Any options other than having to choose a larger aspect ratio and crop it, scale the video (messing up its aspect ratio), or leave some empty screen real estate in our app?

Answer

You can use AVCaptureSessionPreset1920x1080 preset on iPhone 5. See the AVCaptureSession Class Reference for iOS.

EDIT:

AVCaptureSessionPresetiFrame960x540 preset has the same ratio as AVCaptureSessionPreset1920x1080. This should be the best choice if you want to improve performance and keep the aspect ratio.