Mjpeg流媒体无法在谷歌chrome上运行
本文关键字:chrome 运行 谷歌 流媒体 Mjpeg | 更新日期: 2023-09-27 18:29:51
我是mjpeg流媒体的新手。我正在尝试构建一个mjpeg流媒体服务器应用程序,将mjpeg视频流式传输到运行firefox或googlechrome的客户端。目前,流媒体在firefox上运行良好,但拒绝在谷歌chrome上运行。有人知道为什么会这样吗?(我已经下载了最新版本的googlechrome和firefoxforwindows)以下是我的C#类中的代码片段,它将http头和图像流(内存流)写入网络流:
/* Write the HTTP header to the network stream */
public void WriteHeader()
{
Write("HTTP/1.1 200 OK'r'n" +
"Content-Type: multipart/x-mixed-replace; boundary=" +
this.Boundary +
"'r'n"
);
this.Stream.Flush();
}
/* To write text to the stream */
private void Write(string text)
{
byte[] data = BytesOf(text);
this.Stream.Write(data, 0, data.Length);
}
/* Write header followed by the provided memory stream*/
public void Write(MemoryStream imageStream)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine();
sb.AppendLine(this.Boundary);
sb.AppendLine("Content-Type: image/jpeg");
sb.AppendLine("Content-Length: " + imageStream.Length.ToString());
sb.AppendLine();
Write(sb.ToString());
imageStream.WriteTo(this.Stream);
Write("'r'n");
this.Stream.Flush();
}
/* To get bytes from the from the specified string */
private static byte[] BytesOf(string text)
{
return Encoding.ASCII.GetBytes(text);
}
下面是进行适当方法调用以将标头和图像数据写入网络流的代码片段:
/* Sends data to the specified client */
private void SendData(Socket client)
{
MjpegWriter jw = new MjpegWriter(new NetworkStream(client, true));
jw.WriteHeader();
foreach (var memstream in this.ProcessImages())
{
Thread.Sleep(50);
jw.Write(memstream);
}
}
我也有同样的问题(Chrome 29中的错误)。我发现,如果你把你的运动jpeg流嵌入到一个html文件中,例如:
<html><body>
<img src="http://192.168.1.77:8081">
</body></html>
您现在可以在Chrome 29中查看流。
我认为这是最新版本Chrome的一个错误。我可以在Chrome v28上很好地使用mjpg_streamer,但v29在一个空白屏幕上停止了。运行oldchrome.exe,它有时留在程序文件''谷歌''铬''应用程序下,运动jpeg再次开始工作。我给谷歌发了一个bug通知,但不确定会持续多久。
我发现Chromium Blog:的Chrome 29不支持x-mixed-replace
我们已经删除了对multipart/x-mixed-replace-main资源的支持。我们将继续支持多部分图像和动画图像。
奇怪