RootEncoder icon indicating copy to clipboard operation
RootEncoder copied to clipboard

BitmapSource with transparent background

Open cryinrain69 opened this issue 8 months ago • 5 comments

Hi. I am using:

  • vMix Server.
  • SRT Protocol
  • Library Version: 2.5.9
  • Using GenericStream and BitmapSource.

I want to stream a bitmap to the server (PNG image, with transparent background, is SRT 2028 source as in the image below). But the server receives a black background (Image 2). How can I stream the bitmap to get the same background result as in Image 1 (image added from vMix server) ?

Image 1:

Image


Image 2:

Image

cryinrain69 avatar Apr 16 '25 04:04 cryinrain69

Hello,

The background is black because opengl clean the screen in each frame using a color. I'm not sure if your case is possible. You can try clear using transparent color here: https://github.com/pedroSG94/RootEncoder/blob/master/encoder/src/main/java/com/pedro/encoder/input/gl/render/CameraRender.java#L105 And here: https://github.com/pedroSG94/RootEncoder/blob/master/encoder/src/main/java/com/pedro/encoder/input/gl/render/ScreenRender.java#L138 Set the last value to 0f which means totally transparent. If it is not working, I think it is not possible

pedroSG94 avatar Apr 17 '25 10:04 pedroSG94

Hi. Can you create a commit so I can implement it? My Android Studio often fails when downloading a lib to use it as a module :-(

cryinrain69 avatar Apr 17 '25 10:04 cryinrain69

Try with this gradle:

  implementation 'com.github.pedroSG94.RootEncoder:library:7be5f8b871'
  //Optional, allow use CameraXSource and CameraUvcSource 
  implementation 'com.github.pedroSG94.RootEncoder:extra-sources:7be5f8b871'

pedroSG94 avatar Apr 17 '25 11:04 pedroSG94

Hi.

I tried that commit but still got the same black background.

In addition, I am customizing OpenGlView (MyOpenGlView) to add some features (like zoom on pinch, ...). In version 2.5.9, I still extend the OpenGlView class normally. But with that commit (and in the master branch), you have changed OpenGlView to final type so I can't extend it anymore. Can you change it back to open class OpenGlView : SurfaceView, GlInterface... ?

Image

cryinrain69 avatar Apr 18 '25 09:04 cryinrain69

Hello,

OpenGlView is open again.

About the background. I was reading a bit more about the transparency/alpha in a stream and it is not possible. Transparency with H264, H265 and AV1 is not allowed at all (you can find fews possible implementations but it is not a standard).

pedroSG94 avatar Apr 18 '25 21:04 pedroSG94