Media player libraries in Java [closed]

2019-04-04 03:17发布

I am evaluating libraries for playing audio/video in Java. It does not need to be 100% Java; Java bindings to native libraries are perfectly OK. An external application that can be controlled from Java is also fine, as long as it can render video on a Java component.

The target platform is Linux. Windows support is a plus, but not required.

I have played with VLC using the VLCj bindings, and it works pretty well in general, but keeps crashing occasionally when put under stress. I have also used mplayer in slave mode, which looks good. But I'd like to evaluate other options as well.

These are the requirements:

  • Live playback of H.264, MPEG4 through RTP using RTSP. Extra points for MJPEG over HTTP.
  • Able to render video on a Java (Swing or AWT) Component
  • Open source, and actively maintained
  • Stable, rock-solid

Suggestions? Advice?

3条回答
2楼-- · 2019-04-04 03:42

I've also spent a while researching my options, and I've actually come to the conclusion that VLCJ is the best option - however here's the clincher, you need to run it out of process (especially with multiple players) for it to give you 100% reliable operation. That's the approach I'm taking and I've yet to see it crash. With it rock solid in this way it also has other advantages:

  • It can play pretty much anything. Yes it's a bit of a cliche, but this includes DVDs, Youtube videos, pretty much any video file...
  • Should support Linux / Mac / Windows, though I've yet to verify Mac working.
  • Actively maintained, and if you ask a good (as in well thought out) question on the discussion group the owner often replies in minute in my experience!
  • Open source, and the Google group activity at the time of writing is high.
  • Uses all the graphics acceleration VLC does
  • Able to play to any heavyweight Canvas component (and if you use the direct player, you get the BufferedImage to display anywhere you like, even in JOGL 3D land if you're that crazy!

I haven't found it that heavy on the resources front either, though I haven't done any thorough testing (but 3 players work fine in tandem as well as my relatively power-hungry application on my 4 year old basic laptop!)

Disadvantages? There's no official framework for out of process players, so you have to build one yourself (see here for how I did it). And you do sometimes have to do some fiddling to get it working. But as far as I can see, it's working well for me so far!

查看更多
Root(大扎)
3楼-- · 2019-04-04 03:49

Ok, I've spent the last month playing with several options and these are the results:

  1. VLC. This was my first thought, as everybody keeps saying that it "plays everything". I have used both the VLCj Java bindings, and the built-in remote interface (-I rc). I found this to work pretty well in general, but had some issues. I kept seeing ocassional crashes under heavy load (not VLCj's fault as it also happens when using the binary directly). Also I've found memory consumption to be relatively high when compared to other options.

  2. MPlayer. This actually performs better than VLC in my experience, no crashes, and memory consumption is lower. No Java bindings, although the slave mode works very well.

  3. GStreamer. Very powerful, very flexible, while still easy to get started with. Tried both the Java bindings and running the gst-launch binary from Java. Both approaches work remarkably well.

  4. Xuggler looked good, however it seems to have issues with RTP (as stated in the FAQ). Since both GStreamer and MPlayer worked so well, I did not get past the initial research.

I found GStreamer to be the best solution given the requirements, with MPlayer being the second option.

查看更多
Lonely孤独者°
4楼-- · 2019-04-04 03:50

have you looked at gstreamer?

查看更多
登录 后发表回答