2014-03-28 53 views

回答

1

我會建議使用ffmpeg。您可以通過編程或使用命令行來完成。在命令行上執行此操作的一個示例是:

ffmpeg -start_number n -i image%d.jpg -vcodec mpeg4 test.avi 

其中n是第一個圖像編號。

+0

我想以編程方式做到這一點開放簡歷不是命令行 – kadu

+0

我從來沒有使用OpenCV進行的是,只有圖像處理。我不知道這是否可能。 –

0

Tutorial how to do Videooutput

你會被要求爲您要使用的編解碼器。這有點複雜,但是SO上已經有很多與編解碼相關的問題。

此代碼應該工作(未測試):

#include <iostream> // for standard I/O 
#include <string> // for strings 
#include <vector> 
#include <opencv2/core/core.hpp>  // Basic OpenCV structures (cv::Mat) 
#include <opencv2/highgui/highgui.hpp> // Video write 

using namespace std; 
using namespace cv; 

int main(int argc, char *argv[], char *window_name){ 
    vector<Mat> images; //fill this somehow 
    Size S = vector[0].getSize();  

    VideoWriter outputVideo; // Open the output 
    outputVideo.open(NAME , ex=-1, 30), S, true); //30 for 30 fps 

    if (!outputVideo.isOpened()){ 
     cout << "Could not open the output video for write: "<< endl; 
     return -1; 
    } 

    for(int i=0; i<images.size(); i++){ 
     outputVideo << res; 
    } 

    cout << "Finished writing" << endl; 
    return 0; 
} 
+0

我應該加載屬性中的命令參數中的所有圖像? – kadu

+0

這是由你來填充你的圖片到矢量中。你可以用命令行參數來完成它,或者對它進行硬編碼,或者以其他方式進行... –