view src/com/aurellem/capture/video/AVIVideoRecorder.java @ 62:f5e52169f056

updated to work with new jme changes
author Robert McIntyre <rlm@mit.edu>
date Wed, 14 Dec 2011 17:43:52 -0700
parents 784a3f4e6202
children
line wrap: on
line source
1 package com.aurellem.capture.video;
3 import java.awt.image.BufferedImage;
4 import java.io.File;
5 import java.io.IOException;
7 import ca.randelshofer.AVIOutputStream;
10 public class AVIVideoRecorder extends AbstractVideoRecorder{
12 AVIOutputStream out = null;
13 boolean videoReady = false;
14 BufferedImage frame;
16 public AVIVideoRecorder(File output) throws IOException {
17 super(output);
18 this.out = new
19 AVIOutputStream(output, AVIOutputStream.VideoFormat.RAW, 24);
20 this.out.setFrameRate(60);
21 }
23 public void initVideo (){
24 frame = new BufferedImage(
25 width, height,
26 BufferedImage.TYPE_INT_RGB);
27 out.setFrameRate((int) Math.round(this.fps));
28 out.setTimeScale(1);
29 out.setVideoDimension(width, height);
30 this.videoReady = true;
31 }
33 public void record(BufferedImage rawFrame) {
34 if (!videoReady){initVideo();}
35 this.frame.getGraphics().drawImage(rawFrame, 0, 0, null);
36 try {out.writeFrame(frame);}
37 catch (IOException e){e.printStackTrace();}
38 }
40 public void finish() {
41 try {out.close();}
42 catch (IOException e) {e.printStackTrace();}
43 }
47 }