I'm getting this error when I try to run the ScreenCaptureKit sample project on macOS Sonoma:
[ERROR] _SCStream_RemoteAudioQueueOperationHandlerWithError:1,053 streamOutput NOT found. Dropping frame
[ERROR] _SCStream_RemoteVideoQueueOperationHandlerWithError:1,020 stream output NOT found. Dropping frame
Both streamOutput are being set like this:
try stream?.addStreamOutput(streamOutput, type: .screen, sampleHandlerQueue: videoSampleBufferQueue)
try stream?.addStreamOutput(streamOutput, type: .audio, sampleHandlerQueue: audioSampleBufferQueue)
Link to sample project https://developer.apple.com/documentation/screencapturekit/capturing_screen_content_in_macos
Any idea of what is causing this?
I downloaded the sample project as well and I was getting the same error.
Funnily enough, an idea came to my mind while showering. Maybe now in Sonoma SCStream
keeps a weak reference to the outputs, and because the sample project declares the CaptureEngineStreamOutput
instance locally, it gets discarded right away. That was my guess.
I came back to the Xcode and confirmed when I saw this line:
func startCapture(configuration: SCStreamConfiguration, filter: SCContentFilter) -> AsyncThrowingStream<CapturedFrame, Error> {
AsyncThrowingStream<CapturedFrame, Error> { continuation in
// The stream output object.
let output = CaptureEngineStreamOutput(continuation: continuation)
So I declared right above the method a property to keep the reference alive:
private var streamOutput: CaptureEngineStreamOutput?
And then, assign the local property to the instance one:
streamOutput = output
That immediately fixed the error!