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

ksullivan picture ksullivan · Jan 11, 2010 · Viewed 26.8k times · Source

I need simple video playback in Java.

Here are my requirements:

  • PRODUCTION QUALITY

  • Open and decode video files whose video and audio codecs can be chosen by me. I.E I can pick well behaving codecs.

  • Be able to play, pause, seekToFrame OR seekToTime and stop playback. Essentially I wish to be able to play segments of a single video file in a non linear fashion. For example I may want to play the segment 20.3sec to 25.6sec, pause for 10 seconds and then play the segment 340.3sec to 350.5sec, etc.

  • During playback, video and audio must be in sync.

  • The video must be displayed in a Swing JComponent.

  • Must be able to use in a commercial product without having to be open source (I.E. LGPL or Comercial is good)


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?


  • Write a Flash application which plays a video and use JFlashPlayer to bring it into my Java Swing application

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?


  • Write a simple media player on top of Xuggler

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.


  • Use FMJ

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


I would appreciate your opinions on my problem.

Answer

Art Clarke picture Art Clarke · Jan 26, 2010

Can a brother get a shout out for Xuggler?