OpenCV on iOS - VideoCapture properties always return 1

I am trying to create a simple OpenCV (iOS) application that downloads a video from a package and requests it for frame counting, duration, etc., then it will try to extract individual frames from it. Unfortunately, when I use the class VideoCapture, all properties return values ​​of 1. Then I try to go to frame #100, but this also does not work. Am I doing it wrong?

cv::VideoCapture capture([[movieURL path] UTF8String]);
if (!capture.isOpened()) {
    Log(@"Could not open the video:%@", [movieURL path]);
}

double rate = capture.get(CV_CAP_PROP_FPS);

cv::Mat frame; //current video frame

//Delay between each frame in ms
//corresponds to video frame rate
int delay = 1000/rate;

long numOfFrames = static_cast<long>(capture.get(CV_CAP_PROP_FRAME_COUNT));

Log(@"Video Frame rate:%f, delay:%d, numOfFrames:%ld", rate, delay, numOfFrames);

double position = 100.0;
capture.set(CV_CAP_PROP_POS_FRAMES, position);

long frameNum = static_cast<long>(capture.get(CV_CAP_PROP_POS_MSEC));

Log(@"Moved to Frame 100. Getting frame number:%ld", frameNum);
+3
source share

All Articles