I want to generate a thumbnail preview of videos in Java. I'm mostly JMF and video manipulation alienated.
- Is there an easy way to do it?
- What about codecs? Will I have to deal with it?
- Any video type is suported? (including Quicktime)
I want to generate a thumbnail preview of videos in Java. I'm mostly JMF and video manipulation alienated.
Are you sure that JMF is right for you? Unfortunately, it is not in particularly good shape. Unless you are already committed to JMF, you very well may want to investigate alternatives. Wikipedia has a decent overview at en.wikipedia.org/wiki/Java_Media_Framework
Many JMF developers have complained that it supports few codecs and formats in modern use. Its all-Java version, for example, cannot play MPEG-2, MPEG-4, Windows Media, RealMedia, most QuickTime movies, Flash content newer than Flash 2, and needs a plug-in to play the ubiquitous MP3 format. While the performance packs offer the ability to use the native platform's media library, they're only offered for Linux, Solaris and Windows. Furthermore, Windows-based JMF developers can unwittingly think JMF provides support for more formats than it does, and be surprised when their application is unable to play those formats on other platforms.
Another knock against JMF is Sun's seeming abandonment of it. The API has not been touched since 1999, and the last news item on JMF's home page was posted in November 2004.
While JMF is built for extensibility, there are few such third-party extensions.
Furthermore, editing functionality in JMF is effectively non-existent, which makes a wide range of potential applications impractical.
There seems to be a few examples out there that are far better than what I was going to send you.
See http://krishnabhargav.blogspot.com/2008/02/processing-videos-in-java.html.
I'd agree with Stu, however. If you can find a way to get what you want using some command-line tools (and run them using Commons-Exec), you might have a better overall solution than depending on what is essentially the Sanskrit of Java extensions.
Thanks @Joe and @Stu! I'm not stuck with JMF. I just didn't know other solutions. I saw somewhere that IBM developed some extensions, but I also noticed the lack of update in Sun's website.
The command-line tools is a nice idea. But I'll first try the code you linked. I'm coming back later with a feedback to you.
Thanks
Both solutions didn't work @Joe. :(
Tried getting an image from wmv, mpg, avi. Or the system hangs, or doesn't find a player or simply throws a NullPointerException. I thik I'll stick with the command-line idea.
@marcio - My own server-side app shells out to ffmpeg to do encoding. I'm 98.42% sure ffmpeg does snapshots, too. (It is an all singing, all dancing beast of a program. The command line options alone could fill a book.)
Check it out: ffmpeg.mplayerhq.hu
Well, since you're not stuck with JMF, have you considered Xuggler? Xuggler is a Java API that uses FFmpeg under the covers to do all video decoding and encoding. It's free and LGPL licensed.
In fact, we have a tutorial that shows How to Make Thumbnails of an Existing File