Sign in to follow this  
ellisvlad

Playing Video With Alpha

Recommended Posts

Hi, I'm a developer for a Minecraft Group called Noxcrew. Basically, what I'm trying to do, is get videos with an alpha channel drawn in Minecraft (LWJGL).

 

Right now, I'm using VLCj to load and render the video to a OpenGL texture, and then drawing this to the screen. When I started, I would get segfault every time I loaded a video. This was because the memory buffer was being freed by Java's GC before VLC was finished with it.

After storing the memory of the VLCj MediaPlayer in a static variable, I get a crash after 10 mins to 30 mins of running. I would assume also it's because of the Java GC. I'm guessing it is because the directmemorybuffer is being moved by Java from eden to a more permanent space, but this corrupts any pointers that VLCj stores.

 

I've been struggling to get VLCj to work for a few weeks now, and have a working-ish solution that just means I have to re-initialise VLCj every 15 mins of running.

 

The other half of the problem, is the video we are trying to render has an alpha channel. At first, we used just a chroma key to filter out a color as each frame rendered.. But there were problems with the way most video formats compress the video data. Then we tried using the Quicktime 32-bit MOV format, which supports an alpha channel in the video.. But results in a bitrate of ~300Mbps... Manageable as a last resort, but not ideal..

 

So my two questions are:

1) Is there a reliable way to load and render videos with an alpha channel in Java/OpenGL. Without using a 32-bit mov file with a fixed huge bitrate.

2) Is there a more stable alternative to VLCj to render this video ingame?

 

Thanks for the help guys!

Share this post


Link to post
Share on other sites

I'm not very fluent with java, but I would be suprised if there wasn't a less "probabilistic" approach to playing videos ;-)

 

Anyhow, about the alpha channel: Have you considered using a second greyscale video stream for the alpha channel? You might have to "blur" the transparency borders of the color stream, similarly to how it's done with eg. foliage textures. Bitrate would be slightly inferior to a specialized codec that exploits the coherence between alpha and color channels, but you can use pretty much any codec pair with whatever bitrate you choose. You can even user a different bitrate (or resolution) for the alpha channel.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this