python - 捕获视频流烧瓶
问题描述
我从覆盆子相机创建了一个简单的实时视频流。看起来像这样
服务器.py
from flask import Flask
from flask import render_template
from flask import Response
import cv2
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/video_feed')
def video_feed():
return Response(gen(), mimetype='multipart/x-mixed-replace; boundary=frame')
def gen():
camera = cv2.VideoCapture(0)
while True:
ret, img = camera.read()
if ret:
frame = cv2.imencode('.jpg', img)[1].tobytes()
yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
else:
break
app.run(host='192.168.0.241', port=7070, debug=True)
索引.html
<html>
<head>
<title>PiCamera stream</title>
</head>
<body>
<h1>Streaming</h1>
<img src="{{ url_for('video_feed') }}">
</body>
</html>
一切正常,我http://<raspberry_ip>:<port>
在浏览器中输入,我可以看到视频。
现在我需要创建用于观看此视频的移动应用程序,但是我正在努力做到这一点。有没有办法在 iOS 应用程序中捕获视频流?
解决方案
您的视频正在播放
http://<raspberry_ip>:<port>/video_feed
推荐阅读
- python - Linux:使用python,如何获取可以打开某种文件类型的软件列表?
- python - Python 使用指定的映射对字典列表进行排序
- python - 检查熊猫数据框中是否存在最小和最大日期之间的所有日期?
- oracle - PLSQL中过程内部的类型转换
- django - 无效的 Django 表单集
- arrays - 我想知道从数组中删除后值在哪里?
- typescript - Typescript keyof 数组包含原型方法
- amazon-web-services - Guardduty 无法检测到 Aws 之外的攻击
- sql - SQL查询找出元素的最后一次出现
- macos - 为什么启动应用程序时不存在 zsh 环境变量?