I am created a app that record video and upload it on server,but video recorded at very high resolution , i want to decrease its resolution, i learn about AVCaptureSessionPreset640x480 on internet but i dont know how to use it.
5 Answers
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

- 103,496
- 31
- 153
- 200
-
your description on this topic is awesome. – Nov 02 '12 at 08:35
-
Do you know how to record video without setting a sessionPreset? I'm getting the error in https://stackoverflow.com/questions/46160407/how-do-i-record-a-video-on-ios-without-using-a-preset – Kartick Vaddadi Sep 13 '17 at 15:49
-
very nice explanation. – Numan Karaaslan Oct 04 '17 at 08:48
-
Sorry, but copying the header file in here helps very little. Quality Presets do configure video resolution - but only to a small predefined set of resolutions. Not to any arbitrary resolution you want. So this is not a viable answer. – Motti Shneor Jul 10 '19 at 12:13
if ([self.captureSession canSetSessionPreset:AVCaptureSessionPreset640x480]) {
[self.captureSession setSessionPreset:AVCaptureSessionPreset640x480];
}

- 8,970
- 5
- 44
- 65
For Swift 2.2 & 3.0:
captureSession.sessionPreset = AVCaptureSessionPreset640x480
Unfortunately, this is not setup as an enum, so it currently lacks type safety since sessionPreset is a String
.

- 35,668
- 12
- 125
- 132
2019 swift 5
var session : AVCaptureSession?
self.session!.sessionPreset = AVCaptureSession.Preset.medium;

- 1,611
- 17
- 22
It's important to use one of these:
NSString *const AVCaptureSessionPresetHigh;
NSString *const AVCaptureSessionPresetMedium;
NSString *const AVCaptureSessionPresetLow;
That way you don't run into a phone that doesn't support your specific specs. Unless you write code to check every time.

- 1,111
- 10
- 17