annotate src/com/aurellem/capture/video/XuggleVideoRecorder.java @ 9:5dfc9e768816

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