Ask Your Question
0

reading a video with opencv

asked 2013-02-12 07:30:50 -0600

engine gravatar image

Hi! I have a video engine2.avi that I want to read and show with openCV. here 's the code that I used:

  #include <opencv2/core/core.hpp>
  #include <opencv2/highgui/highgui.hpp>
  #include <iostream>

  using namespace cv;

  int main(int argc, char** argv)
{
string filename = "D:\\BMDvideos\\engine2.avi";
VideoCapture capture(filename);
Mat frame;

if( !capture.isOpened() )
    throw "Error when reading steam_avi";

namedWindow( "w", 1);
for( ; ; )
{
    capture >> frame;
  //  if(!frame)
   //     break;
    imshow("w", frame);
    waitKey(20); // waits to display frame
}
waitKey(0); }

this code doesn't work if I the file has the codec YUV 4:2:2 (UYVY)(I record the video using Direct-Show), but works when I use a video that grabbed whit openCV !! has anybody an Idea how this could work ? thanks in advance

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-02-12 08:05:44 -0600

This is known OpenCV issue. There are some problems with loading non-compressed video files using FFMPEG back-end.

edit flag offensive delete link more

Comments

thanks Alexander for your answer but in this page they didn't solve it, I'm use OpenCV 242 and my video is 1920x1080 with 25fps

engine gravatar imageengine ( 2013-02-12 08:17:18 -0600 )edit

Question Tools

Stats

Asked: 2013-02-12 07:30:50 -0600

Seen: 1,447 times

Last updated: Feb 12 '13