Immediately freeze-frame an AVCaptureSession

I'm trying the same thing. Though in my case captureStillImageAsynchronouslyFromConnection take 0.5 seconds to return, so maybe you are doing some processing in the completion handler?

If that's the case, I came up with 2 options, both of which are not sufficient for me, but might do for you

What I came up with is either:
* call stopRunning on the capture session when the completion handler is called (again, 0.5 seconds in my case), and then after processing call startRunning again.
* have an UIImageView on top of the overlay, and store the last picture taken, either from camera or video stream in this imageview while you are doing your processing.

What discouraged me from both solutions was that they both add a couple of seconds to the process. But I hope it helps, or gives a direction.

Cheers, Oded.


You just need to set your captureVideoPreviewLayer.connection.enabled = NO;

For details please see my answer here:

AVCaptureSession pause?


Simple freeze-framing gives the user the impression that the image on screen has already been taken, which is false — at least, I'd show a dimmed image. Camera.app gets around the issue by closing the "shutter".

You may be able to change the AVCaptureVideoPreviewLayer alpha to 0.5 to give the impression of a dimmed image, even though it's still running.

Another option is to use AVCaptureVideoDataOutput and some image-manipulation to get the still image. Unfortunately, it doesn't appear possible to use both AVCaptureVideoDataOutput and AVCaptureStillImageOutput at the same time; a workaround is to implement "take picture" functionality by grabbing the next video frame (of course, this is limited by your video resolution, but is fine if you just want to do image-processing on the frame).