Reputation: 1785
Running Windows 7, x64 with OpenCV 2.4.8 (pre-built binaries).
Trying the following basic code:
VideoWriter wrt;
wrt.open("video.mp4", -1, 29, Size(480, 640));
This does nothing. The expected popup for codec selection does not open, nor is the writer getting open (i.e. a call to wrt.isOpen()
returns false). Also, the internal pointer inside the writer class wrt.writer
remains null.
Tried:
opencv_ffmpeg248.dll
to the executable's directory according to this.CV_FOURCC('M','P','4','2')
and others.Nothing worked. Any help/direction would be appreciated..
Upvotes: 0
Views: 14801
Reputation: 380
VideoCapture cap;
VideoWriter videoWriter;
cap.open(0);
if (!cap.isOpened())
{
printf("can not open camera or video file\n");
return ;
}
string namemove("foo.AVI");
int fourCC = CV_FOURCC('M', 'J', 'P', 'G');
Size S = Size((int)cap.get(CAP_PROP_FRAME_WIDTH), (int)cap.get(CAP_PROP_FRAME_HEIGHT));
int fps = cap.get(CAP_PROP_FPS);
videoWriter.open(namemove, -1, cap.get(CAP_PROP_FPS), S, true);
if (!videoWriter.isOpened())
{
cerr << "Cannot open output file " << endl;
return ;
}
Mat img0;
namedWindow("image", WINDOW_NORMAL);
for (;;)
{
cap >> img0;
if (img0.empty())
break;
videoWriter << img0;
imshow("image", img0);
char k = (char)waitKey(30);
if (k == 27) break;
}
Upvotes: 1
Reputation: 2008
Try
VideoWriter wrt;
wrt.open("video.avi", -1, 29, Size(480, 640));
Upvotes: 2