zhibo/live-streaming/README.md
2025-12-15 11:21:21 +08:00

77 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 直播系统
基于 SRS 的个人直播系统,支持 RTMP 推流和 HTTP-FLV/HLS 播放。
## 快速开始
### 1. 安装依赖
```bash
# 后端依赖
npm install
# 前端依赖
cd client && npm install
```
### 2. 启动服务
**方式一Docker 部署(推荐)**
```bash
docker-compose up -d
```
**方式二:本地开发**
```bash
# 终端1: 启动 SRS (需要先安装 Docker)
docker run -d -p 1935:1935 -p 8080:8080 ossrs/srs:5
# 终端2: 启动 API 服务
npm run dev
# 终端3: 启动前端
cd client && npm start
```
### 3. 访问系统
- 前端界面: http://localhost:3000
- API 服务: http://localhost:3001
## 使用方法
### 主播开播
1. 打开 http://localhost:3000
2. 点击"开始直播",填写直播间信息
3. 复制推流地址和密钥
4. 打开 OBS设置 → 推流:
- 服务: 自定义
- 服务器: `rtmp://localhost:1935/live`
- 推流密钥: 复制的密钥
5. 点击"开始推流"
### 观众观看
1. 打开 http://localhost:3000
2. 点击想看的直播间
3. 自动播放(优先使用低延迟的 HTTP-FLV
## 技术栈
- 流媒体服务器: SRS 5.0
- 后端: Node.js + Express
- 前端: React 18 + flv.js + hls.js
- 容器化: Docker
## 端口说明
| 端口 | 服务 |
|------|------|
| 1935 | RTMP 推流 |
| 8080 | HTTP-FLV/HLS 播放 |
| 3001 | API 服务 |
| 3000 | 前端界面 |