Instance Property


A clock object used for output synchronization.


var masterClock: CMClock? { get }


The returned CMClock object is read-only and provides a timebase for all sample buffers in capture output. This can be used in conjunction with the clock from an AVCaptureInput.Port object to synchronize capture output with external data sources such as motion samples.

For example, to synchronize output timestamps to the original timestamps provided by an input device, you can do the following in your fileOutput(_:didOutputSampleBuffer:from:) method:

let port = connection.inputPorts[0]
let orginalClock = port.clock
let syncedPTS = CMSampleBufferGetPresentationTime(sampleBuffer)
let originalPTS = CMSyncConvertTime(syncedPTS, session.masterClock, originalClock)

You can observe the value of this property using Key-value observing.