Multiple camera capture does not work on iOS 16 with xcode 14.0 building

Recently we found one issue: Multiple camera capture does not work on iOS 16 with xcode 14.0 building, reproduce step:

  1. open front and back Camera simultaneously
  2. both front and back camera capturing return front camera stream

We expect front camera and back camera return their self stream.

Hello,

Are you seeing the same issue with the AVMultiCamPiP sample code?

Hello, We tried the method in the demo, it works.

I just list our code used before, could you help check this is a iOS or Xcode compatibility issue or we used wrong method.

before we just used following api to make it work:

  • (void)initCaptureSession

{   if (@available(iOS 13.0, *)) {     if ([self.mu_captureSession canAddInput:self.front_deviceInput]) {       [self.mu_captureSession addInput:self.front_deviceInput];     }     if ([self.mu_captureSession canAddOutput:self.front_videoDataOutput]) {       [self.mu_captureSession addOutput:self.front_videoDataOutput];     }     if ([self.mu_captureSession canAddInput:self.back_deviceInput]) {       [self.mu_captureSession addInput:self.back_deviceInput];     }     if ([self.mu_captureSession canAddOutput:self.back_videoDataOutput]) {       [self.mu_captureSession addOutput:self.back_videoDataOutput];     }   } }

Now on xcode 14 with iOS 16, we need use extra API AVCaptureInputPort & addConnection API to make it work (like demo code)

  • (void)initCaptureSession

{ if (@available(iOS 13.0, *)) { if ([self.mu_captureSession canAddInput:self.front_deviceInput]) { [self.mu_captureSession addInput:self.front_deviceInput]; } if ([self.mu_captureSession canAddOutput:self.front_videoDataOutput]) { [self.mu_captureSession addOutput:self.front_videoDataOutput]; } if ([self.mu_captureSession canAddInput:self.back_deviceInput]) { [self.mu_captureSession addInputWithNoConnections:self.back_deviceInput]; } if ([self.mu_captureSession canAddOutput:self.back_videoDataOutput]) { [self.mu_captureSession addOutputWithNoConnections:self.back_videoDataOutput];

        AVCaptureInputPort * backCameraVideoPort = [self.back_deviceInput portsWithMediaType:AVMediaTypeVideo sourceDeviceType:self.back_device.deviceType sourceDevicePosition:self.back_device.position].firstObject;
        AVCaptureConnection *backCameraVideoDataOutputConnection = [AVCaptureConnection connectionWithInputPorts:@[backCameraVideoPort] output:self.back_videoDataOutput];
        if([self.mu_captureSession canAddConnection:backCameraVideoDataOutputConnection]){
            [self.mu_captureSession addConnection:backCameraVideoDataOutputConnection];
        }
    }
}

}

Hello,

We tried the method in the demo, it works.

I just list our code used before, could you help check this is a iOS or Xcode compatibility issue or we used wrong method.

before we just used following api to make it work:

{
  if (@available(iOS 13.0, *)) {
    if ([self.mu_captureSession canAddInput:self.front_deviceInput]) {
      [self.mu_captureSession addInput:self.front_deviceInput];
    }
    if ([self.mu_captureSession canAddOutput:self.front_videoDataOutput]) {
      [self.mu_captureSession addOutput:self.front_videoDataOutput];
    }
    if ([self.mu_captureSession canAddInput:self.back_deviceInput]) {
      [self.mu_captureSession addInput:self.back_deviceInput];
    }
    if ([self.mu_captureSession canAddOutput:self.back_videoDataOutput]) {
      [self.mu_captureSession addOutput:self.back_videoDataOutput];
    }
  }
}

Now on xcode 14 with iOS 16, we need use extra API AVCaptureInputPort & addConnection API to make it work (like demo code)

- (void)initCaptureSession
{
    if (@available(iOS 13.0, *)) {
        if ([self.mu_captureSession canAddInput:self.front_deviceInput]) {
            [self.mu_captureSession addInput:self.front_deviceInput];
        }
        if ([self.mu_captureSession canAddOutput:self.front_videoDataOutput]) {
            [self.mu_captureSession addOutput:self.front_videoDataOutput];
        }
        if ([self.mu_captureSession canAddInput:self.back_deviceInput]) {
            [self.mu_captureSession addInputWithNoConnections:self.back_deviceInput];
        }
        if ([self.mu_captureSession canAddOutput:self.back_videoDataOutput]) {
            [self.mu_captureSession addOutputWithNoConnections:self.back_videoDataOutput];
            
            AVCaptureInputPort * backCameraVideoPort = [self.back_deviceInput portsWithMediaType:AVMediaTypeVideo sourceDeviceType:self.back_device.deviceType sourceDevicePosition:self.back_device.position].firstObject;
            AVCaptureConnection *backCameraVideoDataOutputConnection = [AVCaptureConnection connectionWithInputPorts:@[backCameraVideoPort] output:self.back_videoDataOutput];
            if([self.mu_captureSession canAddConnection:backCameraVideoDataOutputConnection]){
                [self.mu_captureSession addConnection:backCameraVideoDataOutputConnection];
            }
        }
    }
}
Multiple camera capture does not work on iOS 16 with xcode 14.0 building
 
 
Q