Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, March 5, 2016

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

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


After looking around for a decent library for playing videos in Java, I've come unstuck. Everyone around is screaming not to use JMF because it's outdated, old and requires the user to install it, other alternatives such as VLCJ seem good if they work but are still relatively unstable and rely on hefty amounts of native code, and as for dealing with DVDs, that seems like gold dust to find in a free library!

Current Options:

  • Now JavaFX 2 is gaining momentum it's been something I've been seriously looking at (hence my question here) but I've no luck so far in trying to work out how to make it play anything more than bog standard FLV video.
  • VLCJ is working well for what it does (see my current answer) and at the moment is what I'm going ahead with. It uses libvlc to do pretty much anything, as in it can play pretty much any file and plays DVDs out of the box too. Big problem is that you have to use multiple VMs for each player to get it to perform stably, and that means response is relatively slow. I also haven't got this approach to work on a Mac yet.
  • JMF is ridiculously outdated, horrible and just not really an option as far as I'm concerned. I've played with it in the past, and the experience was not a good one!
  • FMJ says it's a replacement drop in for JMF. I've yet to make it work, as have most other people I've spoken to, and that in itself makes me weary of its quality and comprehension even if I do manage to get it working!
  • Xuggler is great for what it does, it's got brilliant tutorials and it's very well written. But while it's great for the low level transcoding work, playing a video and getting the frames in the right order and in sync and so on is just a nightmare to get working properly, and again adds more code which means more maintenance, potentially more bugs etc. etc...
  • I haven't tried GStreamer-Java yet with any anger, though it doesn't seem to support DVD playback (it's an open source app I'm working on so commercial plugins aren't an option either) and it's codec support doesn't seem to be the widest.
  • JCodec is an interesting effort, the only one I've seen to implement video support from a pure Java perspective - but support for formats is lacking at the moment and it's a relatively new project.
  • Writing something myself in a different native library for each platform I want to support. This is the absolute last resort option due to the added maintenance and coding time it'd require.

Based on the above (or anything else you can think of), what options would people recommend and are there any other sensible ones I've missed out? Or any others people think might be available in the near future?

Answer by user489041 for Dealing with video (DVDs, .avi .mkv) in Java


I'd agree with staying away from JMF. Especially if you want to play DVD's. Even JMF relies on native code for some of its functionality. You prob not going to get away from having some sort of native dependencies anyway. One other option would be FMJ. Its an open source version of JMF. I havent had much luck with it though.

My suggestion would to go with VLCJ. I was exploring this when I needed a media solution. Unfortunately it is released under the GPL so I cant use it in my application, but it seems like it should be able to handle what you want.

Also, my other post might be of interest to you. Link

Also, this might be useful.

Answer by Fernando el Geek for Dealing with video (DVDs, .avi .mkv) in Java


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

Answer by ismail for Dealing with video (DVDs, .avi .mkv) in Java


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

Answer by olafpadme for Dealing with video (DVDs, .avi .mkv) in Java


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.

Answer by Waldheinz for Dealing with video (DVDs, .avi .mkv) in Java


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).

Answer by berry120 for 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!


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.