2010-05-18 204 views
2
 string inputpath = strFileNamePath; 
     string outputpath = "C:\\Image\\"; 
     //for (int iIndex = 0; iIndex < 1000; iIndex++) 
     //{ 
      //string fileargs = "-i" + " " + inputpath + " -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv " + outputpath + "SRT.flv"; 
      string fileargs = "-i" + " " + inputpath + " " + outputpath + "image.jpg"; 
      System.Diagnostics.Process p = new System.Diagnostics.Process(); 
      p.StartInfo.FileName = "C:\\Documents and Settings\\Badr\\My Documents\\Visual Studio 2008\\Projects\\Video2image2video.\\ffmpeg\\ffmpeg.exe"; 
      p.StartInfo.Arguments = fileargs; 
      p.StartInfo.UseShellExecute = false; 
      p.StartInfo.CreateNoWindow = true; 
      p.StartInfo.RedirectStandardOutput = true; 
      p.Start(); 

我有這樣的代碼這個創建僅1視頻的圖像我申請一個循環,但我反覆生成初始圖像我怎麼可以得到所有的視頻如何將視頻轉換爲在c#中使用ffmpeg的圖像文件?

感謝名單的圖片提前

+1

請儘量避免硬編碼路徑,C:\\文件等是令人震驚。使用System.IO.Path.GetDirectoryName(_ System.Reflection.Assembly.GetExecutingAssembly()。GetName()。CodeBase)'要獲取exe所在的路徑 – RvdK 2010-05-18 13:51:20

回答

0

documentation of ffmpeg

您可以從視頻中提取圖片, 或多幅圖像創建一個視頻:

爲電子商務從視頻圖像xtracting:

的ffmpeg -i foo.avi -r 1 -s寬x -f IMAGE2 foo-%03d.jpeg

這將從視頻中提取每 第二一個視頻幀和將輸出 他們在文件名爲foo-001.jpeg', foo-002.jpeg'等圖像將 重新調整,以適應新的WxH值。

所以,只要改變你傳遞給ffmpeg的參數,你應該啓動並運行。

0

嗨,你想在視頻文件中的圖像,當你以這種方式返回;

for (int i = 0; i < iImageCount; i++) 
           { 

            string sInputVideo = Page.MapPath(...); 

            string sImageCapture = Page.MapPath("") + "\\Videolar\\" + ImageName+ "_" + iResim + ".jpg"; 

            ffmpeg.StartInfo.Arguments = " -i \"" + sInputVideo + "\" -s 108*100 -ss " + iImageCapture + " -vframes 1 -f image2 -vcodec mjpeg \"" + sImageCapture + "\""; 
            ffmpeg.StartInfo.FileName = (Server.MapPath("Referanslar/ffmpeg.exe")); 
            ffmpeg.Start(); 
            ffmpeg.WaitForExit(); 
            ffmpeg.Close(); 
            iImageCapture += 1; 
            iResim++; 
           } 

爲你改變它願意的話可以拍照;)

相關問題