Skip to content

Plugging FMJ decoders and renderers into JMF

by werner on July 12th, 2009

Decoders from the FMJ project can be used as plug ins for JMF. But some work is required.

FMJ plug ins do not work out of the box, because JMF is very picky about the format descriptions that a plug in returns to advertise its input/output capabilities.

To get support for PNG-encoded AVI and QuickTime videos in JMF, one can use the FMJ PNGDecoder as a codec plugin. JMF can only build a data flow graph though if one patches the FMJ PNGDecoder and the FMJ ImageIODecoder as follows:

  • Method PNGDecoder.getSupportedInputFormats needs to return a new VideoFormat(“png “) object so that JMF can associate it with the corresponding “png ” FourCC in the video files. This VideoFormat object can be returned in addition to the PNGFormat object which is already returned.
  • Method ImageIODecoder.getSupportedOutputFormat needs to return a new RGBFormat(inputCast.getSize(), -1, Format.byteArray, inputCast.getFrameRate(), 24, 16711680, 65280, 255) object, so that JMF can build its flow graph for rendering the video. This RGBFormat object canย  be returned in addition to the RGBFormat object which is already returned.

To get support for JPEG-encoded AVI and QuickTime videos in JMF, one can use the FMJ JPEGRenderer as a renderer plugin. The following patch is needed in FMJ:

  • Method JPEGRenderer.getSupportedInputFormat needs to return new VideoFormat(VideoFormat.MJPG, null, Format.NOT_SPECIFIED, Format.byteArray, Format.NOT_SPECIFIED). This is needed, so that JMF can associate it with the “MJPG” FourCC in the video files. Again, this format object can be returned in addition to the one already being returned.

Thanks to these patches, my own little media player MultiShow is now able to play JPEG- and PNG-encoded videos in AVI and QuickTime files.

In case someone is interested in the code. The patched FMJ code is available in the download file of MultiShow.

From → Java

4 Comments
  1. Have you seen anything that suggests that a platform-independent Theora decoder that can be dropped into JMF is available anywhere?

    Do you know anything about Sun adding simple video support to Java in a future version so that JMF is no longer necessary?

    I can use QuickTime to make Theora videos in MOV wrappers quite nicely now. They look good and appear to play well. Also, they’re very much smaller than the Cinepak that I’ve had to use for years. Now, QuickTime won’t even export Cinepak in MOV format; I must use AVI. I am also having problems playing AVI Cinepak videos at times depending on the content.

    I can only expect JMF to be more and more of a problem. For the short term, I’d love to have JMF play Theora in MOVs. Maybe that will last until a decent media API appears in Java.

    FMJ won’t work for me. I really must have an invisible load for my customers, most of whom are students. I can use jmf.jar.

  2. Hi Harry,

    I don’t know whether there is a pure Java Theora decoder for JMF.

    I think, Sun wants us to use JavaFX for video playback. ๐Ÿ˜‰ I hope, they will integrate the JavaFX video component into a future version of Java. Unfortunately this will probably not happen for Java 7, since it is not mentioned in the feature list.
    http://openjdk.java.net/projects/jdk7/features/

    Have you tried Cortado? The player is open source now – Fluendo has donated it to xhiph.org some time ago.
    http://www.theora.org/cortado/

    Maybe it is possible to rework it into a decoder for JMF/FMJ?

    About Cinepak and QuickTime: I haven’t tried, but it might be possible to convert Cinepak in .AVI files into Cinepak in .MOV files using FFMPEG?

    Best,
    Werner

  3. Werner,

    Thank you for sharing your applications. I am trying to create a Java application running on Windows that receives MPEG4 video packets on a UDP port and renders the images on a Java panel. I have been attempting to use JMF with various plugins—FOBS, JFFMPEG—without success. Do you have any suggestions for getting JMF to process MP4 video? I would greatly appreciate any help you could offer. Thank you.

  4. Hi Tom,

    I have no recent experience with JMF and real time streaming using RTSP (Afaik RTSP is a UDP protocol). I tried it out many years ago, and it worked fine at the time.

    Afaik JMF together with JFFMPEG should be able to handle most file formats. I would first try getting these libraries to work with a local MP4 file. Once that is properly set up, I would tinker around with RTSP.

    Best,
    Werner

Comments are closed.