Mercurial > jmeCapture
comparison src/com/aurellem/capture/video/FileVideoRecorder.java @ 39:784a3f4e6202
updating capture-video
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 03 Nov 2011 16:00:46 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
38:adeb88787645 | 39:784a3f4e6202 |
---|---|
1 package com.aurellem.capture.video; | |
2 | |
3 import java.awt.image.BufferedImage; | |
4 import java.io.File; | |
5 import java.io.IOException; | |
6 import javax.imageio.ImageIO; | |
7 | |
8 public class FileVideoRecorder extends AbstractVideoRecorder{ | |
9 int current; | |
10 File outDir; | |
11 String formatName = "png"; | |
12 | |
13 public FileVideoRecorder(File output) throws IOException { | |
14 super(output); | |
15 if (output.exists() | |
16 && output.isDirectory() | |
17 && (0 == output.listFiles().length)){ | |
18 // good | |
19 } | |
20 else if (!output.exists()){ | |
21 output.mkdir(); | |
22 } | |
23 else { | |
24 throw new IOException("argument must be either an empty " + | |
25 "directory or a nonexistent one."); | |
26 } | |
27 this.outDir = output; | |
28 } | |
29 | |
30 public void record(BufferedImage rawFrame) { | |
31 String name = String.format("%07d.%s" , current++, formatName); | |
32 File target = new File(output, name); | |
33 try {ImageIO.write(rawFrame, formatName, target);} | |
34 catch (IOException e) {e.printStackTrace();} | |
35 } | |
36 | |
37 public void finish() {} | |
38 } | |
39 | |
40 | |
41 |