Mercurial > jmeCapture
diff src/com/aurellem/capture/video/XuggleVideoRecorder.java @ 68:302d5e9ad120
adjust format
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 19 Jul 2012 12:28:55 -0500 |
parents | 8a6b1684f536 |
children | 2c50a0c99715 |
line wrap: on
line diff
1.1 --- a/src/com/aurellem/capture/video/XuggleVideoRecorder.java Tue Feb 28 11:17:04 2012 -0600 1.2 +++ b/src/com/aurellem/capture/video/XuggleVideoRecorder.java Thu Jul 19 12:28:55 2012 -0500 1.3 @@ -19,40 +19,43 @@ 1.4 1.5 public class XuggleVideoRecorder extends AbstractVideoRecorder{ 1.6 1.7 - IMediaWriter writer; 1.8 - BufferedImage frame; 1.9 - int videoChannel = 0; 1.10 - long currentTimeStamp = 0; 1.11 - boolean videoReady = false; 1.12 + 1.13 + IMediaWriter writer; 1.14 + BufferedImage frame; 1.15 + int videoChannel = 0; 1.16 + long currentTimeStamp = 0; 1.17 + boolean videoReady = false; 1.18 + 1.19 1.20 + public XuggleVideoRecorder(File output) 1.21 + throws IOException {super(output);} 1.22 1.23 - public XuggleVideoRecorder(File output) throws IOException {super(output);} 1.24 + public void initVideo(){ 1.25 + this.frame = new BufferedImage( 1.26 + width, height, 1.27 + BufferedImage.TYPE_3BYTE_BGR); 1.28 + this.writer = ToolFactory.makeWriter(this.targetFileName); 1.29 + writer.addVideoStream(videoChannel, 1.30 + 0, IRational.make(fps), 1.31 + width, height); 1.32 + this.videoReady = true; 1.33 + } 1.34 1.35 - public void initVideo(){ 1.36 - this.frame = new BufferedImage( 1.37 - width, height, 1.38 - BufferedImage.TYPE_3BYTE_BGR); 1.39 - this.writer = ToolFactory.makeWriter(this.targetFileName); 1.40 - writer.addVideoStream(videoChannel, 1.41 - 0, IRational.make(fps), 1.42 - width, height); 1.43 - this.videoReady = true; 1.44 - } 1.45 - 1.46 - public void record(BufferedImage rawFrame) { 1.47 - if (!this.videoReady){initVideo();} 1.48 - // convert the Image into the form that Xuggle likes. 1.49 - this.frame.getGraphics().drawImage(rawFrame, 0, 0, null); 1.50 - writer.encodeVideo(videoChannel, 1.51 - frame, 1.52 - currentTimeStamp, TimeUnit.NANOSECONDS); 1.53 + public void record(BufferedImage rawFrame) { 1.54 + if (!this.videoReady){initVideo();} 1.55 + // convert the Image into the form that Xuggle likes. 1.56 + this.frame.getGraphics().drawImage(rawFrame, 0, 0, null); 1.57 + writer.encodeVideo(videoChannel, 1.58 + frame, 1.59 + currentTimeStamp, TimeUnit.NANOSECONDS); 1.60 1.61 - currentTimeStamp += (long) (1000000000.0 / fps); 1.62 - } 1.63 + currentTimeStamp += (long) (1000000000.0 / fps); 1.64 + } 1.65 1.66 - public void finish() { 1.67 - writer.close(); 1.68 - } 1.69 + public void finish() { 1.70 + writer.close(); 1.71 + } 1.72 + 1.73 1.74 } 1.75