diff --git a/package/ios/CameraView+AVCaptureSession.swift b/package/ios/CameraView+AVCaptureSession.swift index 08ed94f..9cce748 100644 --- a/package/ios/CameraView+AVCaptureSession.swift +++ b/package/ios/CameraView+AVCaptureSession.swift @@ -140,7 +140,20 @@ extension CameraView { */ private func getPixelFormat(videoOutput: AVCaptureVideoDataOutput) -> OSType { // as per documentation, the first value is always the most efficient format - let defaultFormat = videoOutput.availableVideoPixelFormatTypes.first! + var defaultFormat = videoOutput.availableVideoPixelFormatTypes.first! + if enableBufferCompression { + // use compressed format instead if we enabled buffer compression + if defaultFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange && + videoOutput.availableVideoPixelFormatTypes.contains(kCVPixelFormatType_Lossless_420YpCbCr8BiPlanarVideoRange) { + // YUV 4:2:0 8-bit (limited video colors; compressed) + defaultFormat = kCVPixelFormatType_Lossless_420YpCbCr8BiPlanarVideoRange + } + if defaultFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange && + videoOutput.availableVideoPixelFormatTypes.contains(kCVPixelFormatType_Lossless_420YpCbCr8BiPlanarFullRange) { + // YUV 4:2:0 8-bit (full video colors; compressed) + defaultFormat = kCVPixelFormatType_Lossless_420YpCbCr8BiPlanarFullRange + } + } // If the user enabled HDR, we can only use the YUV 4:2:0 10-bit pixel format. if hdr == true {