我正在生成一個MJpeg流並嘗試將它流式傳輸到VLC並在那裏播放。Mjpeg VLC和HTTP流
代碼:
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標頭「應用程序/八位字節流」,而不是多/使用X - 混合取代
任何想法?
韓國社交協會提前, 何塞