The Source for Java Technology Collaboration
User: Password:



Fabrizio Giudici

Fabrizio Giudici's Blog

What about Movies?

Posted by fabriziogiudici on August 28, 2007 at 04:37 AM | Comments (9)

In the latest days I've writing some code to investigate about how hard or easy would be to extend blueMarine capabilities to manage movies in addition to photos.

While my personal interest and volunteering efforts about blueMarine are primarily photo-oriented (I'm really a still photographer!), some modules are involved in my business and a customer asked me about movies for a digital asset management application. So I did some preliminary investigation work.

A first part of the work consisted in just a big refactoring of blueMarine for a better design. In a few words, while up to a few weeks ago the "Photo" module, with its main class PhotoDataObject, was a central point in blueMarine (e.g. with the Thumbnail, Gallery and Trip modules depending on it), a good IoC refactoring made it possible to have everything depending on the pure DataObject (which is a NetBeans API class). PhotoDataObject is now just an extension that other modules aren't aware of (with the exception of a few remaining portions that will be fixed soon), so at the moment blueMarine can manage every kind of datum for which the creation of a thumbnail has a meaning. This of course include movies.

The problem is now about what Java offers in this field. Chris Adamson and Chet Haase blogged in the last months about this topic (1, 2, 3). While I invite you to look at their posts for more details, the conclusion is that at the moment Java is severely lacking a working API for movies. The Java Media Framework (JMF) had a bad fate and is considered dead. Other "branded" APIs, such as QuickTime for Java, are going to die since Apple's attitude towards Java seems oriented to just support the standard platform and nothing more. As you can read in Chet's blog, Sun is working to recover, but no earlier than Java 7, which is two years from now and not an option for me.

Chris' conclusion is to look at existing native libraries (such as ffmpeg or GStreamer) and use a Java wrapper around them (this is only a part of Chris' conclusion, the part which is relevant for me).

Searching around, I've found Ken Larson's FMJ project, which sounds to be directed in that way. Ken's work - for what I've understood after a very quick inspection - includes an implementation of the JMF specs together with wrappers for some existing libraries, including ffmpeg, QuickTime and others. In the end its Player implementation, with some cut and paste from the examples code, allowed me to quickly create a "MovieViewer" module which is the analog component of the "PhotoViewer": it can reproduce movies inside blueMarine (with some troubles still, for instance getting a strong blue cast in the image, which is probably related so some configuration problem on my Mac).




Of course this is not enough. Merely for cataloguing purposes, I need the capability of extracting still frames out of a movie, so I can build a thumbnail. Emmanuele's work with blueMoon, the plugin for astrophotographers, also needs the extraction of still frames; furthermore my personal still photos interests are expanding to "time-lapse photography", a technique about creating a movie out of a sequence of still photos taken at regular time intervals (see Thomas Kranzle's awesome work for an example).

For these reasons I've sketched out some experimental blueMarine modules (azureRiver) and a stand-alone library (Zephyr) which could be thought of as a Mistral extension for movies. The idea here is to wrap every existing API I need with a simplified interface. For instance, as Mistral allows to load, crop and compute the histogram of an image in just four lines of code:


        EditableImage image = EditableImage.create(new ReadOp(new File("20030701-0043.NEF")));
        image.execute(new CropOp(10, 10, 600, 400));
        Histogram histogram = image.execute(new HistogramOp()).getHistogram();
        histogram.compute();


Zephyr allows to extract still frames from movies as easily as:


        EditableMovie editableMovie = EditableMovie.create(new File("mymovie.mov"));
        EditableImage image = editableMovie.execute(new GrabFrameOp(1)).getFrame();


While in all my previous posts I published some more polished code, Zephyr is just the first step after the idea (in details: it's badly coded, it is only based on ffmpeg-Java, I've included only the Mac OS X Intel native library, etc...). My point is that I'd like to know what is other people's interest about this. While I'm strongly committed with Mistral and the still-photo parts of blueMarine, Zephyr is only focused to my current customer's interest - and he has still to decide, also basing on my investigation, if this thing should be really started or not. If some reader would like to join and take a primary role in this stuff, Zephyr could take off even if my customer decides for a "no-go". So I hope to get some feedback to this post!

PS If you would like to look at the code, point your Subversion client to https://azureriver.dev.java.net/svn/azureriver/trunk/src. If you would like to try the thing, download blueMarine 0.9.RC1, use the Plugin Manager to add the following Update Centers:
  • https://bluemarine.dev.java.net/nonav/UpdateCenter/0.9.RC1-hotfix/blueMarine/updates.xml
  • https://azureriver.dev.java.net/nonav/UpdateCenter/0.9.RC1-hotfix/updates.xml

and download the stuff from them. Remember that thumbnail generation only works on Mac OS X Intel at the moment; the movie player could work also with other platforms (but I've tried it only with Mac OS X).




Technorati Tags: , , , , ,

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Hello Fabrizio.
    Did you -by any chance- compare fmj with jobs? ( http://fobs.sourceforge.net )
    If so, what are the advantages/weaknesses you found for each, or shorter, why one instead of the other?

    I was about to use fobs for a video application, but your post made me wonder if i was going in the right direction.

    Excellent post, as always !

    Posted by: pepe on August 29, 2007 at 08:42 AM

  • Hi Pepe.

    No, I wasn't even aware of fobs, sorry. I'll have a look at it now!

    Posted by: fabriziogiudici on August 29, 2007 at 09:42 AM

  • it doesn't matter at all with this post, anyway...
    are you aware of this?
    http://ajaxian.com/archives/new-technology-dynamic-resizing-of-images

    what do you think about?

    Posted by: ildella on August 30, 2007 at 12:40 AM

  • http://bluemarine.tidalwave.it/issues/browse/BM-494 :-)

    BTW, as a photographer I'm not thrilling for it, since it looks like a way to heavy manipulate photos, which is something I don't do; but other potential blueMarine users could enjoy it, of course, and it's really cool - and thus demo oriented ;-) . And maybe it can be used for "standard" operations such as dust removal, etc...

    Posted by: fabriziogiudici on August 30, 2007 at 01:39 AM

  • I will stand on same side as Fabrizio.
    It looks like an impressive idea, with tons of applications and huge amount of money to tear-off, but as a non-manipulating photographer (i almost never retouched photos, except colorimetry/balance), this only makes me sigh and roll eyes to the sky.

    Posted by: pepe on August 30, 2007 at 02:44 AM

  • Hello,

    I like the java videolan api, it's simple.
    http://jvlc.ihack.it/doc/
    or more general
    http://wiki.videolan.org/MediaControlAPI

    ffmpeg-java is a good solution for reading lot a different video file on Mac OS, Windows or Linux.

    I need correspondance between frame number and lenth (time) of the video like 1h03m45s,12 (Position in MediaControlAPI videolan api)

    I try this day ffmpeg-java on windows XP but i have link error with native library dll ...

    Vincent D.

    Posted by: vdaburon on August 31, 2007 at 08:53 AM

  • Fabrizo,
    Can you please drop a mail to my dev.java.net account (add pepe@) about your fobs findings if you have any?
    Thank you.

    Posted by: pepe on September 04, 2007 at 01:09 AM

  • Sure pepe. But don't expect anything soon (i.e. before the end of the month).

    Posted by: fabriziogiudici on September 04, 2007 at 05:23 AM

  • With respect to that XP link error with the native dlls, I ran into that also. It turned out that when I was building ffmpeg and doing a make install it was copying the fully named dll to my cygwin lib directory (e.g. cygavcodec-51.43.0.dll) and then creates a symbolic link with a name that is used in the actual reference between DLLs (e.g cygavcodec-51.dll). But java on XP doesn't recognize the symbolic links and gives the UnsatisfiedLinkError. I fixed it by deleting the sym links and just copying cygavcodec-51.43.0.dll to cygavcodec-51.dll, etc. This resolved the link error. I don't know if this is what you are running into but you might want to check to see the DLLs reference are not symbolic links.

    Posted by: swatdba on September 12, 2007 at 02:42 PM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds