问题描述
我正在尝试使用 Bottle 微框架从连接到 RaspBerry Pi 的 USB 网络摄像头流式传输视频。我可以使用 VLC 查看视频流,但不能在浏览器中查看。
gen_frame 函数:
camera = cv2.VideoCapture(0)
def gen_frames():
try:
while True:
success,frame = camera.read() # read the camera frame
if not success:
break
else:
ret,buffer = cv2.imencode('.jpg',frame)
frame = buffer.tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
except Exception as e:
print(str(e))
视频生成路径如下:
@webcamBot.route('/webcam-test/video_Feed')
def video_Feed():
try:
return Response(gen_frames(),mimetype='multipart/x-mixed-replace; boundary=frame')
except Exception as e:
print(str(e))
<img id="webcam" src="http://192.168.1.12:8024/webcam-test/video_Feed" style="width: 300px; height: $
但是没有视频出现。我在 VLC 中测试了 src 链接,效果很好。
我也没有收到任何错误消息。
感谢建议。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)