iosobjective-ccameraavcapturesessionavcapturedevice

camera.activeFormat not getting applied


we are trying to set a specific camera frame resolution in our iOS application (written in Objective-C) which is not defined in the AVCaptureSessionPreset. With the following code we would like to set the frame dimensions to a specific width:

  for ( AVCaptureDeviceFormat *format in [self.camera formats] ) {
    NSLog(@"%@", format);
    CMVideoDimensions dim = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
    if(dim.width == 3264){
      if ([ self.camera lockForConfiguration:NULL] == YES) {
        self.camera.activeFormat = format;
        [ self.camera unlockForConfiguration];
      }

    }
  }

However the resolution is set to 1920x1080 - which is a default value, i guess? Is there a specific order which defines when to call camera configurations?


Solution

  • You need to set the AVCaptureSessionPreset property of AVCaptureSession to AVCaptureSessionPresetInputPriority.