0

I have looked through the question "why can't i open avi in opencv?" already. But the solution mentioned there can not solve my problem, since there is no "opencv_ffmpeg*.dll" in the opencv for java at all. Even though I copied the "opencv_ffmpeg*.dll" into the folder containing opencv for java or added the path of bin folder which included the "opencv_ffmpeg*.dll" to the environment variable 'PATH', the problem still perplexed me.

The codes which go wrong are as below:

VideoCapture capture;
try{
    capture = new VideoCapture("1.avi");
} catch (Exception e){
    System.out.println("video not exist!");
    return;
}
if (!capture.isOpened()){
    System.out.println("fail to open the video!");
    return;  
}

I always got the "fail to open the video!" prompt. 1.avi is placed properly. Even though I used the absolute path, the problem remained.

Do anyone know how to solve this?

2 Answers2

0

As you found out issue is within missing ffmpeg.dll. Was facing the same problem and at the end it turned out to be an unset environment variable. First double check your OpenCV version. Go to the environmental variables window and add "openCV_installation_folder/build/x86_or_x64/vc12/bin" to the "Path" variable. Make sure that you set correct path depending on version of OpenCV and JVM you are using (32bit or 64bit). If you have Eclipse running then restart it. I hope this will help you and everyone you will face similar issue. Good luck.

De2ev
  • 29
  • 2
0

use capture.open("sample.avi") instead of passing to the constructor of videocapture this is if you are using opencv3.0 adn above