2

I'm trying Java Media Framework and I'm noticing that it doesn't support many video formats and it seems not to be updated enough. Is there an alternative for JMF for Windows Java Desktop Applications?

Michael Berry
  • 70,193
  • 21
  • 157
  • 216
Jonás
  • 1,459
  • 4
  • 27
  • 43
  • possible duplicate of [Playing video in Java](http://stackoverflow.com/questions/5277921/playing-video-in-java) – artbristol May 15 '12 at 14:42
  • @artbristol Disagree, this is asking about frameworks and that last question is asking more about JMF. Either way, that other question is quite old now and doesn't contain many links to good frameworks other than Xuggler. – Michael Berry May 16 '12 at 10:34
  • @berry120 There aren't any good frameworks, that's why. This question has been asked many times before. – artbristol May 16 '12 at 10:36
  • @artbristol That of course depends on your definition of a good framework, but I'd argue now (as oppose to a year or 2 ago) they are starting to emerge. My application successfully uses VLCJ to provide cross platform video support with custom text overlays, and a similar thing can be achieved with JavaFX. Or for extracting packets from streams on a lower level, Xuggler is very good. It all depends what you're after! – Michael Berry May 16 '12 at 12:24
  • @berry120 Fair point. It's good to hear that your experience of VLCJ is positive - maybe the competition will spur on JavaFX and get some decent support into the official platform. – artbristol May 16 '12 at 12:32
  • @artbristol Thanks - I seriously hope so! :-) – Michael Berry May 16 '12 at 12:55

2 Answers2

4

Yes, I'd definitely recommend staying away from JMF. I've felt your frustrations! Personally I recommend VLCJ, especially if you need support for a wide range of formats - I'm using it in my application and it works very well.

The following questions may also be relevant:

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

Adding other video codecs / DVD support to JavaFX 2.2

Community
  • 1
  • 1
Michael Berry
  • 70,193
  • 21
  • 157
  • 216
  • Thanks. I've finally used vlcj because JavaFX requires a JavaFX Project and I had a Java project started before. In fact I've got a problem. I need to play the video component inside a JPanel. How I'd do this? – Jonás May 15 '12 at 15:29
  • 1
    @honnix The best way is to use a Canvas, not a JPanel - that way VLC can just play it directly. The other way is to use a DirectMediaPlayer, which gives you a BufferedImage that you can display on anything you choose. This latter approach is more flexible, but can eat up tremendous amounts of CPU for HD video even on high powered systems. – Michael Berry May 15 '12 at 15:32
  • Hi, I'm using a Canvas but I'm getting the exception "java.lang.IllegalStateException: The video surface component must be displayable". I've asked in http://stackoverflow.com/questions/10609338/trying-to-embed-vlcj-media-player-in-a-windowscanvas-inside-a-jpanel because I've got really stuck. All the examples I've seen run the same code. I can't notice where I am wrong. Thanks in advance. – Jonás May 16 '12 at 13:13
  • @honnix See my answer, but when you get that error it's pretty much always because the canvas isn't being displayed on screen before you attempt to play the video. – Michael Berry May 16 '12 at 15:54
0

In short, it looks like a dead-end. I'd switch to JavaFX 2.1 - it's got much better support and seems to be "live" as well. There's some more information right here on Stack Overflow as well : Adding other video codecs / DVD support to JavaFX 2.2

Community
  • 1
  • 1
Ewald
  • 5,691
  • 2
  • 27
  • 31