YUV video file reading problem because of codec problem

asked 2016-07-09 14:27:01 -0500

Ganesh K gravatar image

updated 2016-07-09 14:31:53 -0500


I am reading YUV video file. I am using the code below. I got the error as Picture size 0x0 is invalid. Warning: Could not find codec parameters <../../modules/highgui/src/cap_ffmpeg_impl.hpp:548>

// VideoExample1.cpp : This file reads the video from file and displays it in the window //

include "stdafx.h"

include <opencv2 core.hpp="">

include <opencv2 imgcodecs.hpp="">

include <opencv2 highgui.hpp="">

include <opencv2 imgproc="" imgproc.hpp="">

include <iostream>

using namespace cv; using namespace std;

int main(int argc, char* argv[]) { VideoCapture cap("C:/videos/a.yuv"); // open the video file for reading

if ( !cap.isOpened() )  // if not success, exit program
     cout << "Cannot open the video file" << endl;
     return -1;

//cap.set(CV_CAP_PROP_POS_MSEC, 300); //start the video at 300ms

double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video

 cout << "Frame per seconds : " << fps << endl;

namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

    Mat frame;

    bool bSuccess = cap.read(frame); // read a new frame from video

    if (!bSuccess) //if not success, break loop
                    cout << "Cannot read the frame from video file" << endl;

    imshow("MyVideo", frame); //show the frame in "MyVideo" window

    if(waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
            cout << "esc key is pressed by user" << endl; 

return 0;


image description

edit retag flag offensive close merge delete