annotate src/com/aurellem/capture/AVIVideoRecorder.java @ 4:edaa7e7806e4

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