Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You need to load the ffmpeg dll as well. You could create a folder structure

lib\opencv-300.jar
lib\x64\opencv_java300.dll
lib\x64\opencv_ffmpeg300_64.dll

and add the jar to your build path.

Then in your application load the libraries e. g. like this:

try {

    System.setProperty("java.library.path", "lib/x64");

    Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
    fieldSysPath.setAccessible(true);
    fieldSysPath.set(null, null);

} catch (Exception ex) {
    ex.printStackTrace();
    throw new RuntimeException(ex);
}

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
System.loadLibrary("opencv_ffmpeg300_64");

The video is now playable with

VideoCapture videoCapture = new VideoCapture();
videoCapture.open("c:/movies/mymovie.mp4");

You need to load the ffmpeg dll as well. You could create a folder structure

lib\opencv-300.jar
lib\x64\opencv_java300.dll
lib\x64\opencv_ffmpeg300_64.dll

and add the jar to your build path.

Then in your application load the libraries e. g. like this:

// set the library path during runtime (or specify it at program start via -Djava.library.path=...)
try {

    System.setProperty("java.library.path", "lib/x64");

    Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
    fieldSysPath.setAccessible(true);
    fieldSysPath.set(null, null);

} catch (Exception ex) {
    ex.printStackTrace();
    throw new RuntimeException(ex);
}

// load the required libraries
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
System.loadLibrary("opencv_ffmpeg300_64");

The video is now playable with

VideoCapture videoCapture = new VideoCapture();
videoCapture.open("c:/movies/mymovie.mp4");