MJPEG VLC和HTTP流 [英] Mjpeg VLC and HTTP Streaming
问题描述
我产生一个MJPEG流,并试图将其传输到VLC和发挥它有
I'm generating a MJpeg Stream and trying to stream it to VLC and play it there.
中的代码:
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似乎坚持读书,但从来没有显示视频)
If I try to open the stream with firefox, there's no problem at all, although with VLC it doesn't work (VLC seems to keep reading but never shows the video)
我一直嗅探VLC到VLC流,他们似乎使用如HTTP头应用程序/八位字节流,而不是多重/ X - 混合替换
I've been sniffing VLC-to-VLC streaming and they seems to use as HTTP header "application/octet-stream" instead of multipart/x-mixed-replace
任何想法?
韩国社交协会提前,
何塞
Tks in advance, Jose
推荐答案
圣何塞,
我有完全相同的问题。火狐扮演我的流,但VLC犯规。我去了直通这么多的方法算出这个包括VLC调试源代码,并得到任何地方。
顺便说一句我(REST)URL看起来像的http://服务器:端口/实时视频/ XYZ
之后,我想我应该尝试的http://服务器:端口/实时视频/ xyz.mjpeg
你猜怎么着,VLC开始播放视频!
我想VLC可能需要一点点提示大于内容类型更要弄清楚它是一个MJPEG流。
希望这有助于。
Jose, I had exactly same problem. Firefox plays my stream but VLC doesnt. I went thru so many ways to figure this out including debugging VLC source code, and got no where. btw My (REST) URL looks like http://server:port/livevideo/xyz Then, I thought I should try http://server:port/livevideo/xyz.mjpeg And guess what, VLC started to play video! I think VLC might need a little hint more than content type to figure out it is a mjpeg stream. Hope this helps.
辛迪
这篇关于MJPEG VLC和HTTP流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!