Ask Your Question

Revision history [back]

why video is not playing only one frame showing

//PlayVideoFilecpp.sIn //main.cpp

include<opencv2\core\core.hpp>

include<opencv2\highgui\highgui.hpp>

include<opencv2\imgproc\imgproc.hpp>

include<iostream>

include<conio.h> //it may be necessary to change or remove this line if not using windos

////////////////// int main(void) { cv::VideoCapture capVideo; cv::Mat imgFrame; capVideo.open("768x576.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);

}

code is working okay but it only show frame why not playing whole video ?

why video is not playing only one frame showing

//PlayVideoFilecpp.sIn //PlayVideoFilecpp.sIn

//main.cpp

include<opencv2\core\core.hpp>

include<opencv2\highgui\highgui.hpp>

include<opencv2\imgproc\imgproc.hpp>

include<iostream>

include<conio.h> //it may be necessary to change or remove this line if not using windos

////////////////// //////////////////

int main(void) { {

cv::VideoCapture capVideo;
  cv::Mat imgFrame;
  capVideo.open("768x576.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);

}

    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);

}

code is working okay but it only show frame why not playing whole video ?

click to hide/show revision 3
None

updated 2018-06-07 00:11:18 -0600

berak gravatar image

why video is not playing only one frame showing

//PlayVideoFilecpp.sIn

//main.cpp

include<opencv2\core\core.hpp>

include<opencv2\highgui\highgui.hpp>

include<opencv2\imgproc\imgproc.hpp>

include<iostream>

include<conio.h>
//main.cpp

#include<opencv2\core\core.hpp>

#include<opencv2\highgui\highgui.hpp>

#include<opencv2\imgproc\imgproc.hpp>

#include<iostream>

#include<conio.h>  //it may be necessary to change or remove this line if not using windos

//////////////////

windos ////////////////// int main(void) {

{
cv::VideoCapture capVideo;
 cv::Mat imgFrame;
 capVideo.open("768x576.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);
}

}

code is working okay but it only show frame why not playing whole video ?