view src/com/aurellem/capture/AVIVideoRecorder.java @ 8:dde12be02029

removed TestAurellem
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Oct 2011 12:29:40 -0700
parents a92de00f0414
children
line wrap: on
line source
1 package com.aurellem.capture;
3 import java.awt.image.BufferedImage;
4 import java.io.File;
5 import java.io.IOException;
8 public class AVIVideoRecorder extends AbstractVideoRecorder{
10 AVIOutputStream out = null;
11 boolean videoReady = false;
12 BufferedImage frame;
14 public AVIVideoRecorder(File output) throws IOException {
15 super(output);
16 this.out = new AVIOutputStream(output, AVIOutputStream.VideoFormat.PNG, 24);
17 this.out.setVideoCompressionQuality(1.0f);
18 }
21 public void initVideo (){
22 frame = new BufferedImage(
23 width, height,
24 BufferedImage.TYPE_INT_RGB);
25 out.setFrameRate((int) Math.round(this.fps));
26 out.setTimeScale(1);
27 out.setVideoDimension(width, height);
28 this.videoReady = true;
29 }
31 public void record(BufferedImage rawFrame) {
32 if (!videoReady){initVideo();}
33 this.frame.getGraphics().drawImage(rawFrame, 0, 0, null);
34 try {out.writeFrame(frame);}
35 catch (IOException e){e.printStackTrace();}
36 }
38 public void finish() {
39 System.out.println("I'm finished! <3");
40 try {out.close();}
41 catch (IOException e) {e.printStackTrace();}
42 }
46 }