Saving a screen recording with RPScreenRecorder start capture

戏子无情 提交于 2020-05-28 05:30:07

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/46945152/saving-a-screen-recording-with-rpscreenrecorder-start-capture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!