所以我找出了问题所在.
在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)