Instance Property


The currently active media data format of the capture device.


var activeFormat: AVCaptureDevice.Format { get set }


You use this property to get or set the currently active device format.

In iOS, you should generally set the session preset on an AVCaptureSession object to configure image or video capture and use the shared AVAudioSession object to configure audio capture. When using a session preset, the session automatically controls the capture device’s active format. However, some specialized capture options (such as high frame rate) are not available in session presets. For these options, you can set the capture device’s active format instead. Doing so changes the associated capture session’s preset to inputPriority.

Attempting to set the active format to one not present in the formats array throws an invalidArgumentException.

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.

class AVCaptureDevice.Format

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