繁体   English   中英

AVCapturePhotoOutput不接受AVCaptureDevice的ExposureDuration和iso

[英]AVCaptureDevice's exposureDuration and iso not honored by AVCapturePhotoOutput

问题:使用AVCaptureDevice.setExposureModeCustom设置快速的“快门速度”(exposureDuration)和高ISO,调用AVCapturePhotoOutput拍照,然后在生成的图像中看到未使用ExposureDuration / ISO(即使实时视频源显示了它使用持续时间/ ISO通过按预期方式变亮/变暗)

原来应该归咎于AVCapturePhotoSettings.isAutoStillImageStabilizationEnabled :默认情况下为true,如果为true, 则可以忽略/重置曝光时间和ISO设置

解决方案是在使用自定义曝光设置时将其设置为false,如下所示:

        // self.customDuration is nil if we're on auto-exposure, non-nil if we are on manual exposure, ie. we called AVCaptureDevice.setExposureModeCustom
        let photoSettings: AVCapturePhotoSettings
        if self.photoOutput.availablePhotoCodecTypes.contains(.hevc), heicSupported {
            photoSettings = AVCapturePhotoSettings(format:
                [AVVideoCodecKey: AVVideoCodecType.hevc])
        } else {
            photoSettings = AVCapturePhotoSettings(format:
                [AVVideoCodecKey: AVVideoCodecType.jpeg])
        }
        // auto still image stabilization destroys our settings for custom exposure (iso, duration), so turn it off if we have any
        photoSettings.isAutoStillImageStabilizationEnabled = self.customDuration == nil ?
            self.photoOutput.isStillImageStabilizationSupported : false

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM