Change FPS on video capture from file

asked 2016-12-07 13:16:23 -0600

megab gravatar image

updated 2020-11-16 11:10:51 -0600

I'm reading a video file, and it's slower than the actual FPS of the file (59 FPS @1080p) even if i'm not doing any processing to the image:

       using namespace cv;
       using namespace std;
       // Global variables
        UMat frame; //current frame
        int main(int argc, char** argv)
        {

                VideoCapture capture("myFile.MP4");
                namedWindow("Frame");
                capture.set(CAP_PROP_FPS, 120); //not changing anything
                cout>>capture.get(CAP_PROP_FPS);
                while (charCheckForEscKey != 27) {

                       capture >>frame;
                if (frame.empty())
                    break;
                imshow("Frame", frame);

                }

    }

Even if I tried to set CAP_PROP_FPS to 120 it doesn't change the fps of the file and when I get(CAP_PROP_FPS) I still get 59.9...

When I read the video the actual outcome is more or less 54 FPS (even using UMat).

Is there a way to read the file at a higher FPS rate ?

Thanks in advance

edit retag flag offensive close merge delete

Comments

I'm running into this problem too. I want to be able to update the fps as a new fps is generated per frame This is because the camera input fps is not constant, and depending on the processing power available at the time, the writing speed must match the input rate as best as possible live time.

I don't see why VideoWriter.set(cv2.CAP_PROP_FPS, newRate) is not working

ddaaggeett gravatar imageddaaggeett ( 2017-09-27 14:13:12 -0600 )edit

I read somewhere that if opencv is not compiled with ffmepg, then it uses some default video capture device (like gstreamer) which doesn't allow changing a framerate.

miks gravatar imagemiks ( 2019-03-03 11:58:49 -0600 )edit