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.
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.
int fps = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
int delay = 1000 / fps;
while (true) {
clock_t startTime = clock();
capture.read(frame);
process();
imshow("video", frame);
while (clock() - startTime < delay) {
waitKey(1);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.