VideoCapture skipping frames

asked 2016-07-04 05:05:53 -0600

aldev gravatar image

Hi,

I'm working on a video processing algorithm in the Java version of OpenCV. I'm using the following functions to read the video file:

    VideoCapture camera = new VideoCapture(video_path);

    if (!camera.isOpened())
        System.out.println("Cannot open file");

    else
    {

        while (true) {
            boolean frameSuccess = camera.read(currentFrame);
            framecount ++;
            System.out.printf("frame: %d", framecount);
            if (frameSuccess != true)
            {   
                break;
            }

and then I process the frames one by one.

The problem is that apparently, the program "skips" frames. The variable framecount doesn't correspond to the real number of frames of the video. The videos are in webm format.

Why might be this failing?

edit retag flag offensive close merge delete

Comments

Have you tried with different file formats?Like mp4,mkv or avi?

can gravatar imagecan ( 2016-07-04 05:55:08 -0600 )edit