How to change size setting of video capturing by AVFoundation
if ([self.captureSession canSetSessionPreset:AVCaptureSessionPreset640x480]) {
[self.captureSession setSessionPreset:AVCaptureSessionPreset640x480];
}
You can change the resolution using the sessionPreset
property.
Default value of session preset is AVCaptureSessionPresetHigh
which is suitable for high quality video and audio output.
You can set the session preset like:
[self.yourSession setSessionPreset:AVCaptureSessionPresetLow];
sessionPreset
A constant value indicating the quality level or bitrate of the output. @property(nonatomic, copy) NSString *sessionPreset Discussion
You use this property to customize the quality level or bitrate of the output. For possible values of sessionPreset, see “Video Input Presets.” The default value is AVCaptureSessionPresetHigh.
You can set this value while the session is running.
You can only set a preset if
canSetSessionPreset
: returns YES for that preset. AvailabilityAvailable in iOS 4.0 and later.
Declared In AVCaptureSession.h
The possible values of session preset is:
Video Input Presets
Constants to define capture setting presets using the
sessionPreset
property.NSString *const AVCaptureSessionPresetPhoto;
NSString *const AVCaptureSessionPresetHigh;
NSString *const AVCaptureSessionPresetMedium;
NSString *const AVCaptureSessionPresetLow;
NSString *const AVCaptureSessionPreset352x288;
NSString *const AVCaptureSessionPreset640x480;
NSString *const AVCaptureSessionPreset1280x720;
NSString *const AVCaptureSessionPreset1920x1080;
NSString *const AVCaptureSessionPresetiFrame960x540;
NSString *const AVCaptureSessionPresetiFrame1280x720;
Constant Details :
AVCaptureSessionPresetPhoto
Specifies capture settings suitable for high resolution photo quality output. Available in iOS 4.0 and later. Declared in AVCaptureSession.h.
AVCaptureSessionPresetHigh
Specifies capture settings suitable for high quality video and audio output. Available in iOS 4.0 and later. Declared in AVCaptureSession.h.
AVCaptureSessionPresetMedium
Specifies capture settings suitable for output video and audio bitrates suitable for sharing over WiFi. Available in iOS 4.0 and later. Declared in AVCaptureSession.h.
AVCaptureSessionPresetLow
Specifies capture settings suitable for output video and audio bitrates suitable for sharing over 3G. Available in iOS 4.0 and later. Declared in AVCaptureSession.h.
AVCaptureSessionPreset352x288
Specifies capture settings suitable for CIF quality (352x288 pixel) video output. Available in iOS 5.0 and later. Declared in AVCaptureSession.h.
AVCaptureSessionPreset640x480
Specifies capture settings suitable for VGA quality (640x480 pixel) video output. Available in iOS 4.0 and later. Declared in AVCaptureSession.h.
AVCaptureSessionPreset1280x720
Specifies capture settings suitable for 720p quality (1280x720 pixel) video output. Available in iOS 4.0 and later. Declared in AVCaptureSession.h.
AVCaptureSessionPreset1920x1080
Specifies capture settings suitable for 1080p quality (1920x1080 pixel) video output. Available in iOS 5.0 and later. Declared in AVCaptureSession.h.
AVCaptureSessionPresetiFrame960x540
Specifies capture settings to achieve 960x540 quality iFrame H.264 video at about 30 Mbits/sec with AAC audio. QuickTime movies captured in iFrame format are optimal for editing applications. Available in iOS 5.0 and later. Declared in AVCaptureSession.h.
AVCaptureSessionPresetiFrame1280x720
Specifies capture settings to achieve 1280x720 quality iFrame H.264 video at about 40 Mbits/sec with AAC audio. QuickTime movies captured in iFrame format are optimal for editing applications. Available in iOS 5.0 and later. Declared in AVCaptureSession.h.
Please refer : AVCaptureSession