Video frame rate always 90k [closed]
I'm trying to get the frame rate of a captured video but it's always returning 90000
but surely this can't be correct, is there any problem with my code that may be causing this value to be returned?
VideoCapture cap("/home/colin/downloads/20140203_133838.mp4"); // open the video file for reading
if ( !cap.isOpened() ) {
cout << "Cannot open the video file" << endl;
return 1;
}
double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
cout << "Frame per seconds : " << fps << endl;
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
while(1) {
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video
if (!bSuccess) {
cout << "Cannot read the frame from video file" << endl;
break;
}
imshow("MyVideo", frame); //show the frame in "MyVideo" window
if(waitKey(30) == 27) { //if escape key is pressed exit program
cout << "esc key is pressed by user" << endl;
break;
}
}
Hmm is this video a cut from a larger video? I have seen those programs for cutting up videos messing up the video headers in past projects, which resulted in a wrong measurement. What I do is calculate the time with C++ functions around a single frame and use that value (in range of milliseconds) to calulcate the FPS myself.
Nope this is the full video.
Then try the approach I suggested. It is possible the encoding of the video isn't working with opencv.