#include <opencv2/opencv.hpp>
using namespace cv;
#include <iostream>
using namespace std;
int main(int argc,char **argv)
{
 Mat Fram;
 VideoCapture VideoCap(0);
 Size CapSize = Size(VideoCap.get(CV_CAP_PROP_FRAME_WIDTH), VideoCap.get(CV_CAP_PROP_FRAME_HEIGHT));
 string File_AVI_NAME;
 if (argc != 1)
 {
  File_AVI_NAME = argv[argc - 1];
 }
 else
   File_AVI_NAME = "Test.avi";
 VideoWriter Write_AVI(File_AVI_NAME, -1, VideoCap.get(CV_CAP_PROP_FPS), CapSize, false);
 //VideoWriter Write_AVI("TEST.avi", -1, VideoCap.get(CV_CAP_PROP_FPS), CapSize, false);
 while (true)
 {
  if (NULL == VideoCap.read(Fram))
  {
   cout << "read fram error!" << endl;
   exit(1);
  }
  Write_AVI << Fram;
  imshow("Video", Fram);
 // waitKey(3);
  if (waitKey(100) == 27)
  {
   goto DONE;
   //exit(0);
  }
 }
//done the avi read
DONE: cout << "write done!" << endl;
 VideoCap.release();
 return 0;
}
05-11 15:41