我正在尝试从两张图片创建1fps webm, 代码:
// path to output
string outputVideoPath = "/home/gio/Desktop/giffer/def.webm";
// write dimensions in size struct
Size dims = Size(640,480);
// create and open VideoWriter object
VideoWriter outputVideo;
outputVideo.open(outputVideoPath, CV_FOURCC('V','P','8', '0'), 1, dims, true);
// check if opened
if(!outputVideo.isOpened()){
cout << "Creating outputVideo fail" << endl;
return -1;
}
// I hate strings
string paths[2];
paths[0] = "/home/gio/Desktop/giffer/images_temp/g0.jpg";
paths[1] = "/home/gio/Desktop/giffer/images_temp/g1.jpg";
for (int i = 0; i < 2; i++) {
cout << paths[i] << endl;
Mat temp = imread(paths[i]);
outputVideo.write(temp);
usleep(10000);
}
结果是唯一的帧(最后一张图像),1秒长。 我做错了什么?
修改
我尝试使用.avi
扩展名DIVX
编解码器,但它确实有效。有关如何使其在.webm
上运行的任何想法?或.gif