C# Mjpeg VLC和HTTP流媒体

C# Mjpeg VLC和HTTP流媒体,c#,http,streaming,vlc,mjpeg,C#,Http,Streaming,Vlc,Mjpeg,我正在生成一个MJpeg流,并尝试将其流到VLC并在那里播放 守则: public void SendMultiPartData(String contentType, Func<byte[]> getData) { MemoryStream mem = null; response.StatusCode = 200; for ( byte[] buffer = getData(); buffer != null

我正在生成一个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();
    }
public void SendMultiPartData(字符串contentType,Func getData)
{
MemoryStream mem=null;
response.StatusCode=200;
对于(字节[]buffer=getData();buffer!=null&&buffer.Length>0;buffer=getData())
{
response.ContentType=“multipart/x-mixed-replace;boundary=--testboundary”;
ascienceoding ae=新的ascienceoding();
byte[]boundary=ae.GetBytes(“\r\n--testboundary\r\n内容类型:“+contentType+”\r\n内容长度:“+buffer.Length+”\r\n\r\n”);
mem=新的内存流(边界);
mem.WriteTo(response.OutputStream);
mem=新的内存流(缓冲区);
mem.WriteTo(response.OutputStream);
response.OutputStream.Flush();
}
mem.Close();
listener.Close();
}
如果我尝试用firefox打开流,根本没有问题,尽管用VLC它不起作用(VLC似乎一直在读,但从来没有显示视频)

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

有什么想法吗

事先, 何塞

你试过这个吗:

Response.Buffer = false;
Response.BufferOutput = false;
或者这些的一些变体?

Jose, 我也有同样的问题。Firefox播放我的流,但VLC不播放。我用了很多方法来解决这个问题,包括调试VLC源代码,但都没有找到答案。 顺便说一句,我的(REST)URL看起来像 然后,我想我应该试试 猜猜看,VLC开始播放视频了! 我认为VLC可能需要比内容类型更多的一点提示来确定它是一个mjpeg流。 希望这有帮助


辛迪

我无法让firefox播放我的流(尽管chrome可以播放)。对于VLC,我将缓冲区设置为0毫秒(在advanced open options下),它似乎从那里开始工作,尽管我的数据速率正在扼杀它