Hi
I am practicing VideoCapture
and VideoWriter
. I am now following
http://stackoverflow.com/questions/13623394/how-to-write-video-file-in-opencv-2-4-3
Which is supposed to be a brief answer.
However, when I am doing it It got.
$ ./simpleRec.out 0 a.avi
HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(5) - Invalid argument
HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(6) - Invalid argument
!!! Output video could not be opened
Here is my code :
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <iomanip>
#include <string>
#include <stdio.h>
using namespace std;
using namespace cv;
int main (int argc, const char** argv){
// Load input video
cv::VideoCapture input_cap(atoi( (argv[1]) ) );
if (!input_cap.isOpened())
{
std::cout << "!!! Input video could not be opened" << std::endl;
return -1;
}
// Setup output video
cv::VideoWriter output_cap(argv[2],
input_cap.get(CV_CAP_PROP_FOURCC),
input_cap.get(CV_CAP_PROP_FPS),
cv::Size(input_cap.get(CV_CAP_PROP_FRAME_WIDTH),
input_cap.get(CV_CAP_PROP_FRAME_HEIGHT)),
true);
if (!output_cap.isOpened())
{
std::cout << "!!! Output video could not be opened" << std::endl;
return 0;
}
// Loop to read from input and write to output
cv::Mat frame;
while (true)
{
if (!input_cap.read(frame))
break;
output_cap.write(frame);
}
input_cap.release();
output_cap.release();
}
Question :
1. What is wrong in my code?
2. How do I solve it?