VLCJ in OpenGL / LWJGL

I’ll try it out when I get time. I’m so busy gaming right now. >_>

So because VLCJ is GPL, I’d have to release my entire game under GPL too?
This GStreamer binding (no idea what GStreamer is), can you also get access to frame memory like in VLCJ? Avoiding copying millions of pixels 24 times per second is pretty important…

Yes! IANAL blah de blah ;D

hmmmm… :stuck_out_tongue:

The binding is JNA based like VLCJ, and has been around a bit longer. And yes, you can get direct memory access to the pixels in the same way.

Because they are all for Swing/AWT and I am not an OpenGL programmer.

GStreamer is the only I haven’t looked into as thoroughly yet. As it seems to be similar to VLC.
And yeah I know there is a processing thing - running on 3 OS’… getting the code from that just seems like a nightmare, crawling through processing source code…

Yes, Mark Lee told me too. Not THAT much of a problem.

As far as I’m aware, both GStreamer-Java and VLCJ started off rendering into whatever the native video component provided by the library is. After that, direct pixel access was provided through JNA pointers which has allowed rendering into Swing / AWT / BufferedImage or whatever. You can do what you want with that pixel data, though.

btw - this is all interesting timing as I’m working on the OpenGL renderer for Praxis, and that already uses GStreamer-Java for video playback, so I’m currently looking into the best ways of getting the data directly into OpenGL.

You don’t need to look through all the Processing code!!! GSVideo just has a few classes that deal with loading the native GStreamer libs on various platform that might be useful.

Libs written for Processing import and use Processing classes like PImage, so its not portable to non-processing without effort.

Looking into some gStreamer & LWJGL stuff right now.

Yes, sorry, should have been clearer. There’s stuff that may be useful, but you’ll have to hack it out! See how you get on with GStreamer-Java by itself first - the GSVideo stuff is only really useful if you want to ship the native libs yourself, and that’s doable without it.

I’ve used this binding quite a lot, so I can try and answer any questions you have about it. Maybe post them in a “GStreamer-Java in OpenGL / LWJGL” thread! :slight_smile:

The maker of vlcj wrote me an email today

he wrote this, using jme3: http://code.google.com/p/vlcj/wiki/JMonkeyEngineExample

RenderCallback: That looks ridiculously easy! No need for a 16-bit RGBA texture though… xD

So, I’m painfully close in getting it to work.

See the link in my above post for reference (RenderCallback in VLCJ with display(Memory))

Source: http://www.java-gaming.org/index.php?action=pastebin&hex=33ad12326

almost there. Maybe I’m doing something incredibly stupid here with the buffers. But I’m not an OpenGL programmer =D

Getting:

[quote]Exception in thread “main” java.lang.IllegalArgumentException: Number of remaining buffer elements is 2785280, must be at least 6291456. Because at most 6291456 elements can be returned, a buffer with at least 6291456 elements is required, regardless of actual returned element count
[/quote]
To bottom line this: Once it works, video playback works.
You can ship VLC, just like a private JRE, including all natives for windows, linux and mac, just like with the lwjgl dlls.

Then there is only license problems, with java library and codecs.
To solve them: only include theora & vorbis codec
Make your code GPL, or at least that part that uses/communicates with VLCJ, still have to know which one

The problem is that you shove a 1280x554 raster into a texture with the dimensions 2048x1024. It won’t fit.

You either have to pad a lot of pixels, or use non-POT textures. I think the latter will be the best option.

[quote]To bottom line this: Once it works, video playback works.
[/quote]
I don’t think you’re as near as you think you are. The ‘buf’ variable is never really filled with data, so you’d be rendering a black screen, although even that wouldn’t work, as you never actually create a texture, you simply call GL11.glBindTexture(GL11.GL_TEXTURE_2D, 1); where ‘1’ should be the handle that glGenTextures provided. This will result in a crash.

I removed the get2Fold parts.
no error.
however no picture, the texture is white - this happens when you bind something thats not there usually

GL11.glBindTexture(GL11.GL_TEXTURE_2D, 1);

0, 1, 2, nothing works

so not sure what the problem is

I updated my previous post. You’re not really connecting any parts in the code you provided: you create a buffer and never fill it, pushing it into the texture every frame and expecting a video will play when you draw it. You have misconceptions about OpenGL and I advice you to work on that first. Try to load your own (non-POT) texture, then you’ll see that glGenTextures() is not optional, and how there are many more calls to OpenGL required to set this up properly.

[quote]buffer not being filled
[/quote]
right here

buf = memory.getByteBuffer(0, 1280 * 544 * 4);

display(Memory) is getting called and memory filled by VLCJ itself

like here http://code.google.com/p/vlcj/wiki/JMonkeyEngineExample

Hm, okay, how are the buffer blits synced? You never request a new frame, and without any request, it must be running on another thread, which will cause lots of tearing as the buffer can be modified during upload.

yeah glGenTextures, ok, doing this, now. No change though.


IntBuffer tmp = createIntBuffer(1); 
GL11.glGenTextures(tmp); 
glTextureID = tmp.get(0);

public IntBuffer createIntBuffer(int size)
{
      ByteBuffer temp = ByteBuffer.allocateDirect(4 * size);
      temp.order(ByteOrder.nativeOrder());

      return temp.asIntBuffer();
} 

GL11.glBindTexture(GL11.GL_TEXTURE_2D, glTextureID);

Yeah no idea. Looking at the JME example it says “Synchronisation might be required…”
I assumed frames were requested by time automatically, because there aren’t any calls in the JME example for this.
But yeah tearing and sync… well first I need it to display anything.

I uploaded an eclipse project, so people who wanna help can actually try.
http://www.mediafire.com/?m3eloau579blx13

This project contains everything you need, but only works on windows (only has the vlc dlls).
You dont need VLC installed or anything like that. A Video to test with is also contained.

TO run the LWJGL class just use the vm parameter “-Djava.library.path=lib” (if my configurations dont show up)

You can also use


public static void main(String[] args) {
    System.setProperty("org.lwjgl.librarypath",System.getProperty("user.dir") + "/relative/path/to/root/of/natives/");
    
    ....
}

This is a not well known LWJGL hidden switch that lets you bypass the -Djava.library.path option.

Ugh… can’t seem to get this on my MacOSX. Keeps giving me “[0x100150020] main libvlc error: No plugins found! Check your VLC installation.” even though I am using the proper VLC_PLUGIN_PATH variable for my VLC version… ???

Just read. I told you, only windows.
Adding the Linux .so files would be best I could do
No access to a mac anyway

Nah, I’ve been trying to get it working using the JARs from the VLCJ/JNA website – not your eclipse package. After some tweaking I got it to link with my VLC libraries (vlclib/vlccore) but I’ve hit a roadblock with the plugins problem.