title: How to enable Stabilization and HDR in IOS Camera?
body: <p><strong>What I Did:-</strong></p>
  
  <p>I have tried to enable <strong>stabilization</strong> and <strong>HDR</strong> but it's not working.I think I was in right path.When I was trying to check that the current device supports stabilization and HDR in that both case I had got only false case in all devices.</p>
  
  <p>Please guide me if any mistakes had done in the below code snippet.</p>
  
  <p>Thanks in advance!!</p>
  
  <p><strong>My Code Snippet:-</strong></p>
  
  <pre><code>func createAVSession() throws -&gt; AVCaptureSession {
          AppLog.LogFunction(object: LOG_Start)
  
          // Start out with low quality
          let session = AVCaptureSession()
          session.sessionPreset = AVCaptureSessionPresetPhoto
  
          // Input from video camera
          let device = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
          let currentFormat = device?.activeFormat.isVideoHDRSupported
          try device?.lockForConfiguration()
          if device?.activeFormat.isVideoHDRSupported == true {
              device?.automaticallyAdjustsVideoHDREnabled = false
              device?.isVideoHDREnabled = true
              print("device?.isVideoHDREnabled\(device?.isVideoHDREnabled)")
          }
  
          if (device?.isFocusModeSupported(.continuousAutoFocus))! {
              device?.focusMode = AVCaptureFocusMode.continuousAutoFocus
              print("device?.focusMode\(device?.focusMode.rawValue)")
          }
          if (device?.isSmoothAutoFocusSupported)! {
              device?.isSmoothAutoFocusEnabled = true
              print("device?.isSmoothAutoFocusEnabled\(device?.isSmoothAutoFocusEnabled)")
          }
  
          if (device?.isExposureModeSupported(.continuousAutoExposure))! {
              device?.exposureMode = .continuousAutoExposure
              print("device?.exposureMode\(device?.exposureMode.rawValue)")
          }
          device?.unlockForConfiguration()
  
          let input = try AVCaptureDeviceInput(device: device)
          do {
              try input.device.lockForConfiguration()
              input.device.activeVideoMaxFrameDuration =  CMTimeMake(1, 30)
              input.device.activeVideoMinFrameDuration =  CMTimeMake(1, 30)
              input.device.unlockForConfiguration()
          }
          catch {
              print("Failed to set FPS")
          }
  
          // Output
          let videoOutput = AVCaptureVideoDataOutput()
  
          videoOutput.videoSettings = [ kCVPixelBufferPixelFormatTypeKey as AnyHashable: kCVPixelFormatType_32BGRA]
          videoOutput.alwaysDiscardsLateVideoFrames = true
          videoOutput.setSampleBufferDelegate(self, queue: sessionQueue)
  
          let stillImageOutput: AVCaptureStillImageOutput = AVCaptureStillImageOutput()
          stillImageOutput.outputSettings = [AVVideoCodecKey: AVVideoCodecJPEG]
  
          //stillImageOutput.isHighResolutionStillImageOutputEnabled = true
  
          if stillImageOutput.isStillImageStabilizationSupported {
              stillImageOutput.automaticallyEnablesStillImageStabilizationWhenAvailable = true
              print("stillImageOutput.isStillImageStabilizationActive\(stillImageOutput.isStillImageStabilizationActive)")
          }
  
          // Join it all together
          session.addInput(input)
          session.addOutput(videoOutput)
  
        if session.canAddOutput(stillImageOutput) {
              session.addOutput(stillImageOutput)
            self.stillImageOutput = stillImageOutput
  
        }
  
  
  
          if let connection = videoOutput.connection(withMediaType: AVMediaTypeVideo) {
              if connection.isVideoOrientationSupported {
                  connection.videoOrientation = .portrait
              }
              if connection.isVideoStabilizationSupported {
                  connection.preferredVideoStabilizationMode = .standard
                  print("connection.activeVideoStabilizationMode\(connection.activeVideoStabilizationMode.rawValue)")
              }
          }
  
  
          AppLog.LogFunction(object: LOG_End)
          return session
      }
  </code></pre>