Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package bikecalibration; import java.io.File; import javafx.beans.property.DoubleProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.LongProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleLongProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import org.opencv.videoio.VideoCapture; import org.opencv.videoio.Videoio; /** * * @author vasja */ public class VideoInfo { public StringProperty FileName = null; public IntegerProperty Width = null; public IntegerProperty Height = null; public DoubleProperty FPS = null; public IntegerProperty TotalNumberOfFrames = null; public DoubleProperty Duration = null; public LongProperty FileSize = null; public VideoInfo(String fileName) { FileName = new SimpleStringProperty(); Width = new SimpleIntegerProperty(); Height = new SimpleIntegerProperty(); FPS = new SimpleDoubleProperty(); TotalNumberOfFrames = new SimpleIntegerProperty(); Duration = new SimpleDoubleProperty(); FileSize = new SimpleLongProperty(); File f = new File(fileName); VideoCapture cap = new VideoCapture(fileName); FileName.set(fileName); Width.set((int) cap.get(Videoio.CAP_PROP_FRAME_WIDTH)); Height.set((int) cap.get(Videoio.CAP_PROP_FRAME_HEIGHT)); FPS.set(cap.get(Videoio.CAP_PROP_FPS)); TotalNumberOfFrames.set((int) cap.get(Videoio.CAP_PROP_FRAME_COUNT)); Duration.set(1 / cap.get(Videoio.CAP_PROP_FPS) * cap.get(Videoio.CAP_PROP_FRAME_COUNT)); FileSize.set(f.length()); cap.release(); } }