66
77* 7 x 24 小时无人监守录制、渲染弹幕、识别字幕、自动上传,启动项目,人人都是录播员。*
88
9- [ :page_facing_up : Documentation] ( #major-features ) |
9+ [ :page_facing_up : Documentation] ( https://timerring.github.io/bilive/ ) |
1010[ :gear : Installation] ( #quick-start ) |
1111[ :thinking : Reporting Issues] ( https://github.com/timerring/bilive/issues/new/choose )
1212
2121
2222## 2. Major features
2323
24- <!-- - **速度快**:~~录制的同时可以选择启动无弹幕版视频的上传进程,下播即上线平台~~。(无弹幕版暂缓上线,等维护完成下一个版本上线) -->
25- - ** 速度快** :采用 ` pipeline ` 流水线处理视频,理想情况下录播与直播相差半小时以内,没下播就能上线录播!
24+ - ** 速度快** :采用 ` pipeline ` 流水线处理视频,理想情况下录播与直播相差半小时以内,没下播就能上线录播,** 目前已知 b 站录播最快版本** !
2625- ** 多房间** :同时录制多个直播间内容视频以及弹幕文件(包含普通弹幕,付费弹幕以及礼物上舰等信息)。
2726- ** 占用小** :自动删除本地已上传的视频,极致节省空间。
2827- ** 模版化** :无需复杂配置,开箱即用,( :tada : NEW)通过 b 站搜索建议接口自动抓取相关热门标签。
2928- ** 检测片段并合并** :对于网络问题或者直播连线导致的视频流分段,能够自动检测合并成为完整视频。
30- - ** 渲染弹幕版视频 ** :自动转换xml为ass弹幕文件并且渲染到视频中形成** 有弹幕版视频** 并自动上传。
29+ - ** 自动渲染弹幕 ** :自动转换xml为ass弹幕文件并且渲染到视频中形成** 有弹幕版视频** 并自动上传。
3130- ** 硬件要求极低** :无需GPU,只需最基础的单核CPU搭配最低的运存即可完成录制,弹幕渲染,上传等等全部过程,无最低配置要求,10年前的电脑或服务器依然可以使用!
3231- ** ( :tada : NEW)自动渲染字幕** (如需使用本功能,则需保证有 Nvidia 显卡):采用 OpenAI 的开源模型 [ ` whisper ` ] ( https://github.com/openai/whisper ) ,自动识别视频内语音并转换为字幕渲染至视频中。
3332
@@ -66,111 +65,128 @@ graph TD
6665+ 带宽: 3Mbps
6766 > 个人经验:若想尽可能快地更新视频,主要取决于上传速度而非弹幕渲染速度,因此建议网络带宽越大越好。
6867
69- > [ !TIP]
70- > 关于渲染速率:与弹幕数量有关,测试硬件的基本区间 2核 Xeon(R) Platinum 85 的 CPU 的渲染速率在 3 ~ 6 倍之间,也可使用 Nvidia GPU 加速,项目的测试显卡为 GTX1650,其渲染速率在 16 ~ 20 倍之间。
71- >
72- > 弹幕渲染具体时间可通过 ` 渲染速率x视频时长 ` 估算,如无需 GPU 加速渲染过程,请忽略本条提示。
73- >
74- > 如需使用 Nvidia GPU 加速,
75- > 请参考:
76- > + [ Using FFmpeg with NVIDIA GPU Hardware Acceleration] ( https://docs.nvidia.com/video-technologies/video-codec-sdk/12.0/ffmpeg-with-nvidia-gpu/index.html )
77- > + [ 使用GPU为FFmpeg 加速] ( https://yukihane.work/li-gong/ffmpeg-with-gpu )
78-
7968## 4. Quick start
8069
70+ 更详细的教程请参考文档 [ bilive] ( https://timerring.github.io/bilive/ )
71+
8172> [ !NOTE]
8273> 如果你是 windows 用户,请不要使用命令提示符(Command Prompt)或 Windows PowerShell,请使用 [ PowerShell] ( https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4 ) 或 Linux 终端例如 WSL 或 ** Git Bash** (推荐)。
74+
75+ ### Mode
76+ 首先介绍本项目三种不同的处理模式:
77+ 1 . ` pipeline ` 模式(默认): 目前最快的模式,需要 GPU 支持,最好在 ` blrec ` 设置片段为半小时以内,asr 识别和渲染并行执行,分 p 上传视频片段。
78+ ![ ] ( https://cdn.jsdelivr.net/gh/timerring/scratchpad2023/2024/2024-12-11-17-33-15.png )
79+ 2 . ` append ` 模式: 基本同上,但 asr 识别与渲染过程串行执行,比 pipeline 慢预计 25% 左右,对 GPU 显存要求较低,兼顾硬件性能与处理上传效率。
80+ ![ ] ( https://cdn.jsdelivr.net/gh/timerring/scratchpad2023/2024/2024-12-11-19-07-12.png )
81+ 3 . ` merge ` 模式: 等待所有录制完成,再进行识别渲染合并过程,上传均为完整版录播(非分 P 投稿),等待时间较长,效率较慢,适合需要上传完整录播的场景。
82+ ![ ] ( https://cdn.jsdelivr.net/gh/timerring/scratchpad2023/2024/2024-12-11-19-08-58.png )
83+
84+ > [ !IMPORTANT]
85+ > 凡是用到 GPU 均需保证 GPU 显存大于运行程序所需 VRAM,具体计算 VRAM 方法可以参考[ 该部分] ( https://timerring.github.io/bilive/models.html#计算-vram-需求 ) 。
86+
87+ ### Installation(有 GPU 版本)
88+
89+ > 是否有 GPU 以 ` nvidia-smi ` 显示驱动以及 ` CUDA ` 检查通过为准。如果未配置显卡驱动或未安装 ` CUDA ` ,即使有 GPU 也无法使用。
90+
91+ > [ !TIP]
92+ > 如果你是 windows 用户,请不要使用命令提示符(Command Prompt)或 Windows PowerShell,请使用 [ PowerShell] ( https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4 ) 或 WSL 或 ** Git Bash** (推荐)。
8393>
8494> ** 注意:PowerShell 和 Windows PowerShell 是[ 不同的应用程序] ( https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.4&viewFallbackFrom=powershell-7.3 ) 。**
85-
86- ### 4.1 安装环境
95+
96+ #### 1. 安装依赖(推荐先 ` conda ` 创建虚拟环境)
97+
8798```
88- # 进入项目目录
8999cd bilive
90- # 安装所需依赖 推荐先 conda 创建虚拟环境
91100pip install -r requirements.txt
92- # 记录项目根目录
101+ ```
102+
103+ 此外请根据各自的系统类型安装对应的 [ ` ffmpeg ` ] ( https://www.ffmpeg.org/download.html ) ,例如 [ ubuntu 安装 ffmpeg] ( https://gcore.com/learning/how-to-install-ffmpeg-on-ubuntu/ ) 。
104+
105+ [ 常见问题收集] ( https://timerring.github.io/bilive/install-questions.html )
106+
107+ #### 2. 设置环境变量用于保存项目根目录
108+
109+ ```
93110./setPath.sh && source ~/.bashrc
94111```
95112
96- 项目大多数参数均在 ` src/allconfig.py ` 文件中,相关参数如下:
97- + GPU_EXIST 是否存在 GPU(以 ` nvidia-smi ` 显示驱动以及 ` CUDA ` 检查通过为主)
98- + MODEL_TYPE 渲染模式,
99- + ` pipeline ` 模式(默认): 目前最快的模式,需要 GPU 支持,最好在 ` blrec ` 设置片段为半小时以内,asr 识别和渲染并行执行,分 p 上传视频片段。
100- + ` append ` 模式: 基本同上,但 asr 识别与渲染过程串行执行,比 pipeline 慢预计 25%。
101- + ` merge ` 模式: 等待所有录制完成,再进行合并识别渲染过程,上传均为完整版录播。
113+ #### 3. 配置 whisper 模型
102114
103- 以下功能默认开启,如果无 GPU,请直接看 4.2 节,并将 ` src/allconfig.py ` 文件中的 ` GPU_EXIST ` 参数设置为 ` False ` ,并将 ` MODEL_TYPE ` 调整为 ` merge ` 或者 ` append ` 。
104- 如果需要使用自动识别并渲染字幕功能,模型参数及链接如下,注意 GPU 显存必须大于所需 VRAM:
115+ 项目默认采用 [ ` small ` ] ( https://openaipublic.azureedge.net/main/whisper/models/9ecf779972d90ba49c06d968637d720dd632c55bbf19d441fb42bf17a411e794/small.pt ) 模型,请点击下载所需文件,并放置在 ` src/subtitle/models ` 文件夹中。
105116
106- | Size | Parameters | Multilingual model | Required VRAM |
107- | :------:| :----------:| :------------------:| :-------------:|
108- | tiny | 39 M | [ ` tiny ` ] ( https://openaipublic.azureedge.net/main/whisper/models/65147644a518d12f04e32d6f3b26facc3f8dd46e5390956a9424a650c0ce22b9/tiny.pt ) | ~ 1 GB |
109- | base | 74 M | [ ` base ` ] ( https://openaipublic.azureedge.net/main/whisper/models/ed3a0b6b1c0edf879ad9b11b1af5a0e6ab5db9205f891f668f8b0e6c6326e34e/base.pt ) | ~ 1 GB |
110- | small | 244 M | [ ` small ` ] ( https://openaipublic.azureedge.net/main/whisper/models/9ecf779972d90ba49c06d968637d720dd632c55bbf19d441fb42bf17a411e794/small.pt ) | ~ 2 GB |
111- | medium | 769 M | [ ` medium ` ] ( https://openaipublic.azureedge.net/main/whisper/models/345ae4da62f9b3d59415adc60127b97c714f32e89e936602e85993674d08dcb1/medium.pt ) | ~ 5 GB |
112- | large | 1550 M | [ ` large ` ] ( https://openaipublic.azureedge.net/main/whisper/models/81f7c96c852ee8fc832187b0132e569d6c3065a3252ed18e56effd0b6a73e524/large-v2.pt ) | ~ 10 GB |
117+ > [ !TIP]
118+ > 使用该参数模型至少需要保证有显存大于 2.7GB 的 GPU,否则请使用其他参数量的模型。
119+ > + 更多模型请参考 [ whisper 参数模型] ( https://timerring.github.io/bilive/models.html ) 部分。
120+ > + 更换模型方法请参考 [ 更换模型方法] ( https://timerring.github.io/bilive/models.html#更换模型方法 ) 部分。
113121
114- > [ !NOTE]
115- > 1 . 项目默认采用 [ ` small ` ] ( https://openaipublic.azureedge.net/main/whisper/models/9ecf779972d90ba49c06d968637d720dd632c55bbf19d441fb42bf17a411e794/small.pt ) 模型,请自行下载所需文件,并放置在 ` src/subtitle/models ` 文件夹中。
116- > 2 . 由于 github 单个文件上限是 100MB,因此本仓库内只保留了 tiny 模型以供试用,如需试用请将 ` settings.ini ` 文件中的 ` Mode ` 参数设置为模型对应Size名称` tiny ` ,使用其他参数量模型同理。
117- > 3 . 如果追求识别准确率,推荐使用参数量 ` small ` 及以上的模型。
118122
119- ### 4.2 biliup-rs 登录
123+ #### 4. biliup-rs 登录
120124
121125首先按照 [ biliup-rs] ( https://github.com/biliup/biliup-rs ) 登录b站,登录脚本在 ` src/upload/biliup ` ,登录产生的` cookies.json ` 保留在该文件夹下即可。
122126
123- ### 4.3 启动自动录制
124-
125- - 在 ` record.sh ` 启动脚本中设置端口 ` port `
126- - 在 ` settings.toml ` 中设置视频存放目录、日志目录,也可启动后在 blrec 前端界面即` http://localhost:port ` 中进行设置。详见 [ blrec] ( https://github.com/acgnhiki/blrec ) 。
127+ [ 常见问题收集] ( https://timerring.github.io/bilive/biliup.html )
127128
128- 启动 blrec:
129+ #### 5. 启动自动录制
129130
130131``` bash
131132./record.sh
132133```
133- ### 4.4 启动自动上传
134134
135- > 请先确保你已经完成了 4.1 步骤,下载并放置了模型文件。
136- > 否则,请将 ` src/allconfig.py ` 文件中的 ` GPU_EXIST ` 参数设置为 ` False `
135+ [ 常见问题收集] ( https://timerring.github.io/bilive/record.html )
137136
138- #### 启动扫描渲染进程
137+ #### 6. 启动自动上传
138+
139+ 请先确保你已经完成` 步骤 3 ` ,正确下载并放置了模型文件。
140+
141+ ##### 6.1 启动扫描渲染进程
139142
140143输入以下指令即可检测已录制的视频并且自动合并分段,自动进行弹幕转换,字幕识别与渲染的过程:
141144
142145``` bash
143146./scan.sh
144147```
145148
146- #### 启动自动上传进程
149+ [ 常见问题收集] ( https://timerring.github.io/bilive/scan.html )
150+
151+ ##### 6.2 启动自动上传进程
147152
148153``` bash
149154./upload.sh
150155```
151156
157+ [ 常见问题收集] ( https://timerring.github.io/bilive/upload.html )
158+
159+
160+ #### 7. 查看执行日志
161+
162+ 相应的执行日志请在 ` logs ` 文件夹中查看,如果有问题欢迎在 [ ` issue ` ] ( https://github.com/timerring/bilive/issues/new/choose ) 中提出。
163+ ```
164+ logs # 日志文件夹
165+ ├── blrecLog # blrec 录制日志
166+ │ └── ...
167+ ├── burningLog # 弹幕渲染日志
168+ │ └── ...
169+ ├── mergeLog # 片段合并日志
170+ │ └── ...
171+ ├── scanLog # scan运行日志
172+ │ └── ...
173+ ├── uploadLog # 视频上传日志
174+ │ └── ...
175+ └── blrec.log # record.sh 运行日志
176+ ```
177+
178+ ### Installation(无 GPU 版本)
179+ 无 GPU 版本过程基本同上,可以跳过步骤 3,需要注意在执行步骤 5 ** 之前** 完成以下设置将确保完全用 CPU 渲染视频弹幕。
180+
181+ 1 . 请将 ` src/allconfig.py ` 文件中的 ` GPU_EXIST ` 参数设置为 ` False `
182+ 2 . 将 ` MODEL_TYPE ` 调整为 ` merge ` 或者 ` append ` 。
183+
152184> [ !TIP]
153185> 上传默认参数如下,[ ] 中内容全部自动替换。也可在 src/upload/extract_video_info.py 中自定义相关配置:
154186> + 默认标题是"【弹幕】[ XXX] 直播回放-[ 日期] -[ 直播间标题] "。
155187> + 默认描述是"【弹幕+字幕】[ XXX] 直播,直播间地址:[ https://live.bilibili.com/XXX ] 内容仅供娱乐,直播中主播的言论、观点和行为均由主播本人负责,不代表录播员的观点或立场。"
156188> + 默认标签是根据主播名字自动在 b 站搜索推荐中抓取的[ 热搜词] ,详见[ bilibili-API-collect] ( https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/search/suggest.md ) 。
157189
158- > [ !NOTE]
159- > 相应的执行日志请在 ` logs ` 文件夹中查看。
160- > ```
161- > logs # 日志文件夹
162- > ├── blrecLog # blrec 录制日志
163- > │ └── ...
164- > ├── burningLog # 弹幕渲染日志
165- > │ └── ...
166- > ├── mergeLog # 片段合并日志
167- > │ └── ...
168- > ├── scanLog # scan运行日志
169- > │ └── ...
170- > ├── uploadLog # 视频上传日志
171- > │ └── ...
172- > └── blrec.log # record.sh 运行日志
173- > ```
174190
175191## 特别感谢
176192
@@ -179,4 +195,4 @@ pip install -r requirements.txt
179195- [ hihkm/DanmakuFactory] ( https://github.com/hihkm/DanmakuFactory )
180196- [ acgnhiki/blrec] ( https://github.com/acgnhiki/blrec )
181197- [ qqyuanxinqq/AutoUpload_Blrec] ( https://github.com/qqyuanxinqq/AutoUpload_Blrec )
182- - [OpenAI/whisper](https://github.com/OpenAI/whisper)
198+ - [ OpenAI/whisper] ( https://github.com/OpenAI/whisper )
0 commit comments