How to achieve video stabilization (smoothness) in AVCaptureSession similar to the experience of video capture in IOS Camera app?

I'm trying to build an app that also has video capture/recording in-build. I'm using AVCaptureSession for video recording and tried various preset and stabilizationMode but nothing got me the smoothness that comes along with the iOS camera app video recording. The preview layer I see is similar to the camera preview in the photo mode of iOS camera app but nowhere close to the preview layer of the video mode of iOS camera app.

I used stabilizationMode as below but to no effect.

if (connection?.isVideoStabilizationSupported)! {

connection?.preferredVideoStabilizationMode = AVCaptureVideoStabilizationMode.cinematicExtended

}


Not sure what I'm doing wrong. Any help will be much appreciated.


Thanks,

Venkat