【发布时间】:2020-05-24 06:08:46
【问题描述】:
我已经为直播设置了一个 nginx 服务器,一切正常,我可以看到直播 VLC 播放器。
我正在尝试在网络浏览器而不是 VLC 播放器中实现直播,但没有得到任何适当的解决方案。
我看到了很多 jw 播放器的例子,但它不起作用。 任何人都请建议最好在网络浏览器中观看直播。
谢谢
【问题讨论】:
我已经为直播设置了一个 nginx 服务器,一切正常,我可以看到直播 VLC 播放器。
我正在尝试在网络浏览器而不是 VLC 播放器中实现直播,但没有得到任何适当的解决方案。
我看到了很多 jw 播放器的例子,但它不起作用。 任何人都请建议最好在网络浏览器中观看直播。
谢谢
【问题讨论】:
这已经不可能了。以前可以使用 FASH,但不再支持 flash。您必须使用受支持的格式,例如 HLS 或 DASH
【讨论】:
因为我在尝试解决类似问题时来晚了,所以这里有一个我觉得有用的答案。
一个选项可能正在使用这个项目:rtsp-simple-server
您可以尝试使用从 rtmp 到 HLS 的代理。然后你需要为你的浏览器添加 HLS 支持(此时非 sarari 浏览器似乎需要像 hls.js 这样的 JS 后备)
您可能希望在配置 yaml 中添加这样的部分来桥接单个流:
paths:
hls:
source: rtmp://example.com:1935/stream
【讨论】:
import time
import cv2
from flask import Flask, render_template, Response
from werkzeug.wrappers import Request, Response
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
def gen():
cap = cv2.VideoCapture("live streaming **strong text**url")
width = 1200
height = 700
dim = (width, height)
while(cap.isOpened()):
ret, img = cap.read()
if ret == True:
img = cv2.resize(img, dim, fx=0.5, fy=0.5)
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')
time.sleep(0.1)
else:
break
@app.route('/video_feed')
def video_feed():
return Response(gen(),
mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ ==('__main__'):
from werkzeug.serving import run_simple
run_simple('localhost', 7600, app)
【讨论】: