当前位置:  开发笔记 > IOS > 正文

iOS Swift - AVCaptureSession - 捕获尊重帧速率的帧

如何解决《iOSSwift-AVCaptureSession-捕获尊重帧速率的帧》经验,为你挑选了1个好方法。



1> Richard Pool..:

所以我找出了问题所在.

AVCaptureDevice.h上面的评论部分,该activeVideoMinFrameDuration财产说明:

在iOS上,接收者的activeVideoMinFrameDuration在以下条件下重置为其默认值:

- The receiver's activeFormat changes
- The receiver's AVCaptureDeviceInput's session's sessionPreset changes
- The receiver's AVCaptureDeviceInput is added to a session

最后一个要点导致我的问题,所以做以下操作解决了我的问题:

        do {

            let input : AVCaptureDeviceInput = try AVCaptureDeviceInput(device: captureDevice)

            if session.canAddInput(input) {
                try session.addInput(input)
            }

            try captureDevice.lockForConfiguration()
            captureDevice.activeVideoMinFrameDuration = CMTimeMake(1, 2)
            captureDevice.activeVideoMaxFrameDuration = CMTimeMake(1, 2)
            captureDevice.unlockForConfiguration()

            let output : AVCaptureVideoDataOutput = AVCaptureVideoDataOutput()

            let dispatch_queue : dispatch_queue_t = dispatch_queue_create("streamoutput", nil)
            output.setSampleBufferDelegate(self, queue: dispatch_queue)

            session.addOutput(output)

推荐阅读
mobiledu2402851377
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有