Ask Your Question
2

VideoCapture can not open some files

asked 2015-09-18 15:37:40 -0500

shofwan gravatar image

My simple code here:

VideoCapture camera = new VideoCapture("visiontraffic.avi");
    if (!camera.isOpened()) {
        System.out.println("Can not open Camera, try it later.");
    }

can only open that file (visiontraffic.avi) but no other files with avi format or other format. Opening camera works fine with:

VideoCapture camera = new VideoCapture(0);

my whole code and my video example can be downloaded here: https://www.dropbox.com/sh/dshmg0cnou...

please help me I'm confused. Other cases I found was absolutely cannot open any video at all, neither opening camera. And I've seen how to resolve it here:

  1. http://stackoverflow.com/questions/84...
  2. http://answers.opencv.org/question/70... (still no answer)
  3. http://answers.opencv.org/question/69... (still no answer)
  4. http://answers.opencv.org/question/54...

Actually I didn't really understand how to installing ffmpeg, recompile opencv with ffmpeg config, etc but I think my problem isn't there. And I've tried to copy ffmpeg.dll from opencv everywhere.

thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-09-20 10:12:40 -0500

RolandC gravatar image

What you are missing in your code is the loading of the ffmpeg dll. Just put the opencv_ffmpeg300_64.dll from the OpenCV installation into the java library folder, i. e. where the opencv_java300.dll resides and add this to your code:

System.loadLibrary("opencv_ffmpeg300_64");

Just tried it, works fine.

ps: Where did you get these videos, are they free to use? I just started with OpenCV and java yesterday and would need some samples.

edit flag offensive delete link more

Comments

1

It's free to use. I get it here

shofwan gravatar imageshofwan ( 2015-09-21 04:32:42 -0500 )edit

@RolandC, thanks for such a good answer. I applied the same, the video is playing but the sound is not coming. Can you guide me

Abdul Muheet gravatar imageAbdul Muheet ( 2018-03-01 13:57:17 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-09-18 15:34:18 -0500

Seen: 476 times

Last updated: Sep 20 '15