replayKit RPSampleBufferType does not have video

228 views Asked by At

I am using ReplayKit to record the screen. However, I have a very strange issue with having video buffers. When user taps record button, the following method is called;

       rpScreenRecorder.startCapture { (sampleBuffer, bufferType, error) in
        if let error = error {
            print(error.localizedDescription)
        }
        
        switch bufferType {
        case .video:
            print("video")
        case .audioApp:
            print("audioApp")
        case .audioMic:
            print("audioMic")
        @unknown default:
            print("default")
        }
    } completionHandler: { (error) in
        if let error = error {
            print(error.localizedDescription)
        }
    }

The problem is, bufferType does not have video. When I print all cases, audioMic and audioApp is returned forever but video is never returned.

I can easily repeat this problem only on the first launch when I remove the app and install it again. It works as expected in other cases.

p.s: I had a look at other issues before asking this question. None of them solved the problem.

1

There are 1 answers

0
musakokcen On BEST ANSWER

After spending days and nights to solve this issue, I finally came up with a solution.

Simply, the reason was about the main window

Main window is important for replay kit because it is recording the main window.

I was using different windows to hide some views from the recorded video. I also changed windowLevel of the main window. Today, I noticed that removing every adjustment related to main window solved the problem. (other windows have no effect.)