Open nhwxhn opened 2 years ago
I want to get multiple frames in a row, but the grabber.grabImage() method is too slow, can it be optimized? Below is my code
int flag = 1; List<Map<Integer, Frame>> lists = new ArrayList<>(); while (flag < 64) { Map<Integer,Frame> map = new HashMap<>(); Frame frame = grabber.grabImage(); map.put(flag,frame); lists.add(map); flag++; } log.info("lists"); for (Map<Integer, Frame> map : lists) { map.forEach((k,v)->{ DecimalFormat decimalFormat = new DecimalFormat("00000"); String name = decimalFormat.format(k); File imgUrl = new File("C:\\Users\\Administrator\\Desktop\\video\\" + name + ".jpg"); Java2DFrameConverter converter = new Java2DFrameConverter(); BufferedImage bufferedImage = converter.getBufferedImage(v); try { ImageIO.write(bufferedImage, "jpg", imgUrl); } catch (IOException e) { e.printStackTrace(); } }); }
You could try to use hardware acceleration: https://trac.ffmpeg.org/wiki/HWAccelIntro
Thank you, I will refer to
I want to get multiple frames in a row, but the grabber.grabImage() method is too slow, can it be optimized? Below is my code