I'm getting the same error from ScreenCaptureKit, and I suspect it's coming from ReplayKit, did you find any solution?
Post
Replies
Boosts
Views
Activity
@lzell I was able to "fix" it by changing the CaptureEngine class to also implement SCStreamOutput and SCStreamDelegate. So now, I'm sending self instead of streamOutput to addStreamOutput.
try stream?.addStreamOutput(self, type: .screen, sampleHandlerQueue: videoSampleBufferQueue)
Replacing the createPCMBuffer func for this one fixed the issue (source: https://stackoverflow.com/questions/75228267/avaudioplayernode-causing-distortion)
Are there any concerns in doing it this way?
func createPCMBuffer(from sampleBuffer: CMSampleBuffer) -> AVAudioPCMBuffer? {
let numSamples = AVAudioFrameCount(sampleBuffer.numSamples)
let format = AVAudioFormat(cmAudioFormatDescription: sampleBuffer.formatDescription!)
let pcmBuffer = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: numSamples)!
pcmBuffer.frameLength = numSamples
CMSampleBufferCopyPCMDataIntoAudioBufferList(sampleBuffer, at: 0, frameCount: Int32(numSamples), into: pcmBuffer.mutableAudioBufferList)
return pcmBuffer
}
Thanks