Video frame rate always 90k [closed]

asked 2014-02-03 08:03:24 -0500

colin747 gravatar image

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 =; // read a new frame from video
    if (!bSuccess) {
      cout << "Cannot read the frame from video file" << endl;
    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; 
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-11-13 04:05:35.481930


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.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-05 04:41:27 -0500 )edit

Nope this is the full video.

colin747 gravatar imagecolin747 ( 2014-02-05 09:35:17 -0500 )edit

Then try the approach I suggested. It is possible the encoding of the video isn't working with opencv.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-06 03:24:17 -0500 )edit