2016-09-23 25 views
0

我一直在努力,現在其目的是在服務器上運行,開發時間長一個C#應用程序工作。它從一個數據庫獲取信息並用它製作一個視頻。我一直在使用這個porpuse庫(Aforge)。但現在看起來我必須使用FFMPEG將5個mp4合併爲一個。我的問題是:與FFMPEG /熔接機和C#

  1. 我必須從下載「執行」exe文件,使其工作?或者我可以簡單地使用像其他庫(如Aforge)的DLL?

  2. FFMPEG看起來很複雜,我。我一直試圖使用Splicer insted。有一個非常漂亮和乾淨的example,我很樂意使用。但我無法讓拼接器工作。我正在使用VS 13.如何獲得拼接器的工作?將dll添加到「調試文件夾」,然後添加引用?如果是的話哪個dll?

這是我的代碼到目前爲止。它不顯示任何錯誤,但它不會做任何事情(我加了參考和splicer.dll到我的項目)

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
using Splicer; 
using Splicer.Renderer; 
using Splicer.Timeline; 

namespace MergeVideos 
{ 
    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void Form1_Load(object sender, EventArgs e) 
     { 

      string firstVideoFilePath = @"C:\file1.avi"; 
      string secondVideoFilePath = @"C:\file2.avi"; 
      string outputVideoPath = @"C:\output.avi"; 

      using (ITimeline timeline = new DefaultTimeline()) 
      { 
       IGroup group = timeline.AddVideoGroup(32, 720, 576); 

       var firstVideoClip = group.AddTrack().AddVideo(firstVideoFilePath); 
       var secondVideoClip = group.AddTrack().AddVideo(secondVideoFilePath, firstVideoClip.Duration); 

       using (AviFileRenderer renderer = new AviFileRenderer(timeline, outputVideoPath)) 
       { 
        renderer.Render(); 
       } 
      } 

     } 
    } 
} 

提前感謝!

回答

0

所以我一直在這一點,我想張貼在我的問題,這是不完全流行的答案。

  1. 您不必執行EXE或添加任何dll引用獲得的ffmpeg去,您只需通過命令行執行的解壓的exe文件,就像這樣:

    var p = new System.Diagnostics.Process(); 
    p.StartInfo.FileName = "cmd.exe"; 
    p.StartInfo.Arguments = "/k ffmpeg -f concat -i mylist.txt -c copy output"; 
    p.StartInfo.RedirectStandardOutput = true; 
    p.StartInfo.UseShellExecute = false; 
    p.StartInfo.CreateNoWindow = true; 
    p.Start(); 
    
  2. FFMPEG並不複雜,你只需要閱讀文檔的一點點,看到一些例子。網絡中有很多信息和示例代碼。