This is actually related to another question I had that was already answered. That question is here: Redirecting stdout of one process object to stdin of another
My
For anyone who wants to do something similar, here is the new version with KeeperOfTheSoul's advice applied:
Process tccatProcess = new Process();
tccatProcess.StartInfo.FileName = "tccat";
tccatProcess.StartInfo.Arguments = String.Format("-i {0} -T {1}", devNode, title);
tccatProcess.StartInfo.UseShellExecute = false;
tccatProcess.StartInfo.RedirectStandardOutput = true;
Process ffmpegProcess = new Process();
string bashSafePreviewTemplate = slasher.bashSlash(previewTempDir + "/test%03d.jpg");
ffmpegProcess.StartInfo.FileName = "ffmpeg";
ffmpegProcess.StartInfo.Arguments = String.Format("-i - -r 1 -t 1 -s {1}x{2} -ss {3} {0}",
bashSafePreviewTemplate, width, height, timePosition);
ffmpegProcess.StartInfo.UseShellExecute = false;
ffmpegProcess.StartInfo.RedirectStandardInput = true;
Console.WriteLine("tccat command: {0} {1}", tccatProcess.StartInfo.FileName, tccatProcess.StartInfo.Arguments);
Console.WriteLine("ffmpeg command: {0} {1}", ffmpegProcess.StartInfo.FileName, ffmpegProcess.StartInfo.Arguments);
//return true;
try{
tccatProcess.Start();
ffmpegProcess.Start();
BinaryReader tccatOutput = new BinaryReader(tccatProcess.StandardOutput.BaseStream);
BinaryWriter ffmpegInput = new BinaryWriter(ffmpegProcess.StandardInput.BaseStream);
int buffSize = 4096;
byte[] buff = new byte[buffSize];
while(!ffmpegProcess.HasExited)
{
ffmpegProcess.Refresh();
buff = tccatOutput.ReadBytes(buffSize);
ffmpegInput.Write(buff);
ffmpegInput.Flush();
}
tccatProcess.Kill();
tccatProcess.Close();
ffmpegProcess.Close();
}catch(Exception e){
//uninteresting log code
return false;
}