ppt updated

This commit is contained in:
2026-06-27 16:58:39 +08:00
parent 01ebdcbdc1
commit 1dc1fa5c7c
3 changed files with 213 additions and 105 deletions

View File

@@ -4,7 +4,7 @@ theme: default
size: 16:9
paginate: true
header: "Hightube 开源跨平台个人直播平台最终汇报"
footer: "Highground-Soft | 最终汇报 (v1.0.0-Release) | 2026.06.27"
footer: "Highground-Soft | 验收汇报 (v1.0.1-Release) | 2026.06.29"
style: |
:root {
--ink: #0f172a;
@@ -129,14 +129,14 @@ style: |
<div class="eyebrow">Final Project Presentation</div>
# Hightube 最终汇报
# Hightube 项目验收汇报
## 成果与展望:构建私有化直播生态
<p class="lead">已实现从<strong>高并发流引擎、后端性能优化</strong>到<strong>多端自适应拉流与公网部署</strong>的完整闭环。</p>
<div style="margin-top: 40px; font-size: 18px;">
Highground-Soft 团队:程景愉、舒钰权、李俊友、张钊源<br />
当前版本:<strong>v1.0.0-Release</strong> | 项目状态:已完成公网发布与性能验证
当前版本:<strong>v1.0.1-Release</strong> | 项目状态:已完成公网发布与性能验证
</div>
---
@@ -233,19 +233,26 @@ style: |
---
<!-- _class: compact arch-slide -->
<style scoped>
section { padding: 40px 58px 30px; }
h1 { margin-bottom: 6px; }
.card { padding: 12px 16px; }
table { font-size: 12px !important; }
td { padding: 3px 5px !important; }
</style>
# 系统架构总览
<div style="text-align:center; margin-bottom:12px;">
<p style="font-size:16px; color:var(--soft); margin:0;">
OBS / 移动端推流 → <strong>RTMP Server</strong> → <strong>FFmpeg 转码管线</strong> → <strong>Go 业务后端</strong> → <strong>Flutter / Web 播放端</strong>
</p>
<div style="text-align:center; font-size:14px; color:var(--soft); margin-bottom:8px;">
OBS 推流 → <strong>RTMP Server</strong> → <strong>FFmpeg 转码管线</strong> → <strong>Go 业务后端</strong> → <strong>Web / 移动端播放</strong>
</div>
<div class="grid-2">
<div class="card">
<h3>流媒体分发层</h3>
<table style="width:100%; font-size:16px;">
<tr><td>推流监听</td><td><strong>RTMP 协议</strong> (端口 1935)</td></tr>
<h3 style="margin-bottom: 4px;">流媒体分发层</h3>
<table style="width:100%; line-height: 1.2; border-collapse: collapse;">
<tr><td style="width: 25%;">推流监听</td><td><strong>RTMP 协议</strong> (端口 1935)</td></tr>
<tr><td>流鉴权</td><td>URL 路径 <code>stream_key</code> 数据库实时匹配</td></tr>
<tr><td>转码引擎</td><td>FFmpeg 子进程异步管线 (原始/720p/480p)</td></tr>
<tr><td>Web 分发</td><td><strong>HTTP-FLV</strong> (低延迟 chunked 长连接)</td></tr>
@@ -253,9 +260,9 @@ style: |
</table>
</div>
<div class="card">
<h3>应用业务层 (Go)</h3>
<table style="width:100%; font-size:16px;">
<tr><td>Web 框架</td><td><strong>Gin</strong> — 路由控制、CORS 过滤、健康监测</td></tr>
<h3 style="margin-bottom: 4px;">应用业务层 (Go)</h3>
<table style="width:100%; line-height: 1.2; border-collapse: collapse;">
<tr><td style="width: 25%;">Web 框架</td><td><strong>Gin</strong> — 路由控制、CORS 过滤、健康监测</td></tr>
<tr><td>ORM / 数据库</td><td><strong>GORM + SQLite</strong> (嵌入式轻量级持久化)</td></tr>
<tr><td>安全体系</td><td><strong>JWT</strong> 访问令牌 + <strong>Bcrypt</strong> 密码单向哈希</td></tr>
<tr><td>互动接口</td><td><strong>Gorilla WebSocket</strong> Hub 模式弹幕服务器</td></tr>
@@ -264,13 +271,13 @@ style: |
</div>
</div>
<p style="margin-top: 14px; font-size: 16px; text-align: center;"><strong>部署核心</strong>客户端Flutter与服务端Go完全分离结合 Docker 容器化一键部署。</p>
<p style="margin-top: 8px; font-size: 14px; text-align: center; color: var(--muted);"><strong>部署核心</strong>客户端Flutter与服务端Go完全分离结合 Docker 容器化一键部署。</p>
---
<!-- _class: compact -->
# 后端性能优化:三驾马车 (重点)
# 后端性能优化:三驾马车
为了解决直播系统高并发读写下 SQLite 数据库锁死、Socket 写入开销高的问题,设计了三大底层优化:
@@ -306,31 +313,46 @@ style: |
---
<!-- _class: compact -->
<style scoped>
section { padding: 40px 58px 30px; }
table { font-size: 11px !important; line-height: 1.2; width: 100%; table-layout: fixed; border-collapse: collapse; }
th, td { padding: 4px 6px !important; }
</style>
# 后端性能优化:定量测试成果 (重点)
通过并发压测与物理测量,后端调优取得了极其显著的性能定量数据:
<p style="margin: 0 0 8px; font-size: 15px;">通过并发压测与物理测量,后端调优取得了极其显著的性能定量数据:</p>
<div class="grid-2">
<div class="card">
<h3>SQLite 并发写吞吐量对比 (TPS)</h3>
<table style="width:100%; font-size:16px;">
<div class="card" style="padding: 12px 16px;">
<h3 style="margin-bottom: 4px;">SQLite 并发写吞吐量对比 (TPS)</h3>
<table style="width:100%; table-layout: fixed;">
<colgroup>
<col style="width: 28%;">
<col style="width: 22%;">
<col style="width: 28%;">
<col style="width: 22%;">
</colgroup>
<tr><th>并发客户端数</th><th>普通模式</th><th>WAL 调优模式</th><th>提升幅度</th></tr>
<tr><td>1 客户端</td><td>85 tps</td><td>125 tps</td><td>+ 47.1%</td></tr>
<tr><td>5 并发</td><td>18 tps</td><td>240 tps</td><td>+ 1,233.3%</td></tr>
<tr><td>10 并发</td><td>9 tps (大量超时)</td><td><strong>380 tps</strong></td><td><strong>+ 4,122.2%</strong></td></tr>
<tr><td>10 并发</td><td>9 tps (超时)</td><td><strong>380 tps</strong></td><td><strong>+ 4,122.2%</strong></td></tr>
</table>
<p style="font-size: 14px; margin-top: 8px; color: var(--soft);">* WAL 配合同步 NORMAL 与内存 temp_store彻底消除了写锁定错误。</p>
<p style="font-size: 9.5px; margin-top: 3px; color: var(--soft); margin-bottom: 0;">* WAL 配合同步 NORMAL 与内存 temp_store彻底消除锁表冲突。</p>
</div>
<div class="card">
<h3>流媒体播放延迟定量测试 (Latency)</h3>
<table style="width:100%; font-size:16px;">
<div class="card" style="padding: 12px 16px;">
<h3 style="margin-bottom: 4px;">流媒体播放延迟定量测试 (Latency)</h3>
<table style="width:100%; table-layout: fixed;">
<colgroup>
<col style="width: 32%;">
<col style="width: 22%;">
<col style="width: 22%;">
<col style="width: 24%;">
</colgroup>
<tr><th>测试链路</th><th>追帧关闭</th><th>追帧开启</th><th>分析结论</th></tr>
<tr><td>同网直连 RTMP</td><td>800 ms</td><td>800 ms</td><td>局域网直连物理延迟极低</td></tr>
<tr><td>公网 FRP RTMP</td><td>1250 ms</td><td>1250 ms</td><td>穿透引入约 450ms 网络延迟</td></tr>
<tr><td>Web HTTP-FLV</td><td>2600 ms</td><td><strong>1650 ms</strong></td><td>追帧开启后降低 1 秒延迟</td></tr>
<tr><td>网络抖动积压</td><td>6200 ms</td><td><strong>1700 ms</strong></td><td><strong>15秒内快速收敛至正常水平</strong></td></tr>
<tr><td>同网直连 RTMP</td><td>800 ms</td><td>800 ms</td><td>局域网物理延迟极低</td></tr>
<tr><td>公网 FRP RTMP</td><td>1250 ms</td><td>1250 ms</td><td>中转引入约 450ms 开销</td></tr>
<tr><td>Web HTTP-FLV</td><td>2600 ms</td><td><strong>1650 ms</strong></td><td>算法介入后降低 1 秒</td></tr>
<tr><td>网络抖动积压</td><td>6200 ms</td><td><strong>1700 ms</strong></td><td><strong>15秒内快速平滑收敛</strong></td></tr>
</table>
</div>
</div>
@@ -338,18 +360,22 @@ style: |
---
<!-- _class: compact -->
<style scoped>
section { padding: 25px 40px 15px; }
h1 { margin-bottom: 6px; }
</style>
# 公网部署方案:网络拓扑结构 (重点)
# 公网部署方案:网络拓扑结构
<div style="text-align: center; margin-bottom: 10px;">
<img src="figures/topo.png" width="850" style="display:block; margin: 0 auto; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);" />
<div style="text-align: center; margin-top: -8px; margin-bottom: 4px;">
<img src="figures/topo.png" width="1140" style="display:block; margin: 0 auto; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.12);" />
</div>
<p style="margin: 0; font-size: 16px; text-align: center; color: var(--muted);">利用 <strong>FRP 内网穿透</strong> 与 <strong>Caddy 反向代理</strong>,实现零公网 IP 本地服务器的公网安全暴露。</p>
<p style="margin: 0; font-size: 14.5px; text-align: center; color: var(--muted);">利用 <strong>FRP 内网穿透</strong> 与 <strong>Caddy 反向代理</strong>,实现零公网 IP 本地服务器的公网安全暴露。</p>
---
# 公网部署方案:隧道穿透与反向代理 (重点)
# 公网部署方案:隧道穿透与反向代理
<div class="grid-2">
<div class="card">
@@ -381,61 +407,31 @@ style: |
---
# 关键技术突破Web 端播放器适配
<div class="grid-2">
<div class="card">
<h3>1. 平台视图 iframe 混合渲染</h3>
<ul style="font-size:17px;">
<li>在 Flutter Web 侧通过 <code>HtmlElementView</code> 动态注册 iframe 播放页面 <code>flv_player.html</code>。</li>
<li>将 <code>flv.min.js</code> 本地化部署到项目内,摆脱对外部 CDN 网络连通性的依赖。</li>
<li>采用 HTML5 <code>postMessage</code> 通道,实现 Flutter 主框架到 iframe 播放页面的跨域音量/状态控制。</li>
</ul>
</div>
<div class="card">
<h3>2. 前端自适应速率追帧算法</h3>
<ul style="font-size:17px;">
<li>通过监听 HTML5 <code>video</code> 元素的 <code>timeupdate</code> 事件,实时计算当前缓冲区延迟。</li>
<li><strong>延迟 &gt; 5 秒</strong>:强制跳帧到 <code>video.currentTime = end - 1.0</code>。</li>
<li><strong>延迟 1.5 ~ 5 秒</strong>:触发 1.15 倍播放速率微调追帧,实测在 15 秒内即可无感知地将累积延迟收敛到正常线,保证用户体验。</li>
</ul>
</div>
</div>
---
# 界面展示
<!-- _class: compact -->
<style scoped>
section { padding: 40px 58px 30px; }
.grid-2 { gap: 16px; }
.card { padding: 10px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.72); }
img { width: 100%; height: 185px !important; object-fit: contain; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.06); border: 1px solid var(--line); }
h3 { margin: 8px 0 2px; font-size: 16.5px; color: var(--blue); }
p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.3; text-align: center; }
</style>
# 界面展示Web 端平台与播放效果
<div class="grid-2">
<div class="card">
<img src="figures/hightube-official.png" />
<div style="text-align: center;">
<img src="figures/hightube-official.png" width="420" style="border-radius: 8px; border: 1px solid var(--line);" />
<span style="font-size: 13px; display: block; margin-top: 4px; color: var(--soft);">图1Web 浏览器平台主页(活跃房间列表)</span>
<h3>Web 平台主页</h3>
<p>展示活跃直播间列表与 12s 定期封面图轮询</p>
</div>
</div>
<div class="card">
<img src="figures/hightube-screenshot.png" />
<div style="text-align: center;">
<img src="figures/hightube-screenshot.png" width="420" style="border-radius: 8px; border: 1px solid var(--line);" />
<span style="font-size: 13px; display: block; margin-top: 4px; color: var(--soft);">图2OBS 直播推送与 Web 端低延迟拉流及实时弹幕互动</span>
</div>
</div>
</div>
---
# 界面展示 (客户端)
<div class="grid-2">
<div class="card">
<div style="text-align: center;">
<img src="figures/hightube-adminpanel.png" width="400" style="border-radius: 8px; border: 1px solid var(--line);" />
<span style="font-size: 13px; display: block; margin-top: 4px; color: var(--soft);">图3自研后端管理控制台及系统健康指标</span>
</div>
</div>
<div class="card">
<div style="text-align: center;">
<img src="figures/hightube-android.jpg" width="160" style="border-radius: 8px; border: 1px solid var(--line);" />
<span style="font-size: 13px; display: block; margin-top: 4px; color: var(--soft);">图4Android 手机客户端直播与聊天室界面</span>
<h3>网页端直播与弹幕互动</h3>
<p>flv.js 自适应追帧播放与 WebSocket 弹幕互动</p>
</div>
</div>
</div>
@@ -443,26 +439,86 @@ style: |
---
<!-- _class: compact -->
<style scoped>
section { padding: 40px 58px 30px; }
.grid-2 { gap: 16px; }
.card { padding: 10px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.72); }
img { width: 100%; height: 185px !important; object-fit: contain; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.06); border: 1px solid var(--line); }
h3 { margin: 8px 0 2px; font-size: 16.5px; color: var(--blue); }
p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.3; text-align: center; }
</style>
# 界面展示:管理后台与手机端
<div class="grid-2">
<div class="card">
<img src="figures/hightube-adminpanel.png" />
<div style="text-align: center;">
<h3>自研后端管理控制台</h3>
<p>实时监控系统健康指标、当前并发数与 SSE 异步日志流</p>
</div>
</div>
<div class="card">
<img src="figures/hightube-android.jpg" />
<div style="text-align: center;">
<h3>Android 手机客户端</h3>
<p>Flutter 自绘引擎渲染与低延迟硬解拉流</p>
</div>
</div>
</div>
---
<!-- _class: compact -->
<style scoped>
section { padding: 40px 58px 30px; }
h1 { margin-bottom: 8px; }
table { font-size: 11.5px !important; line-height: 1.25; width: 100%; table-layout: fixed; border-collapse: collapse; }
th, td { padding: 4.5px 6px !important; }
</style>
# 开发规范与团队协作
<div class="grid-2">
<div class="card">
<h3>工程化协作规范</h3>
<ul style="font-size:16px;">
<li><strong>契约先行</strong>:前后端联调前先规定好 RESTful JSON 接口及 API Schema降低联调摩擦。</li>
<li><strong>Git 分支工作流</strong>:采用功能分支开发,代码合并需通过 Merge Request 与同行评审(Code Review,保证 main 分支稳定可用。</li>
<li><strong>自动规范化格式</strong>Go 后端强制开启 <code>gofmt</code>Flutter 引入 <code>analysis_options.yaml</code> 开启严苛的静态类型检查与垃圾变量扫描。</li>
<ul style="font-size:14px; padding-left: 1.1em; line-height: 1.35;">
<li><strong>契约先行</strong>:前后端联调前先落定 RESTful JSON 接口,极大降低双方联调摩擦。</li>
<li><strong>Git 分支工作流</strong>:采用特性分支开发,合并须经过 MR 与 Code Review持主分支始终可用。</li>
<li><strong>格式与静态规范</strong>:后端强制执行 <code>gofmt</code> 格式化;前端配置严格 <code>analysis_options.yaml</code> 检查。</li>
</ul>
</div>
<div class="card">
<h3>成员分工</h3>
<table style="width:100%; font-size:14px;">
<tr><th>成员</th><th>职责与主要交付成果</th></tr>
<tr><td><strong>程景愉</strong></td><td>后端框架搭建、流媒体解封装、FFmpeg 实时转码通道</td></tr>
<tr><td><strong>舒钰权</strong></td><td>RESTful 业务逻辑编写、JWT Token 中间件与用户系统</td></tr>
<tr><td><strong>李俊友</strong></td><td>Flutter 原生播放器对接、WebSocket 实时聊天室、弹幕渲染</td></tr>
<tr><td><strong>张钊源\n(本人)</strong></td><td>流媒体底座与推流鉴权、Web 端嵌入式 flv.js 播放器与自适应追帧、公网 FRP + Caddy 反向隧道部署</td></tr>
<h3>成员分工与交付成果</h3>
<table style="width: 100%; table-layout: fixed; border-collapse: collapse;">
<colgroup>
<col style="width: 24%;">
<col style="width: 76%;">
</colgroup>
<thead>
<tr>
<th style="text-align: left;">成员</th>
<th style="text-align: left;">核心职责与主要交付成果</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>程景愉<br/>(本人)</strong></td>
<td>项目总体管理前后端核心基础版本设计开发系统公网隧道穿透与Caddy反向代理分布式部署。</td>
</tr>
<tr>
<td><strong>舒钰权</strong></td>
<td>用户登录与个人设置界面开发, 基于 WebSocket 的直播聊天室与弹幕引擎开发,前端弹幕浮层与裁剪区域优化。</td>
</tr>
<tr>
<td><strong>张钊源</strong></td>
<td>后端管理面板、服务器运行状态监控Metrics、日志收集与历史审计功能等功能开发。</td>
</tr>
<tr>
<td><strong>李俊友</strong></td>
<td>后端核心流媒体与业务API架构设计及实现、前端音视频播放与Web适配, 项目介绍网站设计部署。</td>
</tr>
</tbody>
</table>
</div>
</div>
@@ -470,17 +526,68 @@ style: |
---
<!-- _class: compact challenge-slide -->
<style scoped>
section { padding: 40px 58px 30px; }
table { font-size: 13px !important; line-height: 1.25; width: 100%; table-layout: fixed; border-collapse: collapse; }
th, td { padding: 4px 6px !important; }
</style>
# 遇到的挑战与解决方案 (最终版)
# 遇到的挑战与解决方案
| 挑战 | 问题描述 | 最终解决方案 | 结果 |
| :--- | :--- | :--- | :---: |
| **推流安全** | RTMP 默认无校验,极易被恶意盗播 | 路径剥离 `stream_key` 并引入数据库实时鉴权拦截 | ✅ |
| **僵尸转码进程** | 直播中断后后台 FFmpeg 挂载无法回收 | 树状 `context.Context` 传导 + 资源 `defer cancel()` | ✅ |
| **Web 直连失败** | 浏览器沙箱环境不支持 RTMP 协议 | 引入 HTTP-FLV 分块传输流Web 侧调用 `flv.js` 解码 | ✅ |
| **缓存延迟累积** | 浏览器播放器积压缓冲,延迟越来越高 | 编写基于 `timeupdate` 的 1.15x 倍速追帧及强跳帧算法 | ✅ |
| **轻量数据库锁死** | 大量弹幕持久化写入引发 SQLite 独占锁 | 开启 `WAL` 日志模式,调优 synchronous、temp_store | ✅ |
| **公网资源发布** | 本地测试机处于内网且无公网 IP | 建立 **FRP** 穿透,配合公网 **Caddy** 证书自动化路由 | ✅ |
<table style="width: 100%; table-layout: fixed; border-collapse: collapse;">
<colgroup>
<col style="width: 15%;">
<col style="width: 32%;">
<col style="width: 45%;">
<col style="width: 8%;">
</colgroup>
<thead>
<tr>
<th style="text-align: left;">挑战</th>
<th style="text-align: left;">问题描述</th>
<th style="text-align: left;">最终解决方案</th>
<th style="text-align: center;">结果</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>推流安全</strong></td>
<td>RTMP 默认无校验,极易被恶意盗播</td>
<td>路径剥离 <code>stream_key</code> 并引入数据库实时鉴权拦截</td>
<td style="text-align: center;">✅</td>
</tr>
<tr>
<td><strong>僵尸转码进程</strong></td>
<td>直播中断后后台 FFmpeg 挂载无法回收</td>
<td>树状 <code>context.Context</code> 传导 + 资源 <code>defer cancel()</code></td>
<td style="text-align: center;">✅</td>
</tr>
<tr>
<td><strong>Web 直连失败</strong></td>
<td>浏览器沙箱环境不支持 RTMP 协议</td>
<td>引入 HTTP-FLV 分块传输流Web 侧调用 <code>flv.js</code> 解码</td>
<td style="text-align: center;">✅</td>
</tr>
<tr>
<td><strong>缓存延迟累积</strong></td>
<td>浏览器播放器积压缓冲,延迟越来越高</td>
<td>编写基于 <code>timeupdate</code> 的 1.15x 倍速追帧及强跳帧算法</td>
<td style="text-align: center;">✅</td>
</tr>
<tr>
<td><strong>轻量数据库锁死</strong></td>
<td>大量弹幕持久化写入引发 SQLite 独占锁</td>
<td>开启 <code>WAL</code> 日志模式,调优 synchronous、temp_store</td>
<td style="text-align: center;">✅</td>
</tr>
<tr>
<td><strong>公网资源发布</strong></td>
<td>本地测试机处于内网且无公网 IP</td>
<td>建立 <strong>FRP</strong> 穿透,配合公网 <strong>Caddy</strong> 证书自动化路由</td>
<td style="text-align: center;">✅</td>
</tr>
</tbody>
</table>
---
@@ -509,7 +616,7 @@ style: |
<!-- _class: compact -->
# 演示流程预览 (最终汇报)
# 演示流程预览
<div class="grid-2">
<div class="card">
@@ -542,7 +649,8 @@ style: |
<h1>感谢聆听</h1>
<p style="font-size:24px; margin: 16px 0 8px;"><strong>Hightube</strong> — 开源跨平台个人直播系统项目最终汇报</p>
<p style="font-size:18px; color: var(--soft); margin: 0 0 24px;">欢迎老师指正Q & A</p>
<p style="font-size:16px;">项目介绍地址:<strong>https://hightube.nudt.space</strong></p>
<p style="font-size:16px;">公网体验地址:<strong>https://stream.nudt.space</strong></p>
<p style="font-size:16px;">开源地址:<strong>https://github.com/Highground-Soft/Hightube</strong></p>
<p style="font-size:16px;">开源仓库地址:<strong>https://github.com/Highground-Soft/Hightube</strong></p>
</div>
</div>

BIN
presentation.pdf Normal file

Binary file not shown.

Binary file not shown.