ffmepgを使用してメディア ファイル変換用の .NET ラッパーを作成しようとしています。
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 をご覧ください。