4

Is there any method to convert byte[] NV21Data to WebRtc VideoFrame ?

I try to do it with TextureBufferImpl and seems its the only way, but it looks really complex.

YuvConverter yuvConverter = new YuvConverter(); 
TextureBufferImpl buffer = new TextureBufferImpl(composedBitmap.getWidth(), 
composedBitmap.getHeight(),VideoFrame.TextureBuffer.Type.RGB, 
textures[0], new Matrix(), surfaceTextureHelper.getHandler(), yuvConverter, null);


VideoFrame.I420Buffer i420Buf = yuvConverter.convert(buffer);
VideoFrame CONVERTED_FRAME = new VideoFrame(i420Buf, 0, System.nanoTime());

This question has info how to convert VideoFrame to byte[] Android org.webrtc.VideoRenderer.I420Frame arrays to PreviewCallback.onPreviewFrame byte[]

This way gives VideoFrame as black, seems not working as intended.

This question is converting to webRtc VideoFrame from surface Converting a Bitmap to a WebRTC VideoFrame

https://gist.github.com/n1xx1/2cd38043838e259969bce983ce21ffaa

Kyryl Zotov
  • 1,788
  • 5
  • 24
  • 44
  • I faced frame black issue.. can you give solution for this ? I offered bounty for this question also (https://stackoverflow.com/questions/51494654/converting-a-bitmap-to-a-webrtc-videoframe) – Ranjithkumar Sep 26 '20 at 22:05
  • any update on this? – mger Nov 02 '21 at 17:18

0 Answers0