rlm@39: package com.aurellem.capture.video; rlm@39: rlm@39: import java.awt.image.BufferedImage; rlm@39: import java.io.File; rlm@39: import java.io.IOException; rlm@39: import javax.imageio.ImageIO; rlm@39: rlm@39: public class FileVideoRecorder extends AbstractVideoRecorder{ rlm@39: int current; rlm@39: File outDir; rlm@39: String formatName = "png"; rlm@39: rlm@39: public FileVideoRecorder(File output) throws IOException { rlm@39: super(output); rlm@39: if (output.exists() rlm@39: && output.isDirectory() rlm@39: && (0 == output.listFiles().length)){ rlm@39: // good rlm@39: } rlm@39: else if (!output.exists()){ rlm@39: output.mkdir(); rlm@39: } rlm@39: else { rlm@39: throw new IOException("argument must be either an empty " + rlm@39: "directory or a nonexistent one."); rlm@39: } rlm@39: this.outDir = output; rlm@39: } rlm@39: rlm@39: public void record(BufferedImage rawFrame) { rlm@39: String name = String.format("%07d.%s" , current++, formatName); rlm@39: File target = new File(output, name); rlm@39: try {ImageIO.write(rawFrame, formatName, target);} rlm@39: catch (IOException e) {e.printStackTrace();} rlm@39: } rlm@39: rlm@39: public void finish() {} rlm@39: } rlm@39: rlm@39: rlm@39: