I am trying to play a movie file into an OpenGL texture in a Java application. I am using JOGL and have a basic OpenGL scene, but I have no idea how to play a movie into a texture.

The only thing I could find was this:


It is quite old and uses JOGL 1.1 and Fobs4JMF, which is no longer maintained. I managed to get it to build in eclipse but it wasn't able to read my movie clip. I could probably convert the movie clip to an older codec to see if that works, but I would rather have a modern solution.

I am a professional game developer, so the OpenGL part is no problem, but I am new to Java (coming from a C++ background).

Is there any modern library that wraps this functionality in an easy to use package?

  • 2
    \$\begingroup\$ You can use xuggler to decode vid files but it doesn't provide anything to integrate with JOGL so you'll have to code decoded vid->texture part yourself. xuggle.com/xuggler \$\endgroup\$ – XiaoChuan Yu Jun 21 '13 at 2:05
  • 1
    \$\begingroup\$ I have done the opposite, encode a H.264 video from OpenGL rendering with Java, and I can highly recommend xuggler. It took around 4 hours to glue everything together and have a working solution. By transferring the data with Pixel Buffer Objects and encoding in a separate thread the performance hit was unnoticeable. \$\endgroup\$ – msell Jun 21 '13 at 5:13
  • \$\begingroup\$ I am currently looking into xuggler. Seems pretty powerful. Thanks for the tip \$\endgroup\$ – DaleyPaley Jun 24 '13 at 0:23

You may use the JogAmp JOGL GLMediaPlayer class http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/av/GLMediaPlayer.html

GLMediaPlayer will use the operating system installed codecs to decode the movie, on Android it uses the Android media framework and on desktop systems such as Linux, Windows and Mac it dynamically links to and uses installed libav/libffmpeg libraries. GLMediaPlayer itself only expose a platform neutral API and renders to a texture.

Example code are found to playback a movie on all six sides of a cube and on a rotating rectangle inside the jogamp jogl test codebase:



  • \$\begingroup\$ Thanks, this seems to be the 'correct' way to do it. Good stuff! \$\endgroup\$ – DaleyPaley Jun 24 '13 at 0:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.