private void saveFrameToFile() { /** Generate a key frame every 15th frame * */ boolean keyFrame = false; if (frameCount % 15 == 0) { keyFrame = true; frameCount = 0; } frameCount++; fileCapture.record(generateFrame(keyFrame)); }
public void initialize(Dimension screen, Dimension tile) { screenDim = screen; blockDim = tile; /** Initialize the recorder * */ try { fileCapture.init(); } catch (Exception e) { e.printStackTrace(); System.err.println("FatiledToOpenFile: " + e.getMessage()); } /** Initialize the blocks for this screen capture * */ factory = new BlockFactory(screen, tile); numColumns = factory.getColumnCount(); numRows = factory.getRowCount(); int numberOfBlocks = numColumns * numRows; for (int position = 1; position <= numberOfBlocks; position++) { Block block = factory.createBlock(position); blocksMap.put(new Integer(position), block); } /** Start the recorder */ sendCapturedScreen = true; capturedScreenSender = new Runnable() { public void run() { while (sendCapturedScreen) { saveFrameToFile(); try { Thread.sleep(250); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }; exec.execute(capturedScreenSender); }