ios/iphone photo burst mode api

南楼画角 提交于 2019-12-03 01:28:06

captureStillImageAsynchronouslyFromConnection:completionHandler: isn't, I believe, what Apple is using for its burst mode.

Instead, Apple is* grabbing video frames at full resolution (which is supported by the 5s). Here's how:

The AVCaptureDevice has its activeFormat set to full sensor resolution, then you grab and process 10 frames per second from AVCaptureVideoDataOutputSampleBufferDelegate's captureOutput:didOutputSampleBuffer:fromConnection:, firing off a shutter sound for each frame grab.

You'll need to have a fall-back (either lower-resolution images or a slower burst mode) for devices that don't support video at the full sensor-size resolution—and/or if you want to support anything older than iOS 7.x.

Note that you can't have multiple concurrent usage of captureStillImageAsynchronouslyFromConnection:completionHandler: without some extremely unexpected results. This is why you should call each iteration from the previous one's completionHandler (which, in essence, is what your semaphore is doing). Also, you may wish to switch from PNG as your file format for burst shots—it saves very slowly and requires a lot of system resource—stacking up 15 or 20 PNGs could cause you some serious grief!

*It's probably doing this, because it may, of course, be using a private API to achieve the same end result.

Use this method for burst mode in iOS 8 and above:

- (void)captureStillImageBracketAsynchronouslyFromConnection:(AVCaptureConnection *)connection withSettingsArray:(NSArray *)settings completionHandler:(void (^)(CMSampleBufferRef sampleBuffer, AVCaptureBracketedStillImageSettings *stillImageSettings, NSError *error))handler NS_AVAILABLE_IOS(8_0);

Documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!