I'm using code from this sample: https://developer.apple.com/documentation/screencapturekit/capturing-screen-content-in-macos
It's the same as the code posted by @mac_cain13 that uses .withAudioBufferList function.
It doesn't work for me when capturing microphone audio with ScreenCaptureKit on macOS 15.3.1 - the function always returns nil. However, the same code works without an issue when capturing system audio with ScreenCaptureKit. It only fails to create AVAudioPCMBuffer from CMSampleBuffer when capturing microphone. The sample buffer with microphone audio seems to be fine, because the audio is there (I can save it to file on disk using AVAssetWriter and play it back without an issue).
I only need the AVAudioPCMBuffer to visualize recorded audio in my app. Besides this use case, I write CMSampleBuffer to files on disk, and it works well. Perhaps there is another way?
Topic:
App & System Services
SubTopic:
Core OS
Tags: