Instance Property


The currently active depth data format of the capture device.


var activeDepthDataFormat: AVCaptureDevice.Format? { get set }


When you capture depth information with the AVCaptureDepthDataOutput class, or enable capturing depth maps alongside photos with the AVCapturePhotoOutput class, the capture output automatically uses the depth data format associated with its active photo/video capture format. Set this property's value if you need to change depth capture formats.

Depth data capture requires a compatible capture format for video/photo data. Attempting to set this property to a capture format not listed in the supportedDepthDataFormats array of the current activeFormat object raises an exception.

You may not directly set the frame rate for depth data capture. Depth data frame rate is synchronized to the device's activeVideoMinFrameDuration and activeVideoMaxFrameDuration values, and may be equal to the device's current frame rate, or lower if the device cannot produce depth data fast enough for the active video frame rate. Depth data capture may increase system load, resulting in reduced video frame rate for thermal sustainability.

Before changing the value of this property, you must call lockForConfiguration() to acquire exclusive access to the device’s configuration properties. Otherwise, setting the value of this property raises an exception. When you are done configuring the device, call unlockForConfiguration() to release the lock and allow other devices to configure the settings. You must also call lockForConfiguration() before calling the AVCaptureSession method startRunning(), or the session's preset will override the selected active format on the capture device.

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

See Also

Managing Formats

var formats: [AVCaptureDevice.Format]

The capture formats supported by the device.

var activeFormat: AVCaptureDevice.Format

The currently active media data format of the capture device.

class AVCaptureDevice.Format

A set of media format and capture settings (such as video resolution and frame rate) that can be used to configure a capture device.