view src/com/aurellem/capture/video/AVIVideoRecorder.java @ 9:5dfc9e768816

moved files
author Robert McIntyre <rlm@mit.edu>
date Wed, 26 Oct 2011 08:54:12 -0700
parents
children 4c5fc53778c1
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;
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 }