Wednesday, December 24, 2008

GStreamer - multimedia fun on a plugin architecture

I've poked around GStreamer and the bindings for Java. GStreamer is a framework for "constructing graphs of media-handling components". For example a video player from "scratch". GStreamer is mainly a linux project with few run-of-the-mill GUI components, hence rough around the edges. But two days of compiling, testing and asking questions on a lively IRC channel.

Java Bindings


GStreamer-Java is a API binding layer on top of GStreamer. This means Java can be used for composition of the application, and GStreamer is used as a native library which handles the dirty work. As long as the API's are ok and the native API can pull its weight, I'm happy with the division, as the tedious work of adding functionality can be outsourced, and I can focus on the stuff I know.
GStreamer-Java works is nice to work with out of the box. The tutorials, borrowed from the parent project, are very well as documentation. I haven't dug through the source, but I'm happy for the time beeing. The project isn't Maven-supported, but I've posted a .pom for the needy. The project is hosted on google, but I believe the most updated code lies in a mercurial repo.
The rough edges are concerned with setting up GStreamer, installing native libraries and multimedia components and getting the whole shebang working for each installation. You have been warned! But don't be discouraged; read the next paragraph.

Setting up on a Mac


GStreamer can be installed on a Mac with the help of MacPorts. Remember to install the gst-plugins-good, and possibly bad and ugly, to get the required libs and components for running the tests. Set the VM parameters in your IDE to -Djna.library.path=/opt/local/lib on mac, /usr/lib on linux. I've had some problems with native libraries on JDK 1.6 on Mac, resulting in the error message:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'gstreamer-0.10': dlopen(/opt/local/lib/libgstreamer-0.10.dylib, 1): no suitable image found. Did find:
/opt/local/lib/libgstreamer-0.10.dylib: mach-o, but wrong architecture

In which case, try switching to JDK 1.5.

Conclusion


Messing with GStreamer has been fun, and alot less hopeless than f*cking with Java on Blu-Ray. Their web page could need a overhauling when it comes to finding essential information quickly, and messing with native applications is not what Java developers like to do. But the simplicity and potential power of the architecture is really interesting for my upcoming project, and I'm looking forward to poking some more at it.

No comments:

Post a Comment

Spam will be pruned