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

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!

Leave a Comment