rlm@3: package com.aurellem.capture; rlm@3: rlm@3: import java.awt.image.BufferedImage; rlm@3: import java.io.File; rlm@3: import java.io.IOException; rlm@3: rlm@3: rlm@3: public class AVIVideoRecorder extends AbstractVideoRecorder{ rlm@3: rlm@3: AVIOutputStream out = null; rlm@3: boolean videoReady = false; rlm@3: BufferedImage frame; rlm@3: rlm@3: public AVIVideoRecorder(File output) throws IOException { rlm@3: super(output); rlm@3: this.out = new AVIOutputStream(output, AVIOutputStream.VideoFormat.PNG, 24); rlm@3: this.out.setVideoCompressionQuality(1.0f); rlm@3: } rlm@3: rlm@3: rlm@3: public void initVideo (){ rlm@3: frame = new BufferedImage( rlm@3: width, height, rlm@3: BufferedImage.TYPE_INT_RGB); rlm@3: out.setFrameRate((int) Math.round(this.fps)); rlm@3: out.setTimeScale(1); rlm@3: out.setVideoDimension(width, height); rlm@3: this.videoReady = true; rlm@3: } rlm@3: rlm@3: public void record(BufferedImage rawFrame) { rlm@3: if (!videoReady){initVideo();} rlm@3: this.frame.getGraphics().drawImage(rawFrame, 0, 0, null); rlm@3: try {out.writeFrame(frame);} rlm@3: catch (IOException e){e.printStackTrace();} rlm@3: } rlm@3: rlm@3: public void finish() { rlm@3: System.out.println("I'm finished! <3"); rlm@3: try {out.close();} rlm@3: catch (IOException e) {e.printStackTrace();} rlm@3: } rlm@3: rlm@3: rlm@3: rlm@3: }