Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

videwriter not working after image resize

i am using opencv 3 & visual studio. issue here is that i am unable to save video for any particular resolution other than default full camera resolution there is no error, only thing is video file doesn't grow. it stays at 5.54kb. here is my code

#include"opencv2\opencv.hpp"
using namespace cv;
using namespace std;

VideoCapture cap_cam1(0);

double Width = cap_cam1.get(CV_CAP_PROP_FRAME_WIDTH);
double Height = cap_cam1.get(CV_CAP_PROP_FRAME_HEIGHT); 
cv::Size frameSize(static_cast<int>(Width), static_cast<int>(Height));
string videoFileName = "D://current.avi";
VideoWriter cam1_write(videoFileName, CV_FOURCC('D', 'I', 'V', '3'), 10.0, frameSize, true);
Mat image;
int main()
{
    while (true)
    {
        cap_cam1 >> image;
        resize(image, image, Size(320, 240));
        imshow("image", image);
        cam1_write.write(image);
        if (waitKey(33) == 27)break;
    }

}

if i comment remove resize function, then file size grows and frames are added i also tried adding below lines after videowriter definition

cap_cam1.set(CV_CAP_PROP_FRAME_WIDTH, 240);
cap_cam1.set(CAP_PROP_FRAME_HEIGHT,320);

also tried changing resolution at videowriter definition, after everything file size remains at 5.54kb.

how to record video at custom resolution? Thanks