Unable to play a video in opencv3
Here is my new code.
int main(void) {
cv::VideoCapture capVideo;
cv::Mat imgFrame;
capVideo.open("C:\Users\sbv\Documents\MyVideo.avi");
if (!capVideo.isOpened()) {
std::cout << "\nerror reading video file" << std::endl << std::endl;
_getch();
return(0);
}
if (capVideo.get(CV_CAP_PROP_FRAME_COUNT) < 1) { std::cout << "\nerror: video file must have at least one frame"; _getch(); return(0); }
capVideo.read(imgFrame);
char chCheckForEscKey = 0;
while (capVideo.isOpened() && chCheckForEscKey != 27) {
cv::imshow("imgFrame", imgFrame);
if ((capVideo.get(CV_CAP_PROP_POS_FRAMES) + 1) < capVideo.get(CV_CAP_PROP_FRAME_COUNT))
{
capVideo.read(imgFrame);
}
else
{
std::cout << "end of video\n";
break;
}
chCheckForEscKey = cv::waitKey(1);
}
if (chCheckForEscKey != 27) {
cv::waitKey(0);
}
return(0);
}
error is coming as 'Error reading video file'. please solve this issue
make sure, that opencv_ffmpeg64.dll is on your PATH or next to your app