2010-05-18 203 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++; 
           } 

为你改变它愿意的话可以拍照;)

相关问题