[Ffmpeg-devel] contemplating adding Java support to libavcodec

Brent Baccala cosine
Fri Apr 28 07:54:59 CEST 2006


Hi -

I'm looking to build a Java-based video client using Java Media
Framework (JMF).  A problem with JMF as distributed is that it only
supports a limited subset of codecs (it can't handle H.263 bigger than
CIF, for example).  But it does have a plugin mechanism to add new
codecs, and they can use the Java Native Interface (JNI) to call C
code.

So, my plan is to add the hooks needed to libavcodec so that it can be
dynamically loaded into a Java VM, which should then allow JMF to use
all of libavcodec's codecs.  Sounds simple and powerful.  I'm looking
at avcodec_sample.cpp to figure out how to do it.

Assuming it works, I'd hope to include the C functions needed into
libavcodec, so a second shared library would not be required.  I don't
expect more than a single file containing a handful of functions with
mangled names like Java_pkg_Cls_f__ILjava_lang_String_2 (that's from
the JNI docs) that would be wrappers around things like avcodec_open,
avcodec_decode_video, and img_convert.  It would of course require
maintenance if the basic library calling sequence changed.

If the C hooks are included in the library, then it would probably
make sense to distribute (with the library source) the Java source to
the plugin that should be equally simple - one or two simple classes
that handoff their functions to the C code.  You'd have to download a
JMF implementation from Sun or IBM for it to be very useful, but if a
'hooked' version of libavcodec was already installed, using its codecs
with JMF would then be no more trouble than loading a class file.

The only thing I don't see how to handle portably is to query the
library to see what codecs it currently supports.  Can anybody
suggest how to do this?

I don't think libavformat will really be needed, since JMF can handle
AVI files, MPEG program streams, and RTP feeds natively.  Audio codecs
would probably be desirable, though.

Any comments or suggestions from the library developers would be
welcome...


 					-bwb

 					Brent Baccala
 					cosine at freesoft.org





More information about the ffmpeg-devel mailing list