int _tmain(int argc, _TCHAR* argv[])
{
VideoCapture vc("");
VideoWriter vw;
vw.open( ".//output.avi", // 輸出視頻文件名
(int)vc.get( CV_CAP_PROP_FOURCC ), // 也可設(shè)為CV_FOURCC_PROMPT,在運(yùn)行時選取
(double)vc.get( CV_CAP_PROP_FPS ), // 視頻幀率
cv::Size( (int)vc.get( CV_CAP_PROP_FRAME_WIDTH ), (int)vc.get( CV_CAP_PROP_FRAME_HEIGHT ) ), // 視頻大小
true ); // 是否輸出彩色視頻
Mat frame;
if (!vc.isOpened())
{
cout<<"can not find file"<<endl;
return -1;
}
vc>>frame;
int fnum=1;
Mat gray;
while (!frame.empty())
{
cvtColor(frame, gray, CV_BGR2GRAY);
vw<<frame;
fnum++;
vc>>frame;
if (waitKey(1)>0)
{
break;
}
}
return 0;
}