[opencv] 读写视频, 将连续图片转换为视频

VideoWriter put("output.mpg", CV_FOURCC('M','P','E','G'), 30, S);
        if(!put.isOpened())
        {
                cout << "File could not be created for writing. Check permissions" << endl;
                return -1;
        }

这里 的 S 是size ,视频尺寸, 用 frame.size()即可. 

30 是FPS, 一般都用30帧了, 当然也有60的


下面的代码应该在一个while里面 ,  条件自己添加把~

这里的意思是只要不是空帧,  就把它写入.

存好的视频就在工程文件夹的debug里面


                // Check if the video is over
                if(frame.empty())
                {
                        cout << "Video over" << endl;
                        break;
                }

                put << frame;


原文地址:https://www.cnblogs.com/Pomodori/p/4356937.html