FPS

Adjusting Frame Rate (FPS) for Preview, Video and Frame outputs

A Camera's Frame Rate can be configured per CameraSessionConnection and affects Preview- (see "The Preview Output"), Video- (see "The Video Output") and Frame- (see "The Frame Output") outputs.

Get available FPS ranges

Each CameraDevice lists its available FPS range and resolution combinations via its available CameraFormats:

const device = ...
const format = useCameraFormat(device, [
  { fps: 60 },
  { videoResolution: 'max' }
])
const device = ...
const format = getCameraFormat(device, [
  { fps: 60 },
  { videoResolution: 'max' }
])

Tip

See "Camera Formats" for more information about CameraFormats.

Set FPS

To set the FPS range, you must set both FPS and CameraFormat:

function App() {
  const device = useCameraDevice('back')
  const format = useCameraFormat(device, [
    { fps: 60 },
    { videoResolution: 'max' }
  ])

  return (
    <Camera
      style={StyleSheet.absoluteFill}
      isActive={true}
      device={device}
      format={format}
      fps={{ min: format.maxFps, max: format.maxFps }}
    />
  )
}
function App() {
  const device = useCameraDevice('back')
  const format = useCameraFormat(device, [
    { fps: 60 },
    { videoResolution: 'max' }
  ])
  const camera = useCamera({
    isActive: true,
    device: device,
    format: format,
    fps: { min: format.maxFps, max: format.maxFps }
  })
}
const session = await HybridCameraFactory.createCameraSession(false)
const device = await getDefaultCameraDevice('back')
const format = getCameraFormat(device, [
  { fps: 60 },
  { videoResolution: 'max' }
])
await session.configure([
  {
    input: device,
    config: {
      format: format,
      fps: { min: format.maxFps, max: format.maxFps }
    }
  }
], {})
await session.start()

FPS is a Range

FPS is a Range with a minimum and maximum value.

When min and max are the same value, the Camera will stream at the fixed given Frame Rate. However when min is smaller than max, the Camera may automatically throttle its Frame Rate when needed - for example in low light conditions to automatically allow for longer exposure duration.

Warning

Make sure the currently selected CameraFormat supports the given Range in supportedFpsRanges.