annotate src/com/aurellem/capture/XuggleVideoRecorder.java @ 4:edaa7e7806e4

migrated IsoTimer
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Oct 2011 12:03:01 -0700
parents a92de00f0414
children
rev   line source
rlm@3 1 package com.aurellem.capture;
rlm@3 2
rlm@3 3
rlm@3 4 /**
rlm@3 5 * Handles writing video files using Xuggle.
rlm@3 6 *
rlm@3 7 *
rlm@3 8 * @author Robert McIntyre
rlm@3 9 *
rlm@3 10 */
rlm@3 11 /*
rlm@3 12 public class XuggleVideoRecorder extends AbstractVideoRecorder{
rlm@3 13
rlm@3 14
rlm@3 15 IMediaWriter writer;
rlm@3 16 BufferedImage frame;
rlm@3 17 int videoChannel = 0;
rlm@3 18 long currentTimeStamp = 0;
rlm@3 19 boolean videoReady = false;
rlm@3 20
rlm@3 21
rlm@3 22 public XuggleVideoRecorder(File output) throws IOException {super(output);}
rlm@3 23
rlm@3 24 public void initVideo(){
rlm@3 25 this.frame = new BufferedImage(
rlm@3 26 width, height,
rlm@3 27 BufferedImage.TYPE_3BYTE_BGR);
rlm@3 28 this.writer = ToolFactory.makeWriter(this.targetFileName);
rlm@3 29 writer.addVideoStream(videoChannel,
rlm@3 30 0, IRational.make(fps),
rlm@3 31 width, height);
rlm@3 32 this.videoReady = true;
rlm@3 33 }
rlm@3 34
rlm@3 35
rlm@3 36 public void record(BufferedImage rawFrame) {
rlm@3 37 if (!this.videoReady){initVideo();}
rlm@3 38 // convert the Image into the form that Xuggle likes.
rlm@3 39 this.frame.getGraphics().drawImage(rawFrame, 0, 0, null);
rlm@3 40 writer.encodeVideo(videoChannel,
rlm@3 41 frame,
rlm@3 42 currentTimeStamp, TimeUnit.NANOSECONDS);
rlm@3 43
rlm@3 44 currentTimeStamp += (long) (1000000000.0 / fps);
rlm@3 45 }
rlm@3 46
rlm@3 47 public void finish() {
rlm@3 48 writer.close();
rlm@3 49 }
rlm@3 50
rlm@3 51 }
rlm@3 52
rlm@3 53 */