视频m3u8形式播放 -- python and html

hls

hls官网地址

创建项目

ts为视频片段

m3u8文件内容

html

html 复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/hls.js@1"></script>
  </head>
  <body>
    hello
    <video id="video" controls></video>
    <script>
      if (Hls.isSupported()) {
        var video = document.getElementById('video');
        var hls = new Hls();
        hls.on(Hls.Events.MEDIA_ATTACHED, function () {
          console.log('video and hls.js are now bound together !');
        });
        hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
          console.log(
            'manifest loaded, found ' + data.levels.length + ' quality level',
          );
        });
        hls.loadSource('/static/00001.m3u8');
        // bind them together
        hls.attachMedia(video);
      }
    </script>
  </body>
</html>

app.py

py 复制代码
from flask import Flask,render_template

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

if __name__ == '__main__':
    app.run(debug=True,port=5000)
相关推荐
水银嘻嘻11 分钟前
Web 自动化之 HTML & JavaScript 详解
前端·自动化·html
忧陌6061 小时前
Day22打卡-复习
python
Sylvan Ding2 小时前
PyTorch Lightning实战 - 训练 MNIST 数据集
人工智能·pytorch·python·lightning
水银嘻嘻2 小时前
web 自动化之 Unittest 应用:报告&装饰器&断言
前端·python·自动化
攻城狮7号2 小时前
Python爬虫第20节-使用 Selenium 爬取小米商城空调商品
开发语言·数据库·爬虫·python·selenium
良木林2 小时前
HTML难点小记:一些简单标签的使用逻辑和实用化
前端·html
虚空之月&&轮舞者4 小时前
Python与矢量网络分析仪3671E:自动化测试(Vscode)
网络·vscode·python·射频工程
李昊哲小课5 小时前
tensorflow-cpu
大数据·人工智能·python·深度学习·数据分析·tensorflow
小彭律师10 小时前
数字化工厂中央控制室驾驶舱系统架构文档
python
old_power11 小时前
【Python】PDF文件处理(PyPDF2、borb、fitz)
python·pdf