Dealing with video (DVDs, .avi .mkv) in Java

Solution 1:

After doing a lot of research around different options and trying a few out, I've gone with VLCJ after all, but here's the catch - all the VLCJ stuff is done in out of process VM's. It's a bit more complicated to set up (see here for how I did it) but afterwards you can throw all you like at it and it works just fine (currently using 3 out of process players with no stability issues.)

Xuggler was great, but unfortunately too low level for me - the sheer amount of re-inventing the wheel (and a worse wheel at that) required just to get playback with seeking working put me off somewhat; I felt it'd take forever to sort all the problems out with it. For encoding / transcoding / other low level video work though I'd wholeheartedly recommend it - best without a doubt.

Caveats with my chosen approach? Well, if the external VMs aren't shut down explicitly they'll carry on playing the video in the background even after the application has quit, and debugging gets harder with this approach. I also haven't verified it runs on Mac yet, and my initial suggestion is probably not because from what I've heard MacOS doesn't let one process control another's window without explicit permission with native code. That should be possible with a bit of work though.

As a spin off to the project I'm working on at the moment I might see if I can wrap up all this out of process functionality in a simple Java video framework that uses VLCJ underneath. If anyone would be interested in this (I can't promise anything but the more interest I get, the more likely I am to work on it) then feel free to let me know!

So after my research and findings, I'd recommend going with VLCJ (but definitely using out of process players) if you just want to play / record / stream video stuff, and Xuggler if you want to do any low level video work with the codecs themselves. At the time of writing, there just is no nice, pure Java solution, and it'll probably stay that way for a while - fortunately though it is possible to get decent results with native libraries cross platform. It just requires a lot more work!

Solution 2:

I used jffmeg on some of my projects(ffmeg java bindings), so far I havent faced any problem. http://jffmpeg.sourceforge.net/documentation.html. I also used qt-jambi, but never tried its video library(phonon), this can also solve your problem.

Solution 3:

Have you tried of using the JavaFX APIs?.

The way I see it JavaFX includes support for H.264 playback... and here someone shows how to play back video in Google´s new open source WebM / VP8

http://javafxplace.blogspot.com/2010/06/javafx-and-webm-on-linux.html

Solution 4:

Try Xuggler , it wraps the famous FFmpeg libraries in Java.

Solution 5:

I can recommend the gstreamer-java bindings. As the name suggests, it wraps the GStreamer API in Java classes. This way you have access to the media-processing graphing capabilities which GStreamer provides. This can be really neat if you want to do more advanced tasks like transcoding.

Also, if I remember correctly, there was a commercial plugin for GStreamer which supported DVD playback and came with a license for the CSS. If this does not matter for your use case you can always go with the open-sourced one, too (the only one I ever needed).