视频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)
相关推荐
盈电智控1 天前
体力劳动反而更难被AI取代?物联网科技如何守护最后的劳动阵地
开发语言·人工智能·python
隔壁阿布都1 天前
Spring Boot中的Optional如何使用
开发语言·spring boot·python
谢景行^顾1 天前
深度学习--激活函数
人工智能·python·机器学习
三千院本院1 天前
LlaMA_Factory实战微调Qwen-LLM大模型
人工智能·python·深度学习·llama
wljt1 天前
Linux 常用命令速查手册(Java开发版)
java·linux·python
WPG大大通1 天前
AIoT | 软件:Astra MCP边缘算力构建详解
经验分享·笔记·python·硬件架构·代码
十一.3661 天前
37-38 for循环
前端·javascript·html
波诺波1 天前
环境管理器
linux·前端·python
诸葛思颖1 天前
把本地 Python 项目用 Git 进行版本控制并推送到 GitHub
git·python·github
测试老哥1 天前
自动化测试用例的编写和管理
自动化测试·软件测试·python·功能测试·测试工具·职场和发展·测试用例