我正在编写从套接字读取 h264 数据的代码,将其传递给 h264dec.exe(openh264 解码器),然后将 YUV 数据传递给 YUV-RGB 解码器。我的问题是 openh264dec 的工作方式类似于“h264dec video.h264 out.yuv”。
而且我真的不知道如何处理代码中的参数以将它们作为流服务。出于培训目的,我尝试过h264dec video.h264 \\.\pipe\h264input
但它不起作用,代码如下:
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();
过程是:
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;
}
YUV 解码器将 Stream 对象的宽度和高度作为输入。程序挂起WaitForConnection()
并且没有该功能,YUV
解码器在从流中读取时抛出异常。
甚至有可能让它像这样工作吗?用管道代替参数?