无法使用 Flask 播放 HTML5 视频 [英] Can't play HTML5 video using Flask
问题描述
我正在使用 Flask 提供 .m3u8 和 .ts 文件来模拟视频点播流.
I'm using Flask to serve .m3u8 and .ts files to simulate a vod stream.
视频播放器不会流式传输文件并显示错误(请参见下面的屏幕截图).我找不到它是什么错误的日志.
The video player does not stream the file and shows an error (see the screenshot below). I can't find a log of what error it is.
是否有我遗漏的日志消息?这是什么原因造成的,我该如何解决?
Is there a log message somewhere that I'm missing? What is causing this and how can I fix it?
推荐答案
开发服务器默认以单线程模式运行,这意味着它一次只能处理一个请求.您一次请求两个文件的流,.m3u8 和 .ts.您可以通过 threaded=True
或 processes=value 更大比 1
到 app.run
允许一次处理多个请求,但这有其自身的问题.通常,开发服务器在流式传输 html5 视频和音频时似乎存在问题.真正的解决方案是使用实际的服务器(例如 Nginx 或 Apache)来提供媒体文件.
The development server runs in single threaded mode by default, meaning it can only handle one request at a time. You are requesting streams of two files at once, the .m3u8 and the .ts. You can pass threaded=True
or processes=value greater than 1
to app.run
to allow handling of multiple requests at once, but that comes with it's own problems. The development server in general seems to have problems streaming html5 video and audio. The real solution is to use an actual server such as Nginx or Apache to serve the media files.
这篇关于无法使用 Flask 播放 HTML5 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!