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