AVCaptureVideoDataOutput Resolution

        //Add video data output
        self.bufferFrameQueue = DispatchQueue(label: "bufferFrame queue", qos: .userInitiated,  attributes: [.concurrent], autoreleaseFrequency: .workItem)
 
        self.videoDataOutput = AVCaptureVideoDataOutput()
        if self.session.canAddOutput(self.videoDataOutput!) {
            self.session.addOutput(videoDataOutput!)
            self.videoDataOutput!.alwaysDiscardsLateVideoFrames = true
            self.videoDataOutput!.connection(with: AVMediaType.video)?.videoOrientation = .portrait
            self.videoDataOutput!.videoSettings = [kCVPixelBufferPixelFormatTypeKey: Int(kCVPixelFormatType_32BGRA),
                                                   kCVPixelBufferHeightKey: 960,
                                                   kCVPixelBufferWidthKey: 720] as [String : Any]
            self.videoDataOutput!.setSampleBufferDelegate(self, queue: self.bufferFrameQueue)
        }

I am trying to specify output size to be 960x720 in video settings. However, it doesnt seem to work.


Any other way to get the vidao data output in a custom lower resolution?