I have a video AVCaptureDevice( AVMediaTypeVideo), briefly reducing the exposure with setExposureTargetBias:completionHandler, and then restoring it again. I need to know exactly which buffer in captureOutput:didOutputSampleBuffer:fromConnection:corresponds to the first frame with reduced exposure.
The docs say:
The block receives a timestamp that corresponds to the first buffer to which this setting was applied. The timestamp is synchronized with the device’s clock, and thus must be converted to the main clock before being compared to the timestamps of the buffers delivered through the AVCaptureVideoDataOutput instance.
https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVCaptureDevice_Class/#//apple_ref/occ/instm/AVCaptureDevice/setExposureTargetBias:completionHandler :
How do I get a “device clock”? I did the following in completionHandler, although the host time clock seems to match the main clock.
CMClockRef masterClock = self.captureSession.masterClock;
CMClockRef deviceClock = CMClockGetHostTimeClock();
syncTimeConverted = CMSyncConvertTime( syncTime, deviceClock, masterClock );
I intend to do the following in captureOutput:didOutputSampleBuffer:fromConnection:order to check if the buffer is the one I want
CMTime bufferTime = CMSampleBufferGetPresentationTimeStamp( sampleBuffer );
bool isDroppedExposureFrame = CMTimeCompare( bufferTime, syncTimeConverted ) == 0;
Am I on the right track?
source
share