How to play any video with a fixed frame rate (fps) using OpenCV?

c++, computer-vision, opencv

Solution

Take a look at this article. It shows how to play back AVI files with OpenCV. Here, the frame rate is read using

int fps = ( int ) cvGetCaptureProperty( capture, CV_CAP_PROP_FPS );

and the delay is set via

key = cvWaitKey( 1000 / fps );

Hence, by controlling the `fps` variable, you can get the play back rate you want.

Problem

Is there any way or function in OpenCV that allows us to play any video with a fixed frame rate(fps)? Different videos may have different frame rates but by using OpenCV library can we play them by a fixed frame rate that we define? Thanks in advance.

Original source