---
title: Formats
framework: avfoundation
role: collectionGroup
role_heading: API Collection
path: avfoundation/capture-device-formats
---

# Formats

Configure capture formats and camera frame rates.

## Overview

Overview The following code example illustrates how to select an iOS device’s highest possible frame rate: 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 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 instance. note: In iOS, directly configuring a capture device’s activeFormat property changes the capture session’s preset to inputPriority. Upon making this change, the capture session no longer automatically configures the capture format when you call the startRunning() method or call the 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 lockForConfiguration() method.

## Topics

### Configuring capture formats

- [formats](avfoundation/avcapturedevice/formats.md)
- [activeFormat](avfoundation/avcapturedevice/activeformat.md)
- [activeDepthDataFormat](avfoundation/avcapturedevice/activedepthdataformat.md)
- [AVCaptureDevice.Format](avfoundation/avcapturedevice/format.md)

### Configuring frame durations

- [activeVideoMinFrameDuration](avfoundation/avcapturedevice/activevideominframeduration.md)
- [activeVideoMaxFrameDuration](avfoundation/avcapturedevice/activevideomaxframeduration.md)
- [activeDepthDataMinFrameDuration](avfoundation/avcapturedevice/activedepthdataminframeduration.md)

## See Also

### Configuring camera hardware

- [lockForConfiguration()](avfoundation/avcapturedevice/lockforconfiguration().md)
- [unlockForConfiguration()](avfoundation/avcapturedevice/unlockforconfiguration().md)
- [isSubjectAreaChangeMonitoringEnabled](avfoundation/avcapturedevice/issubjectareachangemonitoringenabled.md)
- [subjectAreaDidChangeNotification](avfoundation/avcapturedevice/subjectareadidchangenotification.md)
- [Focus](avfoundation/capture-device-focus.md)
- [Exposure](avfoundation/capture-device-exposure.md)
- [White balance](avfoundation/capture-device-white-balance.md)
- [Lighting](avfoundation/capture-device-lighting.md)
- [Color](avfoundation/capture-device-color.md)
- [Zoom](avfoundation/capture-device-zoom.md)
