org.jcodec.api.FrameGrab Java Examples

The following examples show how to use org.jcodec.api.FrameGrab. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenViduTestAppE2eTest.java    From openvidu with Apache License 2.0 5 votes vote down vote up
private boolean recordedFileFine(File file, Recording recording) throws IOException {
	this.checkMultimediaFile(file, recording.hasAudio(), recording.hasVideo(), recording.getDuration(),
			recording.getResolution(), "aac", "h264", true);

	boolean isFine = false;
	Picture frame;
	try {
		// Get a frame at 75% duration and check that it has the expected color
		frame = FrameGrab.getFrameAtSec(file, (double) (recording.getDuration() * 0.75));
		BufferedImage image = AWTUtil.toBufferedImage(frame);
		Map<String, Long> colorMap = this.averageColor(image);

		String realResolution = image.getWidth() + "x" + image.getHeight();
		Assert.assertEquals(
				"Resolution (" + recording.getResolution()
						+ ") of recording entity is not equal to real video resolution (" + realResolution + ")",
				recording.getResolution(), realResolution);

		log.info("Recording map color: {}", colorMap.toString());
		log.info("Recording frame below");
		System.out.println(bufferedImageToBase64PngString(image));
		isFine = this.checkVideoAverageRgbGreen(colorMap);
	} catch (IOException | JCodecException e) {
		log.warn("Error getting frame from video recording: {}", e.getMessage());
		isFine = false;
	}
	return isFine;
}