tags:

views:

120

answers:

3

How would I convert an an array of BufferedImages into a video? I'm making a screen recorder.

This is my main question, but if you know, how would I compress the video afterward?

Thanks.

+3  A: 

You'll need the JMF (Java Media Framework) API for this. Sun has a code sample on the subject in the JMF documentation: Generating a Movie File from a List of (JPEG) Images.

BalusC
Is there a simpler answer? I'm totally confused, AND, when I paste it into Eclipse, I get 60 errors... >.<
Stuart
and the errors are? did you put the JMF on the classpath?
Bozho
On the 1st link you can find at the bottom a download link to JMF API. Put it in project's buildpath in Eclipse. You may want to look for other solutions -eventually built on top of the JMF API, so that it's less verbose. But at least be happy that the JMF API exist, otherwise you need to have precise knowledge how to read images and create videos at low binary level (which obviously needs much more code).
BalusC
Is there a way to do it without JMF? Ugh, I worked so hard on my screen recorder application and I feel like it's all for nothing because the image to video part is way out of my league... =(
Stuart
Certainly you can do it without JMF. Even more, the JMF itself is also just built on top of the existing Java SE API. You only have to learn how the movie file should look like "under the hoods" (at binary level) so that you know what exactly to code in Java.
BalusC
A: 

Werner Randelshofer did some work to create a Quicktime movie. See: http://blog.hslu.ch/rawcoder/2008/08/12/writing-avi-videos-using-pure-java/

You could also use Xuggler: http://www.xuggle.com

DerMike
+1  A: 

You can use Xuggler (on Windows, Mac or Linux) to do this, and the following tutorials will show you exactly how to do it. In particular, see the (I'm not kidding) "How to Grow Some Balls" tutorial for a program that makes a video out of a series of BufferedImages (and some audio).

Xuggle
Thank you! Something I can understand! However, I'm confused as to how I put in into Eclipse. Also, I'm going to be exporting this as an independent application. When I export it with Eclipse, will it include Xuggler in the jar? Also, is there a way I can only put MediaTools in what I export, so that I save space? Because according to the tutorial it looks like it's all I need.
Stuart
You need to make sure the right environment variables (see the install instructions) are set when you run as it uses native code. The installers for windows does that automatically. As for bundling the jar, you can do that, or you can insert the source code in your jar given that it's LGPL and open source.
Xuggle
When I try to run the shell file for installation I get "permission denied". I'm not an admin, but I suppose I could ask my dad to install it. Is there a way I can just stick Xuggler in each jar and run it that way without having to install anything? Sorry I'm asking so much...
Stuart
We can't currently stick it in a Jar file (it's on our roadmap), but to work around on Linux or Mac, when it asks you for an installation path, just enter a directlry you can write-to, and then set the environment variables the installer tells you at the end.
Xuggle