// Load native lib libopencv_java451
Video4j.init();
// Open the video
try (Video video = Videos.open(BIG_BUCK_BUNNY2_PATH)) {
// Video dimensions
video.width();
video.height();
// Configured FPS
video.fps();
// Total frames of the video
video.length();
// Seek to specific frame
video.seekToFrame(1020);
// Or just to the 50% point of the video
video.seekToFrameRatio(0.5d);
// Return the number of the current frame
video.currentFrame();
// Read the next frame as matrice (lower level access)
Mat mat = video.frameToMat();
// Read the next frame as image (mat gets automatically converted to image)
BufferedImage image = video.frameToImage();
// Read the frame and resize it to a width of 256 pixel.
BufferedImage image2 = video.boxedFrameToImage(256);
// Display the frame in a window
ImageUtils.show(image);
}
|