Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

HIGHGUI ERROR: V4L2: Unable to get property

$
0
0
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 (5) - Invalid argument HIGHGUI ERROR: V4L2: Unable to get property (6) - Invalid argument !!! Output video could not be opened Here is my code :
#include #include #include #include #include #include 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 //double fps = input_cap.get(CV_CAP_PROP_FPS); int width = input_cap.get(CV_CAP_PROP_FRAME_WIDTH); int height = input_cap.get(CV_CAP_PROP_FRAME_HEIGHT); cv::VideoWriter output_cap(argv[2], CV_FOURCC('M','J','P','G'), 20, cv::Size(width,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(); }
**Update :**
I found it is a bug in issue. `http://code.opencv.org/issues/1895` it is fps is `-1`
I had tried 10,20,30 but it still does not work with reply `!!! Output video could not be opened`
I changed `VideoWriter` initialization a bit. From
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);
to
//double fps = input_cap.get(CV_CAP_PROP_FPS); int width = input_cap.get(CV_CAP_PROP_FRAME_WIDTH); int height = input_cap.get(CV_CAP_PROP_FRAME_HEIGHT); cv::VideoWriter output_cap(argv[2], CV_FOURCC('M','J','P','G'), 20, cv::Size(width,height), true);
I have to comment `fps` out otherwise it will thrown an error `HIGHGUI ERROR: V4L2: Unable to get property `
**Question :**
1. What is wrong in my code?
2. How do I solve it?


Viewing all articles
Browse latest Browse all 41027

Trending Articles