« Home | Contact Joint Summary » | Dual-space Expansion for Estimating Penetration de... » | Trouble With The Projection » | Contact Manifold & Signed Distance Map » | Intersection and Penetration Depth » | Crank Model Now Works » | Constraint Force Mixing » | Linear-Time Dynamics using Lagrange Multipliers » | Piston Assembly Simulation » | Implementing Piston Assembly Model »

Make Movies

Step 1:

Do screen grab at every frame and encode the captured image to JPEG format. The solution could come from Java 3D but using Robot seems to be a more stable method (from I read from different forums).

try {
Rectangle win = getBounds();
Robot robot = new Robot(getGraphicsConfiguration().getDevice());
BufferedImage image =
robot.createScreenCapture(new Rectangle(win.x, win.y,
win.width, win.height));
FileOutputStream out = new FileOutputStream("image" + jpgCount + ".jpg");
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(image);
param.setQuality(0.9f, false);
} catch(AWTException e) {
} catch(IOException e) {
System.err.println("I/O exception!");

Step 2:

Stitch the still images into a movie using ffmpeg:

ffmpeg -i image%d.jpg -b 800 movie.mpg


ffmpeg -i image%d.jpg -sameq movie.mpg

Bit rate is probably the main factor for quality. Choose wisely. The default bit rate of 200 yields low quality result.

In windows, make a "makemovie.bat" that consists of this line will also works

ffmpeg -i image\image%%d.jpg -sameq movie.mpg

Post a Comment