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;
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);
source
share