annotate src/com/aurellem/capture/video/AVIVideoRecorder.java @ 19:4de7988407ef

added CompositeSoundProcessor for combining SoundProcessors
author Robert McIntyre <rlm@mit.edu>
date Sat, 29 Oct 2011 15:16:06 -0700
parents be5ac56826be
children 784a3f4e6202
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@9 12 AVIOutputStream out = null;
rlm@9 13 boolean videoReady = false;
rlm@9 14 BufferedImage frame;
rlm@9 15
rlm@9 16 public AVIVideoRecorder(File output) throws IOException {
rlm@9 17 super(output);
rlm@9 18 this.out = new AVIOutputStream(output, AVIOutputStream.VideoFormat.PNG, 24);
rlm@9 19 this.out.setVideoCompressionQuality(1.0f);
rlm@9 20 }
rlm@9 21
rlm@9 22
rlm@9 23 public void initVideo (){
rlm@9 24 frame = new BufferedImage(
rlm@9 25 width, height,
rlm@9 26 BufferedImage.TYPE_INT_RGB);
rlm@9 27 out.setFrameRate((int) Math.round(this.fps));
rlm@9 28 out.setTimeScale(1);
rlm@9 29 out.setVideoDimension(width, height);
rlm@9 30 this.videoReady = true;
rlm@9 31 }
rlm@9 32
rlm@9 33 public void record(BufferedImage rawFrame) {
rlm@9 34 if (!videoReady){initVideo();}
rlm@9 35 this.frame.getGraphics().drawImage(rawFrame, 0, 0, null);
rlm@9 36 try {out.writeFrame(frame);}
rlm@9 37 catch (IOException e){e.printStackTrace();}
rlm@9 38 }
rlm@9 39
rlm@9 40 public void finish() {
rlm@9 41 try {out.close();}
rlm@9 42 catch (IOException e) {e.printStackTrace();}
rlm@9 43 }
rlm@9 44
rlm@9 45
rlm@9 46
rlm@9 47 }