Mjpeg VLC和HTTP Streaming

我正在生成一个MJpeg Stream并尝试将其流式传输到VLC并在那里播放。

代码:

public void SendMultiPartData(String contentType, Func 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似乎继续阅读但从未显示video)

我一直在嗅探VLC到VLC流,它们似乎用作HTTP头“application / octet-stream”而不是multipart / x-mixed-replace

有任何想法吗 ?

提前说,何塞

何塞,我有同样的问题。 Firefox播放我的流,但VLC没有。 我经历了很多方法来解决这个问题,包括调试VLC源代码,并没有在哪里。 顺便说一句我的(REST)URL看起来像http:// server:port / livevideo / xyz然后,我想我应该尝试http:// server:port / livevideo / xyz.mjpeg猜猜看,VLC开始播放video! 我认为VLC可能需要一些提示而不是内容类型,以确定它是一个mjpeg流。 希望这可以帮助。

辛迪

你试过这个:

 Response.Buffer = false; Response.BufferOutput = false; 

还是那些变化?

我无法让firefox播放我的流(虽然chrome可以播放它)。 对于VLC,我将缓冲区设置为0毫秒(在高级打开选项下)并且它似乎可以在那里工作,尽管我的数据速率正在消除它。