AVAssetWriterInput appendSampleBuffer崩溃

时间:2015-07-24 01:22:13

标签: ios swift avfoundation avcapturesession avassetwriter

我有一个audioWriterBuffer,我附加了音频样本缓冲区,如下所示

func captureOutput(captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, fromConnection connection: AVCaptureConnection!) {

    if CMSampleBufferDataIsReady(sampleBuffer) <= 0 {
        return
    }

    if captureOutput == audioOutput && audioWriterBuffer != nil && audioWriterBuffer.readyForMoreMediaData == true {
        var audioTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer)
        audioWriterBuffer.appendSampleBuffer(sampleBuffer)
    }
}

它按预期工作。然而,每隔一段时间,它就会崩溃并出现以下错误:

  

NSArray在被枚举时发生了变异。

at:

audioWriterBuffer.appendSampleBuffer(sampleBuffer)

我不明白它的相关性,或者如何解决它。

有任何线索吗?

0 个答案:

没有答案