Processクラスを使用してopenRTSPを実行する小さなGUIラッパーを作成しました。私が抱えている問題は、出力をmpeg4ビデオファイルにリダイレクトすることです。コマンドラインでopenRTSPを実行することによって、私が渡しているパラメータが正しいことを確認しました。C#プロセスクラスはビデオファイルに出力をリダイレクト
openRTSP.exe - 一部-parameters -for - ビデオ-4 RTSP://video.from.server> video.mp4
"> video.mp4" 私は悩みの再生を持っていますものです。
Processクラスを使用する他の例を見てきましたが、ASCIIテキストのみで動作するようです。
編集は--- ここではいくつかの詳細です
this.outputStream = new StreamWriter(fileNameToUse, false, Encoding.Default);
try
{
byte[] buffer;
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = new Process())
{
// Assign start info to the process
exeProcess.StartInfo = startInfo;
// Set up the event handler to call back with each line of output
exeProcess.OutputDataReceived += new DataReceivedEventHandler(OnDataReceived);
// Start the Process
exeProcess.Start();
exeProcess.BeginOutputReadLine();
exeProcess.WaitForExit();
}
}
catch (Exception ex) { PrintException(ex); }
finally
{
this.outputStream.Flush();
this.outputStream.Close();
}
// Called asynchronously with a line of data
private void OnDataReceived(object Sender, DataReceivedEventArgs e)
{
lock (this)
{
if (!string.IsNullOrEmpty(e.Data) && (this.outputStream != null))
this.outputStream.WriteLine(e.Data);
}
}
データを書き込むWriteLineメソッドを使用して、受信した、私のアプリケーションは、ファイルサイズが、私はコマンドラインからopenRTSPを実行する場合と同じです終了したときにどの「正しい」出力、すなわち再生可能なmpeg4ビデオを生成する。コマンドラインから実行すると、openRTSPはmpeg4ファイルを出力しています。私はmpeg4にリダイレクトしています。
startInfo.Argumentsに割り当てられた文字列の最後に "> fileNameToUse"を追加しようとしましたが、すぐにopenRTSPが失敗しました。
おかげで、 マット
[MedallionShell](https://github.com/madelson/MedallionShell)ライブラリが興味深いかもしれません。これにより、プロセスストリームのリダイレクトが非常に簡単になります。 – ChaseMedallion