diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/com/aurellem/capture/video/AVIVideoRecorder.java	Wed Oct 26 08:54:12 2011 -0700
     1.3 @@ -0,0 +1,46 @@
     1.4 +package com.aurellem.capture.video;
     1.5 +
     1.6 +import java.awt.image.BufferedImage;
     1.7 +import java.io.File;
     1.8 +import java.io.IOException;
     1.9 +
    1.10 +
    1.11 +public class AVIVideoRecorder extends AbstractVideoRecorder{
    1.12 +
    1.13 +	AVIOutputStream out = null;
    1.14 +	boolean videoReady = false;
    1.15 +	BufferedImage frame;
    1.16 +	
    1.17 +	public AVIVideoRecorder(File output) throws IOException {
    1.18 +		super(output);
    1.19 +		this.out = new AVIOutputStream(output, AVIOutputStream.VideoFormat.PNG, 24);
    1.20 +		this.out.setVideoCompressionQuality(1.0f);
    1.21 +	}
    1.22 +
    1.23 +	
    1.24 +	public void initVideo (){
    1.25 +		frame = new BufferedImage(
    1.26 +				width, height,
    1.27 +				BufferedImage.TYPE_INT_RGB);
    1.28 +		out.setFrameRate((int) Math.round(this.fps));
    1.29 +		out.setTimeScale(1);
    1.30 +		out.setVideoDimension(width, height);
    1.31 +		this.videoReady = true;
    1.32 +	}
    1.33 +	
    1.34 +	public void record(BufferedImage rawFrame) {
    1.35 +		if (!videoReady){initVideo();}
    1.36 +		this.frame.getGraphics().drawImage(rawFrame, 0, 0, null);
    1.37 +		try {out.writeFrame(frame);}
    1.38 +		catch (IOException e){e.printStackTrace();}
    1.39 +	}
    1.40 +	
    1.41 +	public void finish() {
    1.42 +		System.out.println("I'm finished! <3");
    1.43 +		try {out.close();} 
    1.44 +		catch (IOException e) {e.printStackTrace();}
    1.45 +	}
    1.46 +
    1.47 +	
    1.48 +
    1.49 +}