I am writing code that reads h264 data from socket, passes it to h264dec.exe (openh264 decoder) and then pases YUV data to YUV-RGB decoder. My issue is that openh264dec works like "h264dec video.h264 out.yuv".
And I don't really know how to handle arguments in code to serve them as streams.
For training purposes i've tried h264dec video.h264 \\.\pipe\h264input
but it doesn't work, the code is as below:
NamedPipeServerStream pipeServ = new NamedPipeServerStream(Utility.DecoderOutputPipeName, PipeDirection.InOut);
Openh264.Openh264 openh264 = new Openh264.Openh264();
openh264.Start();
pipeServ.WaitForConnection();
Openh264.YUVDecoder decoder = new Openh264.YUVDecoder(pipeServ, 640, 480);
decoder.NewFrame += Decoder_NewFrame;
decoder.Start();
The process is:
public Openh264()
{
string args;
//args = @" \\.\pipe\" + Utility.DecoderInputPipeName;
args = @"C:\test\vid.h264";
args += @" \\.\pipe\" + Utility.DecoderOutputPipeName;
openh264 = new Process();
openh264.StartInfo.CreateNoWindow = true;
openh264.StartInfo.UseShellExecute = false;
openh264.StartInfo.FileName = "h264dec.exe";
openh264.StartInfo.Arguments = args;
}
The YUV decoder takes as an input Stream object, width and height.
The program hangs on WaitForConnection()
and without that function, YUV
decoder throws an exception while reading from the stream.
Is it even possible to make it work like this? Substitute arguments with pipes?