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