Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating RTCVideoframe with CVPixelBuffer

Need help in creating RTCVideoframe

This is the init method for RTCVideoframe RTCVideoFrame(buffer: RTCVideoFrameBuffer, rotation: RTCVideoRotation, timeStampNs: Int64)

I am able to get input buffer as CVPixelBuffer

How can I convert CVpixelBuffer to RTCVideoFrameBuffer.

Thanks and any help is much appreciated

like image 332
MacDeveloper Avatar asked Feb 24 '26 07:02

MacDeveloper


1 Answers

Using cmSampleBuffer we received from

`

sharedRecorder.startCapture(handler: { (cmSampleBuffer, rpSampleType, error) in
   switch rpSampleType {
  case RPSampleBufferType.video:

{
 let pixelBuffer = CMSampleBufferGetImageBuffer(cmSampleBuffer)!
 let rtcpixelBuffer = RTCCVPixelBuffer(pixelBuffer: pixelBuffer)
 videoFrame = RTCVideoFrame(buffer: rtcpixelBuffer, rotation: RTCVideoRotation._0, timeStampNs: Int64(timestamp))
}
} )}

`

like image 165
MacDeveloper Avatar answered Feb 27 '26 03:02

MacDeveloper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!