rlm@3: package com.aurellem.capture; rlm@3: rlm@3: rlm@3: /** rlm@3: * Handles writing video files using Xuggle. rlm@3: * rlm@3: * rlm@3: * @author Robert McIntyre rlm@3: * rlm@3: */ rlm@3: /* rlm@3: public class XuggleVideoRecorder extends AbstractVideoRecorder{ rlm@3: rlm@3: rlm@3: IMediaWriter writer; rlm@3: BufferedImage frame; rlm@3: int videoChannel = 0; rlm@3: long currentTimeStamp = 0; rlm@3: boolean videoReady = false; rlm@3: rlm@3: rlm@3: public XuggleVideoRecorder(File output) throws IOException {super(output);} rlm@3: rlm@3: public void initVideo(){ rlm@3: this.frame = new BufferedImage( rlm@3: width, height, rlm@3: BufferedImage.TYPE_3BYTE_BGR); rlm@3: this.writer = ToolFactory.makeWriter(this.targetFileName); rlm@3: writer.addVideoStream(videoChannel, rlm@3: 0, IRational.make(fps), rlm@3: width, height); rlm@3: this.videoReady = true; rlm@3: } rlm@3: rlm@3: rlm@3: public void record(BufferedImage rawFrame) { rlm@3: if (!this.videoReady){initVideo();} rlm@3: // convert the Image into the form that Xuggle likes. rlm@3: this.frame.getGraphics().drawImage(rawFrame, 0, 0, null); rlm@3: writer.encodeVideo(videoChannel, rlm@3: frame, rlm@3: currentTimeStamp, TimeUnit.NANOSECONDS); rlm@3: rlm@3: currentTimeStamp += (long) (1000000000.0 / fps); rlm@3: } rlm@3: rlm@3: public void finish() { rlm@3: writer.close(); rlm@3: } rlm@3: rlm@3: } rlm@3: rlm@3: */