This is a simple code to read Video from File
My problem is that Why when trying to read a Video, the video is very very slower?? I'm trying to read a Video recorded with My Phone thee video file format is mp4;
How Can I solve this problem?? to convert that video in an other Video Format?? which one?? int main() {
///Video Lecture
const string sourceReference = "K:/OpenCv/DataSetCar/WP.mp4";
// Open the video file
cv::VideoCapture capture(sourceReference);
// check if video successfully opened
if (!capture.isOpened())
return 1;
// Get the frame rate
double rate= capture.get(CV_CAP_PROP_FPS);
bool stop(false);
cv::Mat frame; // current video frame
cv::namedWindow("Extracted Frame",WINDOW_AUTOSIZE);
// Delay between each frame in ms
// corresponds to video frame rate
int delay= 1000/rate;
// for all frames in video
while (!stop) {
// read next frame if any
if (!capture.read(frame))
break;
cv::imshow("Extracted Frame",frame);
// introduce a delay
// or press key to stop
if (cv::waitKey(delay)>=0)
stop= true;
}
// Close the video file.
// Not required since called by destructor
capture.release();
return 0;
}