Mercurial > jmeCapture
comparison src/com/aurellem/capture/video/AVIVideoRecorder.java @ 39:784a3f4e6202
updating capture-video
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 03 Nov 2011 16:00:46 -0700 |
parents | be5ac56826be |
children |
comparison
equal
deleted
inserted
replaced
38:adeb88787645 | 39:784a3f4e6202 |
---|---|
7 import ca.randelshofer.AVIOutputStream; | 7 import ca.randelshofer.AVIOutputStream; |
8 | 8 |
9 | 9 |
10 public class AVIVideoRecorder extends AbstractVideoRecorder{ | 10 public class AVIVideoRecorder extends AbstractVideoRecorder{ |
11 | 11 |
12 AVIOutputStream out = null; | 12 AVIOutputStream out = null; |
13 boolean videoReady = false; | 13 boolean videoReady = false; |
14 BufferedImage frame; | 14 BufferedImage frame; |
15 | 15 |
16 public AVIVideoRecorder(File output) throws IOException { | 16 public AVIVideoRecorder(File output) throws IOException { |
17 super(output); | 17 super(output); |
18 this.out = new AVIOutputStream(output, AVIOutputStream.VideoFormat.PNG, 24); | 18 this.out = new |
19 this.out.setVideoCompressionQuality(1.0f); | 19 AVIOutputStream(output, AVIOutputStream.VideoFormat.RAW, 24); |
20 } | 20 this.out.setFrameRate(60); |
21 | 21 } |
22 | 22 |
23 public void initVideo (){ | 23 public void initVideo (){ |
24 frame = new BufferedImage( | 24 frame = new BufferedImage( |
25 width, height, | 25 width, height, |
26 BufferedImage.TYPE_INT_RGB); | 26 BufferedImage.TYPE_INT_RGB); |
27 out.setFrameRate((int) Math.round(this.fps)); | 27 out.setFrameRate((int) Math.round(this.fps)); |
28 out.setTimeScale(1); | 28 out.setTimeScale(1); |
29 out.setVideoDimension(width, height); | 29 out.setVideoDimension(width, height); |
30 this.videoReady = true; | 30 this.videoReady = true; |
31 } | 31 } |
32 | 32 |
33 public void record(BufferedImage rawFrame) { | 33 public void record(BufferedImage rawFrame) { |
34 if (!videoReady){initVideo();} | 34 if (!videoReady){initVideo();} |
35 this.frame.getGraphics().drawImage(rawFrame, 0, 0, null); | 35 this.frame.getGraphics().drawImage(rawFrame, 0, 0, null); |
36 try {out.writeFrame(frame);} | 36 try {out.writeFrame(frame);} |
37 catch (IOException e){e.printStackTrace();} | 37 catch (IOException e){e.printStackTrace();} |
38 } | 38 } |
39 | 39 |
40 public void finish() { | 40 public void finish() { |
41 try {out.close();} | 41 try {out.close();} |
42 catch (IOException e) {e.printStackTrace();} | 42 catch (IOException e) {e.printStackTrace();} |
43 } | 43 } |
44 | 44 |
45 | 45 |
46 | 46 |
47 } | 47 } |