view src/com/aurellem/capture/video/AVIVideoRecorder.java @ 34:13d354e1184b

trying to track down very strange bug where a listener and aux listener at the same location hear different things
author Robert McIntyre <rlm@mit.edu>
date Sun, 30 Oct 2011 14:58:01 -0700
parents be5ac56826be
children 784a3f4e6202
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;
7 import ca.randelshofer.AVIOutputStream;
10 public class AVIVideoRecorder extends AbstractVideoRecorder{
12 AVIOutputStream out = null;
13 boolean videoReady = false;
14 BufferedImage frame;
16 public AVIVideoRecorder(File output) throws IOException {
17 super(output);
18 this.out = new AVIOutputStream(output, AVIOutputStream.VideoFormat.PNG, 24);
19 this.out.setVideoCompressionQuality(1.0f);
20 }
23 public void initVideo (){
24 frame = new BufferedImage(
25 width, height,
26 BufferedImage.TYPE_INT_RGB);
27 out.setFrameRate((int) Math.round(this.fps));
28 out.setTimeScale(1);
29 out.setVideoDimension(width, height);
30 this.videoReady = true;
31 }
33 public void record(BufferedImage rawFrame) {
34 if (!videoReady){initVideo();}
35 this.frame.getGraphics().drawImage(rawFrame, 0, 0, null);
36 try {out.writeFrame(frame);}
37 catch (IOException e){e.printStackTrace();}
38 }
40 public void finish() {
41 try {out.close();}
42 catch (IOException e) {e.printStackTrace();}
43 }
47 }