view src/com/aurellem/capture/video/AVIVideoRecorder.java @ 63:df4a2d12ea13

added new timer for debugging purposes
author Robert McIntyre <rlm@mit.edu>
date Sun, 15 Jan 2012 04:10:37 -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 }