我正在生成一个MJpeg Stream并尝试将其流式传输到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到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开始播放视频! 我认为VLC可能需要一些提示而不是内容类型,以确定它是一个mjpeg流。 希望这会有所帮助。

辛迪

其他提示

你试过这个:

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

或者那些变化?

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top