我正在生成一个 MJpeg 流并尝试将其流式传输到 VLC 并在那里播放。
编码:
public void SendMultiPartData(String contentType, Func<byte[]> getData)
{
MemoryStream mem = null;
response.StatusCode = 200;
for ( byte[] buffer = getData(); buffer != null && buffer.Length > 0; buffer = getData())
{
response.ContentType = "multipart/x-mixed-replace; boundary=--testboundary";
ASCIIEncoding ae = new ASCIIEncoding();
byte[] boundary = ae.GetBytes("\r\n--testboundary\r\nContent-Type: " + contentType + "\r\nContent-Length:" + buffer.Length + "\r\n\r\n");
mem = new MemoryStream(boundary);
mem.WriteTo(response.OutputStream);
mem = new MemoryStream(buffer);
mem.WriteTo(response.OutputStream);
response.OutputStream.Flush();
}
mem.Close();
listener.Close();
}
如果我尝试使用 Firefox 打开流,则完全没有问题,尽管使用 VLC 它不起作用(VLC 似乎继续阅读但从不显示视频)
我一直在嗅探 VLC-to-VLC 流,它们似乎用作 HTTP 标头“application/octet-stream”而不是 multipart/x-mixed-replace
有任何想法吗 ?
提前谢谢,何塞