annotate 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
rev   line source
rlm@9 1 package com.aurellem.capture.video;
rlm@9 2
rlm@9 3 import java.awt.image.BufferedImage;
rlm@9 4 import java.io.File;
rlm@9 5 import java.io.IOException;
rlm@9 6
rlm@10 7 import ca.randelshofer.AVIOutputStream;
rlm@10 8
rlm@9 9
rlm@9 10 public class AVIVideoRecorder extends AbstractVideoRecorder{
rlm@9 11
rlm@39 12 AVIOutputStream out = null;
rlm@39 13 boolean videoReady = false;
rlm@39 14 BufferedImage frame;
rlm@9 15
rlm@39 16 public AVIVideoRecorder(File output) throws IOException {
rlm@39 17 super(output);
rlm@39 18 this.out = new
rlm@39 19 AVIOutputStream(output, AVIOutputStream.VideoFormat.RAW, 24);
rlm@39 20 this.out.setFrameRate(60);
rlm@39 21 }
rlm@9 22
rlm@39 23 public void initVideo (){
rlm@39 24 frame = new BufferedImage(
rlm@39 25 width, height,
rlm@39 26 BufferedImage.TYPE_INT_RGB);
rlm@39 27 out.setFrameRate((int) Math.round(this.fps));
rlm@39 28 out.setTimeScale(1);
rlm@39 29 out.setVideoDimension(width, height);
rlm@39 30 this.videoReady = true;
rlm@39 31 }
rlm@9 32
rlm@39 33 public void record(BufferedImage rawFrame) {
rlm@39 34 if (!videoReady){initVideo();}
rlm@39 35 this.frame.getGraphics().drawImage(rawFrame, 0, 0, null);
rlm@39 36 try {out.writeFrame(frame);}
rlm@39 37 catch (IOException e){e.printStackTrace();}
rlm@39 38 }
rlm@9 39
rlm@39 40 public void finish() {
rlm@39 41 try {out.close();}
rlm@39 42 catch (IOException e) {e.printStackTrace();}
rlm@39 43 }
rlm@9 44
rlm@9 45
rlm@9 46
rlm@9 47 }