我将生成一个MJpeg流,并尝试将其流式传输到VLC并在那里播放。
代码如下:
如果我尝试使用Firefox打开流,就没有任何问题,但是使用VLC则无法工作(VLC似乎一直在读取但从未显示视频)。
我一直在嗅探VLC到VLC的流,并且它们似乎使用HTTP头“application/octet-stream”而不是“multipart/x-mixed-replace”。
有什么想法吗?
提前感谢,Jose
代码如下:
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到VLC的流,并且它们似乎使用HTTP头“application/octet-stream”而不是“multipart/x-mixed-replace”。
有什么想法吗?
提前感谢,Jose