Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using different resolution presets with AVFoundation

I'm trying to use AVFoundation to have three recording modes: Audio, Video and Photo. Audio and Video work just fine, but the problem is, if I set the session preset to AVCaptureSessionPreset352x288, the still pictures are also saved at that resolution. If I change my session preset to AVCaptureSessionPresetPhoto, then the photos look great but the video stops working because that isn't a supported preset for video. I've tried creating multiple sessions, reassigning the session preset, etc. but nothing seems to work. Anyone have a way to make this work with the video at a low resolution and still images at full resolution?

like image 500
Davido Avatar asked Apr 24 '26 16:04

Davido


1 Answers

before taking the picture set the property for a new session preset

// captureSession is your capture session object
[captureSession beginConfiguration];
captureSession.sessionPreset = AVCaptureSessionPresetHigh;
[captureSession commitConfiguration];

then call your capture image handler

captureStillImageAsynchronouslyFromConnection: completionHandler:

then change back to low res (= prevPreset)

[captureSession beginConfiguration];
captureSession.sessionPreset = prevPreset;
[captureSession commitConfiguration];
like image 152
Avner Barr Avatar answered Apr 26 '26 10:04

Avner Barr