<!--
{
  "documentType" : "article",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/capture-device-formats",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Formats"
}
-->

# Formats

Configure capture formats and camera frame rates.

## Discussion

The following code example illustrates how to select an iOS device’s highest possible frame rate:

```swift
func configureCameraForHighestFrameRate(device: AVCaptureDevice) {
    
    var bestFormat: AVCaptureDevice.Format?
    var bestFrameRateRange: AVFrameRateRange?

    for format in device.formats {
        for range in format.videoSupportedFrameRateRanges {
            if range.maxFrameRate > bestFrameRateRange?.maxFrameRate ?? 0 {
                bestFormat = format
                bestFrameRateRange = range
            }
        }
    }
    
    if let bestFormat = bestFormat, 
       let bestFrameRateRange = bestFrameRateRange {
        do {
            try device.lockForConfiguration()
            
            // Set the device's active format.
            device.activeFormat = bestFormat
            
            // Set the device's min/max frame duration.
            let duration = bestFrameRateRange.minFrameDuration
            device.activeVideoMinFrameDuration = duration
            device.activeVideoMaxFrameDuration = duration
            
            device.unlockForConfiguration()
        } catch {
            // Handle error.
        }
    }
}
```

Most common configurations of capture settings are available through the [`AVCaptureSession`](/documentation/AVFoundation/AVCaptureSession) object and its available presets. However, on iOS devices, some specialized options (such as high frame rate) require directly setting a capture format on an [`AVCaptureDevice`](/documentation/AVFoundation/AVCaptureDevice) instance.

> Note:
> In iOS, directly configuring a capture device’s ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/activeFormat`` property changes the capture session’s preset to ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureSession/Preset/inputPriority``. Upon making this change, the capture session no longer automatically configures the capture format when you call the ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureSession/startRunning()`` method or call the ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureSession/commitConfiguration()`` method after changing the session topology.
> 
> In macOS, a capture session can still automatically configure the capture format after you make changes. To prevent automatic changes to the capture format in macOS, follow the advice listed under the ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/lockForConfiguration()`` method.

## Topics

### Configuring capture formats

[`var formats: [AVCaptureDevice.Format]`](/documentation/AVFoundation/AVCaptureDevice/formats)

The capture formats a device supports.

[`var activeFormat: AVCaptureDevice.Format`](/documentation/AVFoundation/AVCaptureDevice/activeFormat)

The capture format in use by the device.

[`var activeDepthDataFormat: AVCaptureDevice.Format?`](/documentation/AVFoundation/AVCaptureDevice/activeDepthDataFormat)

The currently active depth data format of the capture device.

[`class Format`](/documentation/AVFoundation/AVCaptureDevice/Format)

A class that defines media formats and capture settings that capture devices support.

### Configuring frame durations

[`var activeVideoMinFrameDuration: CMTime`](/documentation/AVFoundation/AVCaptureDevice/activeVideoMinFrameDuration)

The currently active minimum frame duration.

[`var activeVideoMaxFrameDuration: CMTime`](/documentation/AVFoundation/AVCaptureDevice/activeVideoMaxFrameDuration)

The currently active maximum frame duration.

[`var activeDepthDataMinFrameDuration: CMTime`](/documentation/AVFoundation/AVCaptureDevice/activeDepthDataMinFrameDuration)

The minimum frame duration of depth data.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)