annotate 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
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@9 7
rlm@9 8 public class AVIVideoRecorder extends AbstractVideoRecorder{
rlm@9 9
rlm@9 10 AVIOutputStream out = null;
rlm@9 11 boolean videoReady = false;
rlm@9 12 BufferedImage frame;
rlm@9 13
rlm@9 14 public AVIVideoRecorder(File output) throws IOException {
rlm@9 15 super(output);
rlm@9 16 this.out = new AVIOutputStream(output, AVIOutputStream.VideoFormat.PNG, 24);
rlm@9 17 this.out.setVideoCompressionQuality(1.0f);
rlm@9 18 }
rlm@9 19
rlm@9 20
rlm@9 21 public void initVideo (){
rlm@9 22 frame = new BufferedImage(
rlm@9 23 width, height,
rlm@9 24 BufferedImage.TYPE_INT_RGB);
rlm@9 25 out.setFrameRate((int) Math.round(this.fps));
rlm@9 26 out.setTimeScale(1);
rlm@9 27 out.setVideoDimension(width, height);
rlm@9 28 this.videoReady = true;
rlm@9 29 }
rlm@9 30
rlm@9 31 public void record(BufferedImage rawFrame) {
rlm@9 32 if (!videoReady){initVideo();}
rlm@9 33 this.frame.getGraphics().drawImage(rawFrame, 0, 0, null);
rlm@9 34 try {out.writeFrame(frame);}
rlm@9 35 catch (IOException e){e.printStackTrace();}
rlm@9 36 }
rlm@9 37
rlm@9 38 public void finish() {
rlm@9 39 System.out.println("I'm finished! <3");
rlm@9 40 try {out.close();}
rlm@9 41 catch (IOException e) {e.printStackTrace();}
rlm@9 42 }
rlm@9 43
rlm@9 44
rlm@9 45
rlm@9 46 }