What Is the Role of Avcapturedevicetype.Builtindualcamera

AVCaptureDevice devices are empty

Not all iPhones contain dual camera, that's why devices is empty.

You can try add this deviceTypes: [.builtInWideAngleCamera].

Here is all available device types for now.

Also there is a good answer to question about Dual Camera - check this.

Hope this will help you!

Capture frames from both cameras (TelePhoto and WideAngle) in the same time

Yes, it's possible.

Just pick the right configuration.


Capture device should be builtInDualCamera:

let captureDevice = AVCaptureDevice.default(.builtInDualCamera, for: .video, position: .back)

Configure capture photo output after configuring capture session:

captureSession = AVCaptureSession()
captureSession?.sessionPreset = AVCaptureSession.Preset.photo
captureSession?.addInput(input)
captureSession?.addOutput(capturePhotoOutput!)

capturePhotoOutput?.isHighResolutionCaptureEnabled = true

capturePhotoOutput?.isDualCameraDualPhotoDeliveryEnabled = true


Configure photo settings before capture the photo:

let photoSettings = AVCapturePhotoSettings()
photoSettings.isAutoStillImageStabilizationEnabled = true
photoSettings.isHighResolutionPhotoEnabled = true
photoSettings.isAutoDualCameraFusionEnabled = false

photoSettings.isDualCameraDualPhotoDeliveryEnabled = true


Implement AVCapturePhotoCaptureDelegate, and override next method:

public func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?)

You will receive 2 photoOutput callbacks!

How to get front camera, back camera and audio with AVCaptureDeviceDiscoverySession

You can get the front camera with the following:

AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .front)

The back camera:

AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .back)

And the microphone:

AVCaptureDevice.default(.builtInMicrophone, for: AVMediaType.audio, position: .unspecified)


Related Topics



Leave a reply



Submit