Using VLCJ to draw video onto a texture

Whilst looking for a way to draw a video onto a texture using jMonkey, I couldn’t find a working example, so after a bit of work I managed to come up with something relatively simple that works and shows a video painted onto a texture.

There are problems - as listed below - but it will at least give you a head start to work with something.


  • VLCJ is GPL - probably going to restrict you if you don’t want to publish your code as GPL.
  • VLC Player must be installed on the client machine - or alternatively you can ship the required files with your built project.
  • The 64bit version of VLC player is a bit “dodgy” - It is recommended that you use the 32bit version, and thus compile against the 32bit version of java because wont work cross-platform.

VLC Player: Official download of VLC media player, the best Open Source player - VideoLAN

Probably a good idea to read through the tutorials as well while you’re in a reading mood :sunny:


// the path to your video file - network paths work too.
String filePath = "\\\\NSA310\\video\\Movies\\Shrek 2 (2004).avi";

// the width and height of the movie...
final int width = 704, height = 384;

VLCMediaPlayer vlc = new VLCMediaPlayer(filePath, width, height);
// a quad sized in the correct proportion to the video...
Quad quad = new Quad(7.04f, 3.84f);

Geometry geom = new Geometry("quad", quad);

Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", vlc.getTexture());


Feel free to use, abuse, etc…


You know that jme3-jfx is capable of using the jfx media system to play videos onto a texture?



Support for playing media, especially video media, is generally poor on the Java platform. The Java Media Framework can be used to play some media, but it seems to be a neglected framework and has not been updated to play media encoded with modern codecs. JavaFX also provides the ability to play some media, but not all. In addition to playing media it is often desirable to be able to publish and consume streams of media across the network or the Internet and this too is not well supported by existing Java frameworks.

For these reasons, the usual solution is to use a native media framework and bind to it using native libraries by using the Java Native Interface (JNI), or the Java Native API (JNA) to simplify JNI.

There are a number of different native media players that could be used in this way, two such widely used media players are VLC and mplayer. The vlcj project was created to integrate VLC into Java applications.

Doesn’t hurt to have alternatives :slight_smile:

True, alternatives are always a good thing.

Small, but to me important, correction:

  • VLCJ is GPL - probably going to restrict you if you don’t want to publish your code as GPL.

…it’s not just publishing that is required… you have to GPL license your whole project, also.

Thanks @pspeed - ammended the original post with the corrected note.

I followed your sample code but I keep on getting an error on line 77

public void play()
{ mediaPlayerComponent.getMediaPlayer().playMedia(this.videoPath);

I get an error on playMedia(). The error says " Cannot find Symbol"

Do you have vlc player installed? What is your operating system? Please post the entire stacktrace.

I haven’t used this in over 4 years. I’ll give it a whirl if I can’t resolve it for you.

Thank you so much for replying fast. We have installed a VLC player and the OS is Windows 10.



at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(

at sun.reflect.DelegatingMethodAccessorImpl.invoke(

at java.lang.reflect.Method.invoke(

at de.lessvoid.nifty.NiftyMethodInvoker.callMethod(

at de.lessvoid.nifty.NiftyMethodInvoker.performInvoke(

at de.lessvoid.nifty.Nifty$DelayedMethodInvoke.perform(

at de.lessvoid.nifty.Nifty.invokeMethods(

at de.lessvoid.nifty.Nifty.handleDynamicElements(

at de.lessvoid.nifty.Nifty.access$1600(

at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processEvent(

at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processMouseEvent(

at com.jme3.niftygui.InputSystemJme.handleMouseEvent(

at com.jme3.niftygui.InputSystemJme.onMouseButtonEventQueued(

at com.jme3.niftygui.InputSystemJme.forwardEvents(

at de.lessvoid.nifty.Nifty.update(

at com.jme3.niftygui.InputSystemJme.endInput(

at com.jme3.input.InputManager.processQueue(

at com.jme3.input.InputManager.update(



at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(



Caused by: java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: mygame.VLCMediaPlayer

at mygame.MyStartScreen.controlGame(

… 25 more

Hi @jayfella, we tried the solutions provided in the stackoverflow link, but it still doesn’t work.

In our source code…

In this picture, when we hover the “getMediaPlayer().” and there’s a list of possible methods to use like play() which opens up a description popup, and there’s no error when we use that.

However, in this picture, when we click on playMedia(String), there’s no java doc description popup which makes us think the function may no longer exist and that may be why we’re unable to run the program?


For uploading screen shots, please use an image hosting service. Right now is the best one, I think.

Wow. You used an actual camera to take a picture of your computer screen. That’s awesome.

Anyway. Lack of java doc just means the method wasn’t documented by the programmer. I’ll take a look in the morning for you.

Great! Thank you so much for your help in advance :slight_smile:

For what its worth, I also did this (but one year later, so I should have used the search function on the forum before attempting it). I haven’t used it either since then, but maybe it works out of the box:

1 Like

I checked it over. It worked for me. The steps I took were:

  • Make sure I’m using version 3.x (and not 4.x) of the VLCJ library.
 compile group: '', name: 'vlcj', version: '3.7.0'

If you try to mix 32bit/64bit VLC player/java it won’t work - for me it spits out a huge descriptive error log.

If memory serves - and this was 4 years ago - I think version 3 of VLCJ had issues with the 64bit player. I’m not sure if version 4 resolves this but it doesn’t seem backwards compatible - as expected - since the major version changed.

It may be that upgrading to VLCJ 4 makes all of this a non-isse.

I took it upon myself to make a VLCJ 4 variant. You might want to amend the data on line 50, 51 and 52.

This version is using version 4.1.0 of VLCJ.

compile group: '', name: 'vlcj', version: '4.1.0'


Thank you


HI,I have a Ultra Video(2560*1440)
I try to load video to the code.
I only modify width(2560) and height(1440).
But the video cannot play in this code.

Do you have VLC player 64bit installed? Did you set the path to the video? Does the video play in VLC player? Have you tried a different video/format? What does it say in the logs?