我試圖創建使用ffmepg媒體文件轉換一個.NET包裝,這裏是我已經試過:從.NET程序與ffmpeg交互?
static void Main(string[] args)
{
if (File.Exists("sample.mp3")) File.Delete("sample.mp3");
string result;
using (Process p = new Process())
{
p.StartInfo.FileName = "ffmpeg";
p.StartInfo.Arguments = "-i sample.wma sample.mp3";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
//result is assigned with an empty string!
result = p.StandardOutput.ReadToEnd();
p.WaitForExit();
}
}
實際發生的是ffmpeg的節目的內容是打印出來的控制檯應用程序,但result
變量是一個空字符串。我想以交互方式控制轉換進度,因此用戶甚至不需要知道我正在使用ffmpeg,但他仍然知道轉換進度的細節以及應用程序達到的百分比等。
基本上,我也會很滿意P/Invoke轉換函數的.NET包裝器(我對整個外部庫不感興趣,除非我可以從中提取PI函數)。
任何有經驗的人ffmpeg & .NET?
更新 請查看我的另一個問題,how to write input to a running ffmpeg process。
沒有使用StringBuilder sb。 –
@aaaa bbbb:刪除,謝謝。它仍然從以前的嘗試,無論如何,我添加了一些重要的功能,我的答案。 **你能否看看[這](http://stackoverflow.com/questions/7296901)**? – Shimmy