I wrote a little GUI wrapper which will execute openRTSP using the Process class. The issue I am having is redirecting the output to a mpeg4 video file. I verified the parameters I am passing are correct by running openRTSP on the command line.
openRTSP.exe -some -parameters -for -video -4 rtsp://video.from.server > video.mp4
The "> video.mp4" is what I am having trouble reproducing.
I have looked at other examples of of using the Process class but they appear to work only with ASCII text.
Edit--- Here is some more detail
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);
}
}
When using WriteLine to write the data received, when my application quits the file size is the same as when I run openRTSP from the command line which produces "correct" output, namely a mpeg4 video which is playable. When running from command line openRTSP is outputing an mpeg4 file which I am redirecting to a mpeg4.
I tried adding "> fileNameToUse" to the end of the string assigned to startInfo.Arguments but that made openRTSP fail right away.
Thanks, Matt