I'd like to create a video with transparency (and semi transparency) in android. The images of the source video are split into two images, the top one with color information (looks like the normal video image), the bottom one with alpha information (the same shapes but only in black and white and gray, black means transparent).
This is the solution for iOS: https://medium.com/@quentinfasquel/ios-transparent-video-with-coreimage-52cfb2544d54
What would be the best way to to this in android?
Can this be solved with javacv, FFmpegFrameGrabber, FFmpegFrameFilter etc.?
Or better with OpenGL ES and shaders?
Are there any samples?
Thanks!
We use exactly the same approach to add transparency to videos in our android app. We use OpenGL ES with shaders and it works flawlessly. What you need to do is just render those video to surface texture (can be easily done using ExoPlayer) and afterwards it can be accessed from OpenGL as regular texture. For the shader you can start from something like this
and dont forget to render this into a TextureView and enable transparency with
TextureView.setOpaque(false);