VideoWriter

#include 
#include "highgui.h"
#include 
using namespace std;
using namespace cv;
int main()
{
    Mat frame;
    string filename = "D:\Camera Road 01.avi";
    VideoCapture cap(filename);
    VideoWriter out;
    out.open("D:\\out.avi", CV_FOURCC('X', 'V', 'I', 'D'),cap.get(CV_CAP_PROP_FPS),Size(cap.get(CV_CAP_PROP_FRAME_WIDTH),cap.get(CV_CAP_PROP_FRAME_HEIGHT)));
    if (!cap.isOpened())
    {
        cout << "Video load failed!" << endl;
        return -1;
    }
    while (1)
    {
        cap >> frame;
        if (frame.empty())
        {
            cout << "Video process finished!" << endl;
            return 0;
        }
        imshow("video", frame);
        if (waitKey(10) == 'q') break;
        out << frame;
    }
    cap.release();
    out.release();
    return 0;
}

 

你可能感兴趣的:(opencv)