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