Caprica Software

vlcj 4.x Tutorial

JavaFX

With contemporary versions of JavaFX, at least version 13 onwards, JavaFX is a very capable platform for vlcj applications - and especially so, but not solely, for macOS.

JavaFX requires the use of the "direct rendering" media players provided by vlcj. Such media players render video frames from VLC rather than have VLC do the rendering as the "embedded" media players do.

With Java 1.7+, macOS no longer has heavyweight AWT and so embedded media players no longer work on macOS.

This rendering has historically been slightly less efficient than with the embedded media players, with increased CPU usage due to the rendering overhead.

Nevertheless the increased CPU usage is far from prohibitive and very good results can be achieved.

With JavaFX 13, a new PixelBuffer component was introduced, providing direct access to a native buffer. The direct rendering media players provided by vlcj can use this native buffer with LibVLC and have VLC render directly into that buffer. JavaFX then repaints the video frame at the next pulse.

The performance of a vlcj application with PixelBuffer is generally very good and makes this approach viable on all platforms.

The strength of vlcj's architecture and design is that it is trivial to use a direct rendering media player in place of an embedded media player. The only difference in usage is the video surface component associated with the media player, all other API is exactly the same.

A fully working JavaFX example for vlcj using PixelBuffer is available at Github.

A very small support library to help with using vlcj with JavaFX is also provided.