Paulo Ragonha

Java movie playback: JOGL + Fobs4JMF

Posted by Paulo Ragonha on

Recently I had to integrate video playback on my job's Java OpenGL engine, which uses JOGL.

Java has a support to media playback through it's Java Media Framework, which unfortunately, on it's current version (2.1.1e) does not support many formats for video playback.

So I quickly looked for alternatives, including IBM Toolkit for mpeg4, that hadn't a sufficient production performance I was looking for, and didn't offer an easy option for frame grabbing or plugin extensions as JMF does. Next was Fobs4JMF, which is JMF + ffmpeg. This solution was much more interesting, since it offers a wide variety of codecs (ogg, mp3, m4a, divx, xvid, h264, mov, etc) and is based on the solid ffmpeg solution to decode audio and video.

My implementation, uses the plug-in capabilities of JMF to extend a custom renderer that does a pixel type conversion and rendering to a texture.

This custom renderer works with RGB textures, a type I seemed to made work on my two test machines:

You might wanna try different pixel types to increase the performance on different target machines.

First, lets describe how the Renderer works. It got to be an implementation of a since it will be installed as a plugin on JMF.

For the different methods we need to implement, there are a few we need to take proper care of:

Next we need a way to access this renderer outside of the JMF context, so that we can get the texture and render it on the teapot. To achieve it, our class must also be a implementation, then we can easily get it through a getControl call, such as:


So we implement:

The renderer implementation is org.pirelenito.multimedia.jmf.plugin.RGBGLTextureRenderer.

And also, to make further development easy, there is an IGLTextureRenderer interface with the public methods called by the Canvas:

Last but not least, you will need to register the renderer on JMF, this is done through the JMFRegistry application. The easiest way to start it, since our custom renderer is already on the class path, is inside Eclipse:

To test it out there is also a helper class to instantiate the movie player, and a main class that is an OpenGL canvas used to render the teapot with the texture on its surface.

I am not very experienced with OpenGL, so there might be more effitient ways to do this, using for instanceĀ PBO (Pixel Buffer Object).

You can check the code at

Cheers! ;)

ps: I moved this article from an old Wordpress blog, and for now there are no comments available.

comments powered by Disqus