Take RAW photo with zoom

We would like to develop an app which captures the centre area of a RAW photo, whilst displaying this in the viewfinder.

In our CameraViewController we have videoDeviceInput.device.videoZoomFactor = 8 and the expected zoomed in image appears in the viewfinder. We are also able to set aperture and exposure settings correctly for the area we're interested in.

When it comes to taking the photo we check for availableRawFormat and set photoSettings = AVCapturePhotoSettings(rawPixelFormatType: availableRawFormat )

Unfortunately this crashes with an error saying raw photos can't be taken with the zoomed device.

A workaround we have now is to set the zoom factor to 1 and wait a bit until the photo is taken. We then do the demosaic manually for the centre of the photo. However wondering if there is a better solution?

Take RAW photo with zoom
 
 
Q