我需要提供实时图表,我想通过http传递一个mjpeg流(这样很容易通过使用普通标签将图形包含在网页中) .
是否可以实时从多个jpeg图像创建mjpeg流?
我的策略是:
- 输出正确的http标头:
Cache-Control:no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0
Connection:close
Content-Type:multipart/x-mixed-replace;boundary=boundarydonotcross
Expires:Mon, 3 Jan 2000 12:34:56 GMT
Pragma:no-cache
Server:MJPG-Streamer/0.2
(从 curl -I {on a mjpeg-streamer instance}
得到它,但这看起来很奇怪)
-
简单地生成连续的jpeg图像二进制文件,注意:
-
在流的开头添加正确的标头(如mjpeg-streamer那样):
Content-Type: image/jpeg
Content-Length: 5427
X-Timestamp: 3927662.086099
- 在每个jpeg流的末尾附加边界字符串 .
--boudary--
Questions:
你做到了吗
你知道一个python模块吗?
你觉得它会起作用吗
你有什么建议吗?
2 回答
我把它作为一个概念验证:https://github.com/damiencorpataux/pymjpeg
对于记忆:
您可以使用Flask框架来执行此操作 .
它不仅适用于mjpeg .
我从这里改编了一些代码:https://blog.miguelgrinberg.com/post/video-streaming-with-flask
APP.py
base_camera.py
camera.py