if (log.isTraceEnabled()) {
log.trace(String.format("Image was captured in %s ms", System.currentTimeMillis() - start));
}
start = System.currentTimeMillis();
try {
VideoData data = se.encode(image);
if (log.isTraceEnabled()) {
log.trace(String.format("Image was encoded in %s ms", System.currentTimeMillis() - start));
}
frames.offer(data);
se.createUnalteredFrame();
} catch (IOException e) {
log.error("Error while encoding: ", e);
}
}
}, 0, timeBetweenFrames * NANO_MULTIPLIER, TimeUnit.NANOSECONDS);
sendScheduler.scheduleWithFixedDelay(new Runnable() {
public void run() {
VideoData f = frames.poll();
f = f == null ? se.getUnalteredFrame() : f;
if (f != null) {
try {
timestamp += timeBetweenFrames;
pushVideo(f, timestamp);