ksullivan
ksullivan

Reputation: 496

Video playback in Java ( JMF, Fobs4JMF, Xuggler, FMJ )

I need simple video playback in Java.

Here are my requirements:


My research has led me to the following solutions:

I have implemented a quick prototype and this seems to do what I need. I can play a segment of video using:

player.setStopTime(new Time(end));
player.setMediaTime(new Time(start));
player.start();

While Fobs4JMF seems to work, I feel the quality of the code is poor and the project is no longer active. Does anyone know of any products which use Fobs4JMF?


Unlike Java, Flash is brilliant at playing video. I could write a small Flash application with the methods:

open(String videoFile),
play(),
pause(),
seek(int duration),
stop()

Then bring it into Java using JFlashPlayer which can call Flash functions from Java.

What I like about this solution is that video playback in Flash should be rock solid. Has anyone used JFlashPlayer to play video in Java?


Xuggler is an FFMpeg wrapper for Java which seems to be a quite active and high quality project. However, implementing the simple video playback described in the requirements is not trivial (Seeking in particular) but some of the work has been done in the MediaTools MediaViewer which would be the base upon which to build from.


I have tried to get FMJ to work but have had no sucess so far.


I would appreciate your opinions on my problem.

Upvotes: 25

Views: 27583

Answers (7)

Chaoslab
Chaoslab

Reputation: 33

JMF / Fobs / Xuggler are all inactive.

JavaFX is an option, but if you need too mix 2-3 videos at once you are not going too have a good time and a chunk fest.

VLCJ seemed a little "chunky" as well unfortunately, not as bad but had it's own problems.

Recommend OpenCV, supports 64bit. Have had the best success with it, can play several videos at once and be fine.

Upvotes: 0

john16384
john16384

Reputation: 8064

I'd recommend using MPV. You can use it in combination with JavaFX quite easily, see this example.

In short, you use a little JNA magic to use the MPV native libaries directly, and then let the video display on a JavaFX stage. If you use a child stage, you can even overlay JavaFX controls on top of the video (with full transparancy support).

VLC (with VLCJ) can be used in a similar fashion, but I find that the MPV solution performs better (faster seek and start times).

Upvotes: 0

Michael Berry
Michael Berry

Reputation: 72379

In my mind, VLCJ is the way forward for this type of thing. I love Xuggler for encoding / transcoding work, but unfortunately it's just so complicated to do simple playback and solve all the sync issues and suchlike - and it does very much feel like reinventing the wheel doing so.

The only thing with VLCJ is that to get it to work reliably with multiple players I've had to resort to out of process players. The framework wasn't the simplest thing in the world to get in place, but when it's there it works beautifully. I'm currently running 3 out of process players in my app side by side with no problems whatsoever.

The other caveat is that the embedded media player won't work with a swing component, just a heavyweight canvas - but that hasn't proven a problem for me at all. If it does, then you can use the direct media player to get a bufferedimage and display that on whatever you choose, but it will eat into your CPU a bit more (though no more than other players that take this approach.)

Upvotes: 5

Oso
Oso

Reputation: 528

haven't tried Xuggler (which i'm interested in) but I'm having a good time with VLCJ. The drawback I find in it is only that you have to have VLC installed prior to your application.

Upvotes: 3

paul
paul

Reputation: 5418

I've been using jffmpeg in the same way you use FOBS, it works pretty well, although I haven't compared them.

I would also love to see an easy way to interface with native codecs the way that JavaFX does, but there doesn't seem to be real integration between JavaFX and Java.

There has also been some work trying to get the VLC library libvlc into java. I haven't tried it yet and would be interested to hear back from anyone who has.

Upvotes: 3

Art Clarke
Art Clarke

Reputation: 2505

Can a brother get a shout out for Xuggler?

Upvotes: 13

jsight
jsight

Reputation: 28429

JavaFX has a number of working video and audio codecs builtin. It's likely to be the solution with the broadest support at the moment.

Upvotes: 3

Related Questions