Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

VideoCapture is very slower when opening videoFile why??

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;

}

VideoCapture is very slower when opening videoFile why??

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?? one??

I want openCv to read my video File with the normal speed as when I'm reading the Video File in a Video Media player 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;

}

VideoCapture is very slower when opening videoFile why??

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??

I want openCv to read my video File with the normal speed as when I'm reading the Video File in a Video Media player player

simple url for the video link: from Youtube 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;

}