1

I am attempting to use RPScreenRecorder.shared().startCapture to save a screen recording to firebase. I know how to save videos from AVCapture but cant figure out how to process The CMSampleBuffer to create a file to save to firebase. Please help I cant find documentation on this anywhere yet, here is the method call:

 let recorder = RPScreenRecorder.shared()
 if #available(iOS 11.0, *) {
            recorder.startCapture(handler: { (videoBuffer, bufferType, error) in
                print(videoBuffer)
                print(bufferType)

            }, completionHandler: { (error) in

            })
        } else {
            // Fallback on earlier versions
        }

Even being pointed in the right direction would be helpful, I am lost at how to save THE sample BUFFER as a file that can be played as a video

lawndogg
  • 127
  • 1
  • 14
  • You may try the links of blog https://medium.com/@giridharvc7/replaykit-screen-recording-8ee9a61dd762 and it's sample on https://github.com/giridharvc7/ScreenRecord I have not tried it. Please let all know if you get success. – SHS Nov 28 '17 at 11:54

1 Answers1

2
RPScreenRecorder.shared().startCapture(handler: { (sample, bufferType, error) in
            if CMSampleBufferDataIsReady(sample)
            {
                self.showOverlayWindow()

                if self.assetWriter.status == AVAssetWriterStatus.unknown 
                {
                    self.assetWriter.startWriting()
                    self.assetWriter.startSession(atSourceTime: CMSampleBufferGetPresentationTimeStamp(sample))
                }

                if self.assetWriter.status == AVAssetWriterStatus.failed {
                    print("Error occured, status = \(self.assetWriter.status.rawValue), \(self.assetWriter.error!.localizedDescription) \(String(describing: self.assetWriter.error))")
                    return
                }

                if (bufferType == .video)
                {
                    if self.videoInput.isReadyForMoreMediaData
                    {
                        self.videoInput.append(sample)
                    }
                }
            }

        }) { (error) in
            debugPrint(error)
        }

Details of code can be found here

Talha Ahmad Khan
  • 3,416
  • 5
  • 23
  • 38