仓库指标
- Star
- (6,985 star)
- PR 合并指标
- (30 天内没有已合并 PR)
描述
private void initialiseFrameGrabber() { log.info("Starting new stream"); this.frameGrabber = new FFmpegFrameGrabber(RTSP_URL); this.frameGrabber.setFrameRate(1); try { this.frameGrabber.start(); } catch (FrameGrabber.Exception e) { log.error("error during starting frame grabber {}", e.getMessage()); } }
private void grabAndProcessFrame() {
while (true) {
try {
Frame frame = frameGrabber.grab();
boolean t = frame.keyFrame;
log.info("t: {}", t);
if (frame != null) {
log.info("Getting new frame with time: {}", now());
byte[] image = imageConverter.convertFrameToByteArray(frame);
executor.execute(() -> recognitionService.recognizePlate(image));
}
// frameGrabber.waitForTimestamp() // Thread.sleep(1000); } catch (FrameGrabber.Exception e) { log.error("Exception during getting new frame! {}", e.getMessage()); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
I want actually to grab frame only on each second. This is not valid code because it grabes frames which are in stream queue. Do you have some code or any solution how to handle getting frames only at each second, or to delay them somehow?