1
我想從兩個圖像創建1fps WEBM, 代碼:opencv的VideoWriter只保存一個幀
// 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
你爲什麼討厭字符串? :D – Miki
爲什麼你需要'usleep(...)'?你已經在構造函數中設置了fps。嘗試'outputVideo.write(temp.clone());'只是爲了確保... – Miki
usleep也是肯定的。克隆不起作用。 – notgiorgi