我正在尝试使用RPScreenRecorder.shared()。startCapture将屏幕录制保存到firebase。我知道如何从AVCapture保存视频,但无法弄清楚如何处理CMSampleBuffer来创建一个文件以保存到firebase。请帮助我无法在任何地方找到相关文档,这是方法调用:
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
}
即使指向正确的方向也会有所帮助,我迷失了如何将样本BUFFER保存为可以作为视频播放的文件
答案 0 :(得分:0)
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)
}
有关代码的详细信息,请参见here