From 1f0349959810285870cfe7ea12e4dc6a4e500d8b Mon Sep 17 00:00:00 2001 From: John Howe <89397553+timerring@users.noreply.github.com> Date: Thu, 10 Apr 2025 22:23:13 +0800 Subject: [PATCH] docs: update docs --- README.md | 12 +- docs/.vitepress/config.mts | 1 - docs/biliup.md | 11 -- docs/getting-started.md | 73 +++++------ docs/index.md | 38 +++--- docs/install-questions.md | 28 ++--- docs/installation.md | 250 ++++++++++++++++++++++++++----------- docs/models.md | 33 ++--- docs/record.md | 67 +++++----- docs/reference.md | 6 +- docs/scan.md | 56 ++++----- docs/test-hardware.md | 49 ++++---- docs/upload.md | 25 ++-- 13 files changed, 369 insertions(+), 280 deletions(-) delete mode 100644 docs/biliup.md diff --git a/README.md b/README.md index a1e58fa..4479767 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ > 如果您觉得项目不错,欢迎 :star: 也欢迎 PR 合作,如果有任何疑问,欢迎提 issue 交流。 > -> 敬告:本项目仅供学习交流使用,请在征得对方许可的情况下录制,请勿未经授权私自将内容用于商业用途,请勿用于大规模录制,违者会被官方封禁,法律后果自负。 +> **敬告:本项目仅供学习交流使用,请在征得对方许可的情况下录制,请勿未经授权私自将内容用于商业用途,请勿用于大规模录制,违者会被官方封禁,法律后果自负。** 自动监听并录制B站直播和弹幕(含付费留言、礼物等),根据分辨率转换弹幕、语音识别字幕并渲染进视频,根据弹幕密度切分精彩片段并通过视频理解大模型生成有趣的标题,根据图像生成模型自动生成视频封面,自动投稿视频和切片至B站,兼容无GPU版本,兼容超低配置服务器与主机。 @@ -79,11 +79,11 @@ |--------|---------|---------|---------| | OS | Ubuntu 22.04.4 LTS | debian 6.1.0 | Ubuntu 22.04.4 LTS | | Architecture | x64 | aarch64 | x64 | -| CPU | 2-core Intel(R) Xeon(R) Platinum 85 | 1-core Neoverse-N1 | Intel(R) Core(TM) i5-9300H CPU | +| CPU | 2-core Intel(R) Xeon(R) Platinum 85 | 1-core Neoverse-N1 | 8-core Intel(R) Core(TM) i5-9300H CPU | | GPU | None | None | Nvidia GeForce GTX 1650 | | Memory | 2G | 4G | 24G | -| Disk | 40G | 30G | 512G | -| Bandwidth | 3Mbps | 100Mbps | 100Mbps | +| Disk | 40G | 30G | 100G | +| Bandwidth | 3Mbps | 100Mbps | 50Mbps | | Python Version | 3.10 | 3.10 | 3.10 | > 个人经验:若想尽可能快地更新视频,主要取决于上传速度而非渲染速度,因此建议网络带宽越大越好。由于 [aarch64 版本 PyPI 没有 release](https://github.com/triton-lang/triton/issues/5561) 的 [triton 库](https://pypi.org/project/triton/#history),因此 aarch64 版本暂时不支持本地部署 whisper,pip 时请自行注释 requirement 中的 triton 环境,配置均测试可用。 @@ -105,7 +105,7 @@ ![](https://cdn.jsdelivr.net/gh/timerring/scratchpad2023/2024/2024-12-11-19-08-58.png) > [!IMPORTANT] -> 凡是用到 GPU 均需保证 GPU 显存大于运行程序所需 VRAM,具体计算 VRAM 方法可以参考[该部分](https://timerring.github.io/bilive/models.html#计算-vram-需求)。 +> 凡是用到 GPU 均需保证 GPU 显存大于运行程序所需 VRAM,具体计算 VRAM 方法可以参考[该部分](https://timerring.github.io/bilive/models.html#calculate-vram-requirements)。 ### Installation @@ -161,7 +161,7 @@ pip install -r requirements.txt > + 请保证 NVIDIA 显卡驱动安装正确 `nvidia-smi` `nvcc -V`,并能够调用 CUDA 核心 `print(torch.cuda.is_available())` 返回 `True`。如果未配置显卡驱动或未安装 `CUDA`,即使有 GPU 也无法使用,而会使用 CPU 推理,非常消耗 CPU 计算资源,不推荐,如果 CPU 硬件条件好可以尝试。 > + 使用该参数模型至少需要保证有显存大于 2.7GB 的 GPU,否则请使用其他参数量的模型。 > + 更多模型请参考 [whisper 参数模型](https://timerring.github.io/bilive/models.html) 部分。 -> + 更换模型方法请参考 [更换模型方法](https://timerring.github.io/bilive/models.html#更换模型方法) 部分。 +> + 更换模型方法请参考 [更换模型方法](https://timerring.github.io/bilive/models.html#change-model-method) 部分。 ##### 2.2 MLLM 模型(自动切片功能) diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 8363ca3..b74ac6b 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -21,7 +21,6 @@ let config = defineConfig({ { text: 'Installation & Usage', link: '/installation' }, { text: 'Models', link: '/models' }, { text: 'Questions', link: '/install-questions' }, - { text: 'Biliup', link: '/biliup' }, { text: 'Record', link: '/record' }, { text: 'Upload', link: '/upload' }, { text: 'Scan', link: '/scan' }, diff --git a/docs/biliup.md b/docs/biliup.md deleted file mode 100644 index 8ba0852..0000000 --- a/docs/biliup.md +++ /dev/null @@ -1,11 +0,0 @@ -# biliup常见问题 - -> 如果没有找到遇到的问题,请及时在 [issues](https://github.com/timerring/bilive/issues/new/choose) 中提出。 - -## biliup-rs 产生的 cookies 用处是什么? -1. 主要用于上传前验证登录状态。 -2. 投稿时(包括追加投稿时)指定账号。 -3. 追加投稿时查询已上传稿件的 bvid 进行视频追加投稿。 - -> [!TIP] -> 本 cookies 与 blrec 中录制 cookies 的稍有差别, blrec 中录制 cookies 的获取方法见 [blrec 常见问题](./record#录制-cookies-用处是什么)。 \ No newline at end of file diff --git a/docs/getting-started.md b/docs/getting-started.md index 1a62ca4..726e37b 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,47 +1,38 @@ # Introduction -自动监听并录制B站直播和弹幕(含付费留言、礼物等),根据分辨率转换弹幕、语音识别字幕并渲染进视频,根据弹幕密度切分精彩片段并通过视频理解大模型生成有趣的标题,自动投稿视频和切片至B站,兼容无GPU版本,兼容超低配置服务器与主机。 +> **Warning: This project is only for learning and exchange, please record after obtaining the consent of the other party, please do not use the content without authorization for commercial purposes, please do not use it for large-scale recording, otherwise it will be banned by the official, legal consequences will be self-borne.** -## Major features - -- **速度快**:采用 `pipeline` 流水线处理视频,理想情况下录播与直播相差半小时以内,没下播就能上线录播,**目前已知 b 站录播最快版本**! -- **多房间**:同时录制多个直播间内容视频以及弹幕文件(包含普通弹幕,付费弹幕以及礼物上舰等信息)。 -- **占用小**:自动删除本地已上传的视频,极致节省空间。 -- **模版化**:无需复杂配置,开箱即用,( :tada: NEW)通过 b 站搜索建议接口自动抓取相关热门标签。 -- **检测片段并合并**:对于网络问题或者直播连线导致的视频流分段,能够自动检测合并成为完整视频。 -- **自动渲染弹幕**:自动转换xml为ass弹幕文件并且渲染到视频中形成**有弹幕版视频**并自动上传。 -- **硬件要求极低**:无需GPU,只需最基础的单核CPU搭配最低的运存即可完成录制,弹幕渲染,上传等等全部过程,无最低配置要求,10年前的电脑或服务器依然可以使用! -- **( :tada: NEW)自动渲染字幕**(如需使用本功能,则需保证有 Nvidia 显卡):采用 OpenAI 的开源模型 [`whisper`](https://github.com/openai/whisper),自动识别视频内语音并转换为字幕渲染至视频中。 -- **( :tada: NEW)自动切片上传**:根据弹幕密度计算寻找高能片段并切片,结合多模态视频理解大模型 [`GLM-4V-PLUS`](https://bigmodel.cn/dev/api/normal-model/glm-4) 自动生成有意思的切片标题及内容,并且自动上传。 - - -## Architecture diagram +Automatically monitors and records Bilibili live broadcasts and danmaku (including paid comments, gifts, etc.), converts danmaku according to resolution, recognizes speech and renders subtitles into videos, splits exciting fragments according to danmaku density, and generates interesting titles through video understanding models, automatically generates video covers using image generation models, and automatically posts videos and slices to Bilibili, compatible with the version without GPU, compatible with low-configuration servers and hosts. -项目架构流程如下: - -```mermaid -graph TD - User((用户))--record-->startRecord(启动录制) - startRecord(启动录制)--保存视频和字幕文件-->videoFolder[(Video 文件夹)] - - User((用户))--scan-->startScan(启动扫描 Video 文件夹) - videoFolder[(Video 文件夹)]<--间隔两分钟扫描一次-->startScan(启动扫描 Video 文件夹) - startScan <--视频文件--> whisper[whisperASR模型] - whisper[whisperASR模型] --生成字幕-->parameter[查询视频分辨率] - subgraph 启动新进程 - parameter[查询分辨率] -->ifDanmaku{判断} - ifDanmaku -->|有弹幕| DanmakuConvert[DanmakuConvert] - ifDanmaku -->|无弹幕| ffmpeg1[ffmpeg] - DanmakuConvert[DanmakuConvert] --根据分辨率转换弹幕--> ffmpeg1[ffmpeg] - ffmpeg1[ffmpeg] --渲染弹幕及字幕 --> Video[视频文件] - Video[视频文件] --计算弹幕密度并切片--> GLM[多模态视频理解模型] - GLM[多模态视频理解模型] --生成切片信息--> slice[视频切片] - end - - slice[视频切片] --> uploadQueue[(上传队列)] - Video[视频文件] --> uploadQueue[(上传队列)] +## Major features - User((用户))--upload-->startUpload(启动视频上传进程) - startUpload(启动视频上传进程) <--扫描队列并上传视频--> uploadQueue[(上传队列)] -``` +- **Fast**:Use the `pipeline` pipeline to process videos, in ideal conditions, the recording and live broadcast differ by half an hour, and the recording can be上线录播,**Currently the fastest version of Bilibili recording**! +- **( 🎉 NEW)Multi-architecture**:Compatible with amd64 and arm64 architectures! +- **Multiple rooms**:Simultaneously record the content of multiple live broadcast rooms and danmaku files (including normal danmaku, paid danmaku, and gift-up-ship information). +- **Small memory usage**:Automatically delete locally uploaded videos, saving space. +- **Template**:No complex configuration, ready to use, automatically fetch related popular tags through the Bilibili search suggestion interface. +- **Detect and merge segments**:For video stream segments caused by network issues or live broadcast connection issues, it can automatically detect and merge them into complete videos. +- **Automatically render danmaku**:Automatically convert xml to ass danmaku file, the danmaku conversion tool library has been open source [DanmakuConvert](https://github.com/timerring/DanmakuConvert) and rendered to the video to form **danmaku version video** and automatically upload. +- **Low hardware requirements**:No GPU required, only the most basic single-core CPU and the lowest memory can complete the recording, danmaku rendering, upload, etc. All processes, no minimum configuration requirements, 10-year-old computers or servers can still be used! +- **( :tada: NEW)Automatically render subtitles**:Use the OpenAI open source model `whisper`, automatically identify the speech in the video and convert it to subtitles, and render it to the video. +- **( :tada: NEW)Auto-slice upload**:Calculate the danmaku density and find the high-energy fragments, the auto-slice tool library has been open source [auto-slice-video](https://github.com/timerring/auto-slice-video), combine the multi-modal video understanding large model to automatically generate interesting slice titles and content, and automatically upload, currently supported models: + - `GLM-4V-PLUS` + - `Gemini-2.0-flash` + - `Qwen-2.5-72B-Instruct` +- **( :tada: NEW)Persistent login/download/upload video (supports multi-part posting)**:[bilitool](https://github.com/timerring/bilitool) has been open source, implements persistent login, download video and danmaku (including multi-part)/upload video (can post multi-part), query posting status, query detailed information, etc., one-click pip installation, can be operated using the command line cli, and can also be used as an api call. +- **( :tada: NEW)Auto-loop multi-platform live streaming**:The tool has been open source [looplive](https://github.com/timerring/looplive) is a 7 x 24 hours fully automatic **loop multi-platform live streaming** tool. +- **( :tada: NEW)Generate style-transformed video covers**:Use the image-to-image multi-modal model to automatically obtain the video screenshot and upload the style-transformed video cover. + - `Minimax image-01` + - `Kwai Kolors` + - `Tencent Hunyuan` + - `Baidu ERNIE irag-1.0` + - `Stable Diffusion 3.5 large turbo` + - `Luma Photon` + - `Ideogram V_2` + - `Recraft` + - `Amazon Titan Image Generator V2` + +The project architecture process is as follows: + +![](https://cdn.jsdelivr.net/gh/timerring/scratchpad2023/2024/2025-04-10-17-08-35.png) \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 63ab177..8f2a12f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,31 +5,31 @@ layout: home hero: name: "bilive" text: "Official documentation" - tagline: 7 x 24 小时无人监守录制、渲染弹幕、识别字幕、自动切片、自动上传、兼容超低配机器,启动项目,人人都是录播员。 + tagline: 7 x 24 hours unattended recording, rendering danmaku, recognizing subtitles, automatic slicing, automatic uploading, compatible with low-configuration machines, start the project, then everyone can be a recorder. actions: - theme: brand - text: 现在开始 + text: Start now link: /getting-started - theme: alt - text: 在 GitHub 上查看 + text: View on GitHub link: https://github.com/timerring/bilive features: - - title: 速度快 - details: 采用 pipeline 流水线处理视频,理想情况下录播与直播相差半小时以内,没有下播前就上传录播! - - title: 占用小 - details: 同时录制多个直播间直播以及弹幕(包含普通弹幕,付费弹幕以及礼物上舰等信息),极小的空间也能运行。 - - title: 模版化 - details: 无需复杂配置,开箱即用,(🎉NEW) 通过 b 站搜索建议接口自动抓取相关热门标签。 - - title: (🎉NEW) 自动切片上传 - details: 根据弹幕密度计算寻找高能片段并切片,结合多模态视频理解大模型 GLM-4V-PLUS 自动生成有意思的切片标题及内容,并且自动上传。 - - title: 多模式 - details: 除了 pipeline 模式,还支持 append 以及 merge 模式,对于网络问题或者直播连线导致的视频流分段,能够自动检测合并成为完整视频。 - - title: fine tune 渲染弹幕 - details: 自动转换 xml 为 ass 弹幕文件并且渲染到视频中形成有弹幕版视频并自动上传。根据不同分辨率的视频有 fine tune 的渲染参数。 - - title: 硬件要求低 - details: 即使无 GPU ,只用最基础的单核 CPU 搭配最低的运存即可完成录制,弹幕渲染,上传等等全部过程,无最低配置要求,10 年前的电脑或服务器依然可以使用! - - title: (🎉NEW) 自动渲染字幕(需要Nvidia 显卡) - details: 采用 OpenAI 的开源模型 whisper ,自动识别视频内语音并转换为字幕渲染至视频中。 + - title: Fast + details: Using pipeline to process videos, the recording and live broadcast difference is half an hour, and the recording can be uploaded before the broadcast ends! + - title: Small Occupancy + details: Simultaneously record multiple live broadcasts and danmaku (including normal danmaku, paid danmaku, and gift ship information), and run in a small space. + - title: Template + details: No complex configuration, ready to use, (🎉NEW) automatically fetch related popular tags through the bilibili search suggestion interface. + - title: (🎉NEW) Automatic slicing upload + details: Calculate the bullet density to find high-energy fragments and slice them, combine the multi-modal video understanding model GLM-4V-PLUS to automatically generate interesting slice titles and content, and upload them. + - title: Multi-mode + details: In addition to the pipeline mode, it also supports append and merge modes, and can automatically detect and merge video streams that are segmented due to network issues or live connection issues. + - title: Fine-tune rendering danmaku + details: Automatically convert xml to ass danmaku file and render it to the video to form a video with danmaku, and upload it automatically. There are fine-tune rendering parameters for different video resolutions. + - title: Low hardware requirements + details: Even without a GPU, you can complete the recording, danmaku rendering, and uploading process with the most basic single-core CPU and the lowest memory, and there is no minimum configuration requirement. 10-year-old computers or servers can still be used! + - title: (🎉NEW) Automatic rendering subtitles (requires Nvidia GPU) + details: Use the open-source model whisper from OpenAI to automatically recognize the audio in the video and convert it to subtitles and render it to the video. --- diff --git a/docs/install-questions.md b/docs/install-questions.md index cfef284..0b2181e 100644 --- a/docs/install-questions.md +++ b/docs/install-questions.md @@ -1,41 +1,33 @@ -# 安装常见问题 +# Installation common issues -> 如果没有找到遇到的问题,请及时在 [issues](https://github.com/timerring/bilive/issues/new/choose) 中提出。 +> If you don't find the problem you encountered, please submit it in [issues](https://github.com/timerring/bilive/issues/new/choose). ## OSError: sndfile library not found Reference: https://github.com/timerring/bilive/issues/106 -解决方案:安装对应的库即可 `apt-get install libsndfile1`。 - -## Error /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34’ not found - -Reference: https://blog.csdn.net/huazhang_001/article/details/128828999 - -尽量使用 22.04+ 的版本,更早版本的 ubuntu 自带 gcc 版本无法更新至 biliup-rs 所需版本。 - -解决方案:手动更新版本,参照链接操作即可。 +Solution: Install the corresponding library `apt-get install libsndfile1`. ## requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) https://stackoverflow.com/questions/70379603/python-script-is-failing-with-connection-aborted-connectionreseterror104 -众所周知的网络环境原因 +Known network environment reasons -解决方案:proxy。 +Solution: proxy. ## ERROR: Could not find a version that satisfies the requirement triton==3.1.0 (from versions: none) ERROR: No matching distribution found for triton==3.1.0 From [issue 168](https://github.com/timerring/bilive/issues/168) -根据 https://github.com/triton-lang/triton/issues/1057 确实可能存在这样的问题。 +According to https://github.com/triton-lang/triton/issues/1057, there may be such a problem. -解决方案:我查 pypi 里已经更新了 triton 3.1.0 版本:https://pypi.org/project/triton/#history 可以考虑升级一下 pip,或者直接从 huggingface 上拉 whl 安装也没问题。测试机器版本 linux python3.10.12 pip 下是没问题的。 +Solution: I checked that the pypi library has updated the triton 3.1.0 version: https://pypi.org/project/triton/#history, you can consider upgrading pip, or directly pull the whl installation from huggingface, it is not a problem. The test machine version is linux python3.10.12 pip, it is not a problem. -> 另外,triton 是一个推理的库,如果不需要用到 whisper 生成字幕的话,不装它也可以。 +> Also, triton is a library for inference, if you don't need to use whisper to generate subtitles, you can also not install it. ## ModuleNotFoundError: No module named 'fcntl' -文件锁 `fcntl` 模块不支持 windows,有一些替代方式,但是最佳的解决方法就是使用 WSL 运行本项目。 +The file lock `fcntl` module does not support windows, there are some alternative ways, but the best solution is to use WSL to run this project. -解决方案:使用 WSL 运行本项目。 \ No newline at end of file +Solution: Use WSL to run this project. \ No newline at end of file diff --git a/docs/installation.md b/docs/installation.md index 1cd8f61..06b61b3 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,151 +1,259 @@ # Quick start -## Mode -首先介绍本项目三种不同的处理模式: -1. `pipeline` 模式(默认): 目前最快的模式,需要 GPU 支持,最好在 `blrec` 设置片段为半小时以内,asr 识别和渲染并行执行,分 p 上传视频片段。 + +> [!NOTE] +> If you are a windows user, please use WSL to run this project. + +### Mode + +First, introduce the three different processing modes of this project: (The following description is based on the asr_method="deploy" situation, if you fill in "none" or "api", it does not involve GPU, and you can ignore the description of GPU.) +1. `pipeline` mode (default): The fastest mode, requires GPU support, it is recommended to set the segment in `blrec` to half an hour or less, asr recognition and rendering are executed in parallel, and the video segments are uploaded in p. ![](https://cdn.jsdelivr.net/gh/timerring/scratchpad2023/2024/2024-12-11-17-33-15.png) -2. `append` 模式: 基本同上,但 asr 识别与渲染过程串行执行,比 pipeline 慢预计 25% 左右,对 GPU 显存要求较低,兼顾硬件性能与处理上传效率。 +2. `append` mode: Basically the same as above, but the asr recognition and rendering process are executed serially, which is expected to be 25% slower than the pipeline, with lower GPU memory requirements, and a balance between hardware performance and processing upload efficiency. ![](https://cdn.jsdelivr.net/gh/timerring/scratchpad2023/2024/2024-12-11-19-07-12.png) -3. `merge` 模式: 等待所有录制完成,再进行识别渲染合并过程,上传均为完整版录播(非分 P 投稿),等待时间较长,效率较慢,适合需要上传完整录播的场景。 +3. `merge` mode: Wait for all recordings to complete, then perform the recognition and rendering merging process, the uploads are all complete versions of the recordings (non-P submissions), the waiting time is longer, the efficiency is slower, and it is suitable for scenarios that need to upload complete recordings. ![](https://cdn.jsdelivr.net/gh/timerring/scratchpad2023/2024/2024-12-11-19-08-58.png) > [!IMPORTANT] -> 凡是用到 GPU 均需保证 GPU 显存大于运行程序所需 VRAM,具体计算 VRAM 方法可以参考[该部分](./models.md#计算-vram-需求)。 +> All GPU usage requires that the GPU memory be greater than the VRAM required to run the program, the specific calculation method of VRAM can be referred to [this part](https://timerring.github.io/bilive/models.html#计算-vram-需求)。 -## Installation(有 GPU 版本) +### Installation -> 是否有 GPU 以 `nvidia-smi` 显示 nvidia GPU 驱动以及 `nvcc -V` 显示 `CUDA` 版本号为准。如果未配置显卡驱动或未安装 `CUDA`,即使有 GPU 也无法使用,而会使用 CPU 推理(不推荐,可根据自身硬件条件判断是否尝试 CPU 推理)。 +> [!TIP] +> If you are a windows user, please use WSL to run this project. -> [!NOTE] -> 如果你是 windows 用户,请使用 WSL 运行本项目。 +#### 0. clone project + +Since the project introduces my submodule [DanmakuConvert](https://github.com/timerring/DanmakuConvert), [bilitool](https://github.com/timerring/bilitool) and [auto-slice-video](https://github.com/timerring/auto-slice-video), it is recommended to clone the project and update the submodules. + +```bash +git clone --recurse-submodules https://github.com/timerring/bilive.git +``` + +If you do not clone the project using the above method, please update the submodules: + +```bash +git submodule update --init --recursive +``` -### 1. 安装依赖(推荐先 `conda` 创建虚拟环境) +#### 1. Install dependencies (recommended to create a virtual environment) ``` cd bilive pip install -r requirements.txt ``` -此外请根据各自的系统类型安装对应的 [`ffmpeg`](https://www.ffmpeg.org/download.html),例如 [ubuntu 安装 ffmpeg](https://gcore.com/learning/how-to-install-ffmpeg-on-ubuntu/)。 +Please install the corresponding [`ffmpeg`](https://www.ffmpeg.org/download.html) according to your system type, for example, [install ffmpeg on ubuntu](https://gcore.com/learning/how-to-install-ffmpeg-on-ubuntu/). -[常见问题收集](./install-questions) +[Common issues collection](https://timerring.github.io/bilive/install-questions.html) -### 2. 设置环境变量用于保存项目根目录 +#### 2. Configure parameters -``` -./setPath.sh && source ~/.bashrc -``` +##### 2.1 whisper speech recognition (rendering subtitle function) -### 3. 配置 whisper 模型 +> [!TIP] +> - The configuration related to speech recognition is in the `[asr]` section of the `bilive.toml` file. +> - `asr_method` defaults to none, meaning no speech subtitle recognition. + +##### 2.1.1 Use api method + +Set the `asr_method` parameter in the `bilive.toml` file to `api`, then fill in the `WHISPER_API_KEY` parameter with your [API Key](https://console.groq.com/keys). + +This project uses the `whisper-large-v3-turbo` model provided by groq for free tier, with an upload limit of 40 MB (approximately half an hour), so if you need to use the api recognition method, please adjust the video recording segment to 30 minutes (the default is 30 minutes). In addition, the free tier request limit is 7200 seconds/20 times/hour, 28800 seconds/2000 times/day. If you have more needs, welcome to upgrade to the dev tier, more information can be found on the [groq official website](https://console.groq.com/docs/rate-limits). -项目默认采用 [`small`](https://openaipublic.azureedge.net/main/whisper/models/9ecf779972d90ba49c06d968637d720dd632c55bbf19d441fb42bf17a411e794/small.pt) 模型,请点击下载所需文件,并放置在 `src/subtitle/models` 文件夹中。 +##### 2.1.2 Deploy locally (requires NVIDIA GPU) + +Set the `asr_method` parameter in the `bilive.toml` file to `deploy`, then download the required model files and place them in the `src/subtitle/models` folder. + +The project defaults to using the [`small`](https://openaipublic.azureedge.net/main/whisper/models/9ecf779972d90ba49c06d968637d720dd632c55bbf19d441fb42bf17a411e794/small.pt) model, please click to download the required files and place them in the `src/subtitle/models` folder. > [!TIP] -> 使用该参数模型至少需要保证有显存大于 2.7GB 的 GPU,否则请使用其他参数量的模型。 -> + 更多模型请参考 [whisper 参数模型](./models) 部分。 -> + 更换模型方法请参考 [更换模型方法](./models.md#更换模型方法) 部分。 +> + Please ensure that the NVIDIA GPU driver is installed correctly `nvidia-smi` `nvcc -V`, and the CUDA core can be called `print(torch.cuda.is_available())` to return `True`. If the GPU driver is not configured or `CUDA` is not installed, even if there is a GPU, it will not be used, and the CPU will be used for inference, which consumes a lot of CPU computing resources, not recommended, if the CPU hardware conditions are good, you can try. +> + The model with this parameter requires at least 2.7GB of GPU memory, otherwise please use other parameter models. +> + More models can be found in the [whisper parameter model](https://timerring.github.io/bilive/models.html) section. +> + The method of changing models can be found in the [changing model method](https://timerring.github.io/bilive/models.html#changing-model-method) section. +##### 2.2 MLLM(auto slice title generation) -### 4. biliup-rs 登录 +> [!TIP] +> - The configuration related to automatic slicing is in the `[slice]` section of the `bilive.toml` file. +> - `auto_slice` defaults to false, meaning automatic slicing is not performed. -首先按照 [biliup-rs](https://github.com/biliup/biliup-rs) 登录b站,登录脚本在 `src/utils/biliup` ,登录产生的`cookies.json`保留在该文件夹下即可。 +MLLM is mainly used for automatic slice title generation after slicing, this feature is default closed, if you need to open it, please set the `auto_slice` parameter to `true` and write your own prompt, other configurations are as follows: +- `slice_duration` set the slice duration in seconds (not recommended to exceed 180 seconds). +- `slice_num` set the number of slices. +- `slice_overlap` set the slice overlap duration. The slice is processed using the sliding window method, details can be found in [auto-slice-video](https://github.com/timerring/auto-slice-video) +- `slice_step` set the slice step. +- `min_video_size` set the minimum video size to be sliced, to prevent slicing short fragments due to connection issues or network波动. -然后同样通过 `bilitool login` 扫码登录(biliup 的 list 对应 api 已经失效,因此我写了 [`bilitool`](https://github.com/timerring/bilitool) 工具作为替换)。 +Next, configure the `mllm_model` parameter related to the model and the corresponding api-key, please register an account and apply for the corresponding api key by yourself, fill in the corresponding parameters, please note that only the model set in the `mllm_model` parameter will take effect. -[常见问题收集](./biliup) +| Company | Alicloud | zhipu | Google | +|----------------|-----------------------|------------------|-------------------| +| Name | Qwen-2.5-72B-Instruct | GLM-4V-PLUS | Gemini-2.0-flash | +| `mllm_model` | `qwen` | `zhipu` | `gemini` | +| `API key` | [qwen_api_key](https://bailian.console.aliyun.com/?apiKey=1) | [zhipu_api_key](https://www.bigmodel.cn/invite?icode=shBtZUfNE6FfdMH1R6NybGczbXFgPRGIalpycrEwJ28%3D) | [gemini_api_key](https://aistudio.google.com/app/apikey) | -### 5. 启动自动录制 -```bash -./record.sh +#### 2.3 Image Generation Model(auto generate video cover) + +> [!TIP] +> - The configuration related to automatic video cover generation is in the `[cover]` section of the `bilive.toml` file. +> - `generate_cover` defaults to false, meaning automatic video cover generation is not performed. + +Use the image-to-image multimodal model to automatically obtain the video screenshot and upload the video cover after style transformation, if you need to use this feature, please set the `generate_cover` parameter to `true` and write your own prompt, note that some models only support English, the following parameters need to be configured: image_gen_model and the corresponding api key, please register an account and apply for the corresponding api key by yourself, fill in the corresponding parameters, please note that only the model set in the `image_gen_model` parameter will take effect. + +| Company | Model Name | `image_gen_model` | `API Key` | +|--------------|--------------------------------|-------------------|---------------------------------------------------------------------------------| +| Minimax | image-01 | `minimax` | [minimax_api_key](https://platform.minimaxi.com/user-center/basic-information/interface-key) | +| Kwai | Kolors | `siliconflow` | [siliconflow_api_key](https://cloud.siliconflow.cn/i/3Szr5BVg) | +| Tencent | Hunyuan | `tencent` | [tencent_secret_id and tencent_secret_key](https://console.cloud.tencent.com/cam/capi) | +| Baidu | ERNIE irag-1.0 | `baidu` | [baidu_api_key](https://console.bce.baidu.com/iam/key/list) | +| Stability AI | Stable Diffusion 3.5 large turbo | `stability` | [stability_api_key](https://platform.stability.ai/account/keys) | +| Luma Labs | Photon | `luma` | [luma_api_key](https://lumalabs.ai/api/keys) | +| Ideogram | Ideogram V_2 | `ideogram` | [ideogram_api_key](https://ideogram.ai/manage-api) | +| Recraft | Recraft V3 | `recraft` | [recraft_api_key](https://www.recraft.ai/profile/api) | +| Amazon | Titan Image Generator V2 | `amazon` | [aws_access_key_id and aws_secret_access_key](https://aws.amazon.com/console/) | + +#### 3. Configure upload parameters + +Customize the relevant configuration in the `bilive.toml` file, map the keywords to `{artist}`、`{date}`、`{title}`、`{source_link}`, please combine and customize the template by yourself: + +- `title` title template. +- `description` description template. +- `gift_price_filter = 1` means filtering gifts priced below 1 yuan. +- `reserve_for_fixing = false` means that if the video appears to be incorrect, the video will not be retained for repair after the retry fails, it is recommended to set false for users with limited hard disk space. +- `upload_line = "auto"` means automatically detecting the upload line and uploading, if you need to specify a fixed line, you can set it to `bldsa`、`ws`、`tx`、`qn`、`bda2`. + +#### 4. Configure recording parameters + +> [!IMPORTANT] +> Please do not modify any configuration related to paths, otherwise the upload module will be unavailable. + +> The recording module uses the third-party package `blrec`, the parameter configuration is in the `settings.toml` file, and you can also configure it in the corresponding port visualization page after the recording starts. Quick start only introduces the key configuration, other configurations can be understood by referring to the configuration items in the page, and support hot modification. + +- The addition of rooms follows the format corresponding to `[[tasks]]` in the file. +- The default recording quality of the recording module is super-high quality without login. If you need to login, please fill in the `SESSDATA` parameter value from the `cookie.json` file (see step 5) to the `cookie` part of `[header]`, the format is `cookie = "SESSDATA=XXXXXXXXXXX"`, after logging in, you can record higher quality video. (Recommended not to login) +- `duration_limit` means the recording duration, if you use the whisper api recognition, please control the segmentation within 1800 seconds, otherwise there is no limit. + +#### 5. bilitool login (persistent login, this step only needs to be executed once) + +> For docker deployment, this step can be ignored, because `docker logs` can print the QR code in the console, and you can scan the QR code to login directly, the following content is for source code deployment. + +##### 5.1 Method 1: Login via cookie + +Generally, the log file does not print the QR code effect, so this step needs to be installed in advance on the machine: + +``` +pip install bilitool +bilitool login --export +# Then use the app to scan the QR code to login, the cookie.json file will be automatically exported ``` +Leave the login cookie.json file in the root directory of this project, and it will be deleted after the `./upload.sh` starts. -[常见问题收集](./record) +##### 5.2 Method 2: Login via submodule -### 6. 启动自动上传 +Or you can login in the submodule, the way is as follows: -请先确保你已经完成`步骤 3`,正确下载并放置了模型文件。 +``` +cd src/upload/bilitool +python -m bilitool.cli login +# Then use the app to scan the QR code to login +``` -#### 6.1 启动扫描渲染进程 +[Common issues collection](https://timerring.github.io/bilive/biliup.html) -输入以下指令即可检测已录制的视频并且自动合并分段,自动进行弹幕转换,字幕识别与渲染的过程: +#### 6. Start automatic recording + +> [!IMPORTANT] +> Using the default password and exposing the port on a server with a public IP has a potential risk of exposing the cookie, so **not recommended** to map the port on a server with a public IP. +> - If you need to use https, you can consider using an openssl self-signed certificate and adding the parameters `--key-file path/to/key-file --cert-file path/to/cert-file` in `record.sh`. +> - You can limit the inbound IP rules of the server port or use nginx etc. to restrict access. + +Before starting, please set the password for the recording front-end page, and save it in the `RECORD_KEY` environment variable, `your_password` consists of letters and numbers, and is at least 8 digits, at most 80 digits. +- Temporary setting password `export RECORD_KEY=your_password`。(Recommended) +- Persistent setting password `echo "export RECORD_KEY=your_password" >> ~/.bashrc && source ~/.bashrc`,where `~/.bashrc` can be modified according to the shell you are using. ```bash -./scan.sh +./record.sh ``` -[常见问题收集](./scan) +[Common issues collection](https://timerring.github.io/bilive/record.html) -#### 6.2 启动自动上传进程 +#### 7. Start automatic upload + +> If you use the deploy method to locally deploy whisper, please ensure that you have correctly downloaded and placed the corresponding model files, and ensure that CUDA is available. ```bash ./upload.sh ``` -[常见问题收集](./upload) +[Common issues collection](https://timerring.github.io/bilive/upload.html) +#### Log information -### 7. 查看执行日志 +The corresponding execution logs can be viewed in the `logs` folder, if there are any issues, please submit them in [`issue`](https://github.com/timerring/bilive/issues/new/choose), and provide [debug] level logs if there are any exceptions. -相应的执行日志请在 `logs` 文件夹中查看,如果有问题欢迎在 [`issue`](https://github.com/timerring/bilive/issues/new/choose) 中提出。 ``` -logs # 日志文件夹 -├── blrec # blrec 录制日志 +logs # Log folder +├── record # blrec recording log │ └── ... -├── scan # scan 处理日志 +├── scan # scan processing log [debug] level │ └── ... -├── upload # upload 上传日志 +├── upload # upload log [debug] level │ └── ... -└── runtime # 每次执行的日志 +└── runtime # runtime log [info] level └── ... ``` +### Docker running -## Installation(无 GPU 版本) -无 GPU 版本过程基本同上,可以跳过步骤 3,需要注意在执行步骤 5 **之前**完成以下设置将确保完全用 CPU 渲染视频弹幕。 +The configuration reference is the same as above, the login method is more concise, after starting, the login QR code will be printed in the log, scan the QR code to login. -1. 请将 `src/config.py` 文件中的 `GPU_EXIST` 参数设置为 `False`。(若不置为 `False` 且则会使用 CPU 推理,不推荐,可自行根据硬件条件进行尝试。) -2. 将 `MODEL_TYPE` 调整为 `merge` 或者 `append`。 +#### No GPU version -## Docker 运行 +amd64 and arm64 versions have been built, and the architecture will be automatically selected. -也可以直接拉取 docker 镜像运行,默认 latest。守护进程是 upload,而 record 以及 scan 需要在配置后手动启动,相关配置以及启动流程从 3.2 开始即可,此版本 docker 镜像无 GPU 配置。 +`your_record_password` is the password for the recording page, please set it yourself, the shortest is 8, the longest is 80. -> [!IMPORTANT] -> 如果不需要使用可视化页面可以忽略以下提醒: -> - 不推荐在有公网 ip 的服务器上直接暴露 22333 端口访问管理页面,如果使用请自行限制端口入站 ip 规则或者采用 nginx 等反向代理配置密钥限制他人访问。 -> - 管理页面主要针对 record 模块,只有手动运行 record 后(步骤5)才能访问到管理页面。 +```bash +docker run -itd \ + -v your/path/to/bilive.toml:/app/bilive.toml \ + -v your/path/to/settings.toml:/app/settings.toml \ + -v your/path/to/Videos:/app/Videos \ + -v your/path/to/logs:/app/logs \ + --name bilive_docker \ + -e RECORD_KEY=your_record_password \ + -p 22333:2233 \ + ghcr.io/timerring/bilive:0.3.0 +``` + +#### GPU version -### Docker ```bash sudo docker run \ -itd \ - --name bilive_docker \ + --gpus 'all,"capabilities=compute,utility,video"' \ + --name bilive_docker_gpu \ -p 22333:2233 \ - timerring/bilive:0.2.10 + ghcr.io/timerring/bilive-gpu:0.3.0 ``` ### Docker Compose -#### 使用镜像 +See [Installation](https://bilive.timerring.com/installation.html) for the adjustment method of `compose.yml`. + +#### Use image + +Default CPU latest version, if you need to use the GPU version, please adjust it in `compose.yml` yourself. -默认 CPU latest version,如需使用 GPU 版本,请将 `image: ghcr.io/timerring/bilive:latest` 修改为 `image: ghcr.io/timerring/bilive-gpu:latest`。 ```bash docker compose up -d ``` -#### 自行构建 - -相关配置已经写好,请自行将 `compose.yml` 3-6 行替换为: - -```yaml - build: - context: . - dockerfile: Dockerfile # Dockerfile-GPU - # image: ghcr.io/timerring/bilive:latest # ghcr.io/timerring/bilive-gpu:latest -``` +#### Self-build -然后执行以下命令: +Please adjust the relevant configuration in `compose.yml`, then execute the following command: ```bash docker build diff --git a/docs/models.md b/docs/models.md index 14a52cf..8926826 100644 --- a/docs/models.md +++ b/docs/models.md @@ -1,12 +1,12 @@ -# whisper 参数模型 +# whisper model parameters -本项目采用 [OpenAI 开源的 whisper 模型](https://github.com/openai/whisper)进行 Automatic Speech Recognition (ASR) 任务。 +This project uses the [OpenAI's open source whisper model](https://github.com/openai/whisper) for Automatic Speech Recognition (ASR) tasks. -## 模型信息 -模型基本参数参数及链接如下,注意 GPU 显存必须大于所需 VRAM: +## Model information +The basic parameters and links of the model are as follows, note that the GPU VRAM must be greater than the required VRAM: > [!TIP] -> 如果追求识别准确率,推荐使用参数量 `small` 及以上的模型。 +> If you pursue recognition accuracy, it is recommended to use models with parameters `small` or above. | Size | Parameters | Multilingual model | Required VRAM | |:------:|:----------:|:------------------:|:-------------:| @@ -17,20 +17,21 @@ | large | 1550 M | [`large`](https://openaipublic.azureedge.net/main/whisper/models/81f7c96c852ee8fc832187b0132e569d6c3065a3252ed18e56effd0b6a73e524/large-v2.pt) | ~10 GB | -## 计算 VRAM 需求 +## Calculate VRAM requirements -用 Nvidia 显卡加速 ffmpeg 渲染过程,每个任务所需的 VRAM 约为 180 MB。`whisper` 模型运行所需显存如上表所示。 -因此可以大约计算所需显存。 +Use Nvidia GPU to accelerate the rendering process of ffmpeg, each task requires approximately 180 MB of VRAM. The VRAM required for the `whisper` model is as shown in the table above. -以 `small` 模型为例: -+ 如果采用 `pipeline` 模式,由于并行运行,则运行至少需要 180 + 2620 = 2800 MB 显存。 -+ 如果采用 `append` 或者 `merge` 模式,则运行至少需要 2620 MB 显存。 +Therefore, you can roughly calculate the required VRAM. + +For example, using the `small` model: ++ If using the `pipeline` mode, since it runs in parallel, at least 180 + 2620 = 2800 MB of VRAM is required. ++ If using the `append` or `merge` mode, at least 2620 MB of VRAM is required. > [!WARNING] -> 请一定保证 GPU 显存大于计算结果,否则会爆显存,`RuntimeError: CUDA out of memory.`。 +> Please ensure that the GPU VRAM is greater than the calculated result, otherwise the VRAM will be exhausted, resulting in `RuntimeError: CUDA out of memory.` -## 更换模型方法 +## Change model method -1. 请将 `src/config.py` 文件中的 `Inference_Model` 参数设置为模型对应Size名称,如 `tiny`,`base`,`small`,`medium`,`large`。 -2. 将对应的模型文件下载,并放置在 src/subtitle/models 文件夹中。 -3. 重新运行 `./scan.sh` 脚本。 +1. Please set the `Inference_Model` parameter in the `bilive.toml` file to the corresponding model size name, such as `tiny`, `base`, `small`, `medium`, `large`. +2. Download the corresponding model file and place it in the `src/subtitle/models` folder. +3. Re-run the `./scan.sh` script. diff --git a/docs/record.md b/docs/record.md index 01d3409..0ebc544 100644 --- a/docs/record.md +++ b/docs/record.md @@ -1,72 +1,73 @@ -# record 常见问题 +# record common issues -> 如果没有找到遇到的问题,请及时在 [issues](https://github.com/timerring/bilive/issues/new/choose) 中提出。 +> If you don't find the problem you encountered, please submit it in [issues](https://github.com/timerring/bilive/issues/new/choose). -## 录制 cookies 用处是什么 +## What is the purpose of recording cookies? -主要用于录制时验证账号,B 站默认未登录状态下最高画质参数为 250 (超清),如果想要录制更高参数的画质视频,需要登录账号,请在配置文件中指定账号的 cookies。 +This is used to verify the account when recording, and the default maximum quality parameter for Bilibili when not logged in is 250 (super-clear), if you want to record a higher quality video, you need to log in to the account, please specify the account's cookies in the configuration file. -获取 cookies 的方法可以参考:https://zmtblog.xdkd.ltd/2021/10/06/Get_bilibili_cookie/ - -可以在项目目录下的 `settings.toml` 文件中指定 cookies,也可以在录制面板的 `http://localhost:2233/settings` (默认启动端口 2233,可以自行修改)中的 settings 填写 cookies。 +You can specify cookies in the `settings.toml` file in the project directory, or fill in cookies in the settings of the recording panel `http://localhost:2233/settings` (the default port is 2233, you can modify it yourself). ``` [header] user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36" cookie = "xxxx" ``` -重启 record 后,选择更高画质录制即可。 +After restarting record, select a higher quality recording. > [!TIP] -> 不建议使用 cookies 登录 blrec 录制,因为 B 站官方有时会风控,导致录制全部失败。此外,cookies 登录后,录制效果不太稳定,可能会出现抓取不到对应流的情况。 +> It is not recommended to use cookies to login to blrec recording, because Bilibili's official sometimes blocks the recording, causing the recording to fail. In addition, after logging in with cookies, the recording effect is not stable, and there may be a situation where the corresponding stream is not captured. > -> 因此个人更推荐 **不使用 cookies 的默认录制 250 超清画质**,目前没有获取流的问题。 +> Therefore, I personally recommend **not using cookies for default recording of 250 super-clear quality**, currently there is no problem with getting the stream. -## 如果端口已经占用 -如果端口冲突,请在 `record.sh`启动脚本中重新设置端口 `port`并重启(默认端口号 2233)。 +## If the port is already occupied +If the port is conflicted, please reset the port `port` in the `record.sh` startup script and restart (the default port is 2233). -## 如何调整目录 -录制部分采用的是 `blrec`,在 `settings.toml` 中设置视频存放目录、日志目录,也可启动后在 blrec 前端界面即`http://localhost:port` 中进行设置。详见 [blrec](https://github.com/acgnhiki/blrec)。 +## How to adjust the directory +The recording part uses `blrec`, set the video storage directory and log directory in `settings.toml`, or set it in the blrec frontend interface即`http://localhost:port` after starting. For details, see [blrec](https://github.com/acgnhiki/blrec). > [!TIP] -> 如果要调整目录,请相应调整 `src/config.py` 中的值。 +> Don't recommend adjust the directory, which will cause the upload module to be unavailable. -## 完全无法获取直播流信息 +## The stream information cannot be obtained ``` [2023-06-15 13:07:09,375] [DEBUG] [parse] [xxxxxxxx] Error occurred while parsing stream: ValueError('12 is not a valid CodecID') Traceback (most recent call last): ``` -通常这种情况发生在录制主播在海外的情况,由于海外直播流编码是 HEVC,但是只支持处理 AVC 编码,因此无法获取直播流信息。 -参考 issue:https://github.com/BililiveRecorder/BililiveRecorder/issues/470 +This usually happens when the recording host is overseas, because the overseas live stream encoding is HEVC, but it only supports processing AVC encoding, so it cannot obtain the live stream information. +Reference issue: https://github.com/BililiveRecorder/BililiveRecorder/issues/470 -解决方法:切换录制编码,选择 hls 编码,然后重新录制。 +Solution: Switch the recording encoding, select hls encoding, and then re-record. -## 添加房间失败 +## Failed to add room ``` [2024-11-22 14:29:04,304] [ERROR] [task_manager] Failed to add task xxxxxxxxx due to: KeyError('sex') [2024-11-22 14:29:04,305] [CRITICAL] [exception_handler] KeyError ``` -通常是短时间内添加该房间次数过多,api 请求限制了,可以等几分钟再添加该房间,也可以打开 port 对应面板后在面板里手动添加。 +This usually happens when the recording host is overseas, because the overseas live stream encoding is HEVC, but it only supports processing AVC encoding, so it cannot obtain the live stream information. +Reference issue: https://github.com/BililiveRecorder/BililiveRecorder/issues/470 + +Solution: Switch the recording encoding, select hls encoding, and then re-record. -## 已经在录制状态,重启项目又无法正常工作 +## The project is already in the recording state, but it cannot work after restarting -重启需要等约半分钟,因为它添加房间并且验证启动弹幕服务器需要一点时间,可以尝试关闭该房间录制,再打开。 +Restarting requires waiting for about half a minute, because it adds a room and verifies the start of the danmaku server, so it can try to close the room recording and then open it again. -## 录制的弹幕 xml 以及 jsonl 为空 +## The danmaku xml and jsonl are empty From [issue 123](https://github.com/timerring/bilive/issues/123) -请填写超过 7 位数的 roomid,84074 是 b 站方便推广的一个短链接,用户跳转是直接映射到真实roomid 去的,真正的 roomid 是申请开播权限时分配的,应该是 7~9 位数字。 +Please fill in a roomid with more than 7 digits, 84074 is a short link for Bilibili to promote, the user jumps directly to the real roomid, the real roomid is assigned when applying for broadcast permission, which should be 7~9 digits. -**弹幕服务器是无法通过短链接获取弹幕的。因为短链接只起到映射跳转作用**。 +**The danmaku server cannot obtain the danmaku through the short link. Because the short link only plays a mapping jump role.** -解决方法:在移动端分享里面`图片分享`方式分享直播,然后 b 站移动端会自动生成一个带有真正 roomid 的图片。填写该 roomid 即可。 +Solution: Share the live broadcast in the `图片分享` way in the mobile share, and then Bilibili mobile will automatically generate an image with the real roomid. Fill in this roomid. -## 添加直播间出错 `aiohttp.client_exceptions.ClientResponseError: 412 ` +## Failed to add room `aiohttp.client_exceptions.ClientResponseError: 412 ` From [issue 148](https://github.com/timerring/bilive/issues/148) @@ -74,12 +75,10 @@ From [issue 148](https://github.com/timerring/bilive/issues/148) aiohttp.client_exceptions.ClientResponseError: 412, message='Precondition Failed', ``` -录制部分我采用的是 [blrec](https://github.com/acgnhiki/blrec),根据 [相应的issue](https://github.com/acgnhiki/blrec/pull/264) 情况疑似被风控了。这是请求的[B站 api 报错 412 情况](https://github.com/SocialSisterYi/bilibili-API-collect/issues/872)。 - -解决方法:我建议添加或者更换 UA,还可以考虑添加 cookies,等待几分钟执行 `./record.sh` 重试。或者用 docker 单独部署 blrec 也可以。 +The recording part I use [blrec](https://github.com/acgnhiki/blrec), according to the [corresponding issue](https://github.com/acgnhiki/blrec/pull/264) it seems to be blocked by risk control. This is the [Bilibili API error 412 situation](https://github.com/SocialSisterYi/bilibili-API-collect/issues/872). -## `http://localhost:2233/settings` 网页无法访问 +Solution: I recommend adding or replacing UA, you can also consider adding cookies, wait a few minutes to execute `./record.sh` to retry. Or use docker to deploy blrec separately. -管理页面主要针对 record 模块,而 docker run 时默认守护进程是 upload,并且只是映射了端口,实际 2233 端口没有程序在运行,因为 record 进程并没有启动。 +## `http://localhost:2233/settings` webpage cannot be accessed -解决方法:进入 docker 后手动运行 record (步骤5)后访问管理页面。 \ No newline at end of file +The record process is not working, please check the log. \ No newline at end of file diff --git a/docs/reference.md b/docs/reference.md index dacdc50..3085e8b 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -1,6 +1,6 @@ ## Reference -- [biliup/biliup-rs](https://github.com/biliup/biliup-rs) -- [hihkm/DanmakuFactory](https://github.com/hihkm/DanmakuFactory) - [acgnhiki/blrec](https://github.com/acgnhiki/blrec) -- [OpenAI/whisper](https://github.com/OpenAI/whisper) \ No newline at end of file +- [OpenAI/whisper](https://github.com/OpenAI/whisper) +- [biliup/biliup-rs](https://github.com/biliup/biliup-rs) +- [hihkm/DanmakuFactory](https://github.com/hihkm/DanmakuFactory) \ No newline at end of file diff --git a/docs/scan.md b/docs/scan.md index 2b493ed..6494f4a 100644 --- a/docs/scan.md +++ b/docs/scan.md @@ -1,64 +1,64 @@ -# scan 常见问题 +# scan common issues -> 如果没有找到遇到的问题,请及时在 [issues](https://github.com/timerring/bilive/issues/new/choose) 中提出。 +> If you don't find the problem you encountered, please submit it in [issues](https://github.com/timerring/bilive/issues/new/choose). -## 关于渲染速率 +## About rendering speed -渲染速率主要与硬件以及弹幕数量有关,测试硬件的基本区间 2核 Xeon(R) Platinum 85 的 CPU 的渲染速率在 3 ~ 6 倍之间,也可使用 Nvidia GPU 加速,项目的测试显卡为 GTX1650,其渲染速率在 16 ~ 20 倍之间。 +The rendering speed mainly depends on the hardware and the number of danmaku. The basic test hardware is 2 cores Xeon(R) Platinum 85 CPU, the rendering speed is between 3 ~ 6 times, and can also use Nvidia GPU acceleration. The test graphics card is GTX1650, its rendering speed is between 16 ~ 20 times. -弹幕渲染具体时间可通过 `渲染速率x视频时长` 估算。 +The specific rendering time of danmaku can be estimated by `rendering speed x video duration`. -使用 Nvidia GPU 加速的相关参考: +Related references for using Nvidia GPU acceleration: + [Using FFmpeg with NVIDIA GPU Hardware Acceleration](https://docs.nvidia.com/video-technologies/video-codec-sdk/12.0/ffmpeg-with-nvidia-gpu/index.html) -+ [使用GPU为FFmpeg 加速](https://yukihane.work/li-gong/ffmpeg-with-gpu) ++ [Using GPU to accelerate FFmpeg](https://yukihane.work/li-gong/ffmpeg-with-gpu) -## 渲染速率为什么下降 +## Why does the rendering speed decrease? -长时间地使用 GPU,温度升高可能会导致 GPU 降频,从而导致渲染速率下降。可以通过 `nvidia-smi -q -d CLOCK` 查看 GPU 频率信息。 +Long-term use of GPU may cause the GPU to be downgraded due to temperature rise, resulting in a decrease in rendering speed. You can check the GPU frequency information by `nvidia-smi -q -d CLOCK`. -## requests 请求错误 +## requests request error ``` requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) ``` Reference: https://stackoverflow.com/questions/70379603/python-script-is-failing-with-connection-aborted-connectionreseterror104 -解决方案:网络问题,你应该知道怎么做。 +Solution: Network problem, you should know what to do. -## 字体信息错误 +## Font information error ``` Glyph 0x... not found, selecting one more font for (Microsoft YaHei, 400, 0) ``` Reference:https://github.com/timerring/bilive/issues/35 -解决方案:通常 ffmpeg 无法渲染表情,因此很多情况下关于表情的渲染都会报错,我已经通过一个通用正则滤除了 99% 的表情,当然可能会有其他奇怪的表情和字符,如果报错忽略即可,ffmpeg 会渲染为一个方框,不影响效果。 +Solution: Usually ffmpeg cannot render expressions, so many expressions will report errors, I have filtered out 99% of the expressions through a general regular expression, of course, there may be other strange expressions and characters, if the error is ignored, ffmpeg will render a square, which does not affect the effect. -## 渲染出来的弹幕和字幕为什么都是方框? +## Why are the rendered danmaku and subtitles a square? -这是字体缺失的问题,往往出现在手动部署过程中,我默认采用的是微软雅黑字体,在本项目的 assets 目录下有 msyh.ttf,安装它即可。docker 版本应该不会有这个问题,因为在 dockerfile 中已经完成了该过程。当然如果你想使用别的字体也可以在 DanmakuFactory 指令中转换时指定对应的字体。 +This is a font missing problem, often appearing in manual deployment, I default use Microsoft YaHei font, there is msyh.ttf in the assets directory of the project, install it. The docker version should not have this problem, because it has completed this process in the dockerfile. Of course, if you want to use other fonts, you can also specify the corresponding font in the DanmakuFactory instruction during conversion. -## 为什么又改回队列的方式渲染弹幕了 +## Why did you change back to the queue rendering method? -由于通常 nvidia 加速下的弹幕渲染速率为 10 ~ 15x,而 whisper 执行语音识别的速率为 5x,因此之前由 whisper 创建弹幕渲染的方式是完全行得通的,但是对于弹幕非常多的直播间来说(20分钟片段产生15400+条弹幕),渲染速率会下降到 2 ~ 4x,当新一轮 whisper 处理后的片段进行弹幕渲染时,会进一步使渲染速率下降,堆积超过 3 个并行的弹幕渲染进程,会由于显卡并发编码的数量限制而导致失败,此外还会存在爆显存的风险。因此,为了保证渲染的质量和程序的稳定性,我原改回列队的方式处理弹幕渲染。 +Due to the usually 10 ~ 15x rendering speed of danmaku under nvidia acceleration, and the speed of whisper executing speech recognition is 5x, so the previous way of creating danmaku rendering by whisper is completely feasible, but for live broadcasts with a large number of danmaku (20 minutes fragment produces 15400+ danmaku), the rendering speed will drop to 2 ~ 4x, when the new whisper processed fragment is rendered, the rendering speed will further decrease, and the number of accumulated parallel danmaku rendering processes will exceed 3, which will cause failure due to the limit of the number of concurrent encoding of the graphics card, in addition, there is a risk of out of memory. Therefore, in order to ensure the quality of rendering and the stability of the program, I originally changed back to the queue rendering method to process danmaku rendering. -## WSL 运行报错 ERROR:[Errno -2] Name or service not known +## WSL running error ERROR: [Errno -2] Name or service not known -主机名解析的问题,wsl 通常网络问题比较多。From [issue 159](https://github.com/timerring/bilive/issues/159) +The problem of host name resolution, wsl usually has more network problems. From [issue 159](https://github.com/timerring/bilive/issues/159) -解决方案:主要两个思路 -1. 可以按照内容检查一下网络:https://unix.stackexchange.com/questions/589683/wsl-dns-not-working-when-connected-to-vpn -2. 不用 record.sh 启动,直接在命令行终端里执行 blrec 然后浏览器访问 `http://localhost:2233` (default),按照https://blog.csdn.net/Yiang0/article/details/127780263 ,本机 Windows 可以直接通过 localhost 访问 WSL2,查看一下是否有正常运行的进程。 +Solution: There are two main ideas: +1. Check the network content: https://unix.stackexchange.com/questions/589683/wsl-dns-not-working-when-connected-to-vpn +2. Don't start with record.sh, directly execute blrec in the command line terminal, then browse to `http://localhost:2233` (default), according to https://blog.csdn.net/Yiang0/article/details/127780263, the local Windows can directly access WSL2 through localhost, check if there is a normal running process. -## 录制没有切片产生 +## No slice is produced during recording -> 首先检查 `src/config` 中的 `AUTO_SLICE` 是否为 `True`,如果为 `False`,则不会进行切片处理。 +> First check if `AUTO_SLICE` is `True`, if it is `False`, no slice processing will be performed. -通常默认设置,如果视频文件大小小于 200 MB,则不进行切片处理,这样做的目的主要是防止一些碎片化的片段也被切片上传,因为对于一个网络不佳或者经常连线的主播,一场直播可能会产生几十个片段,如果每两分钟或者三分钟的连线都要再切片一次,冗余的内容对观众来说观感不是很好,因此权衡之下我设置了一个 threshold 为 200 MB,确保足够长的片段才会被切片。 +By default, if the video file size is less than 200 MB, no slice processing will be performed, the purpose of this is mainly to prevent some fragmented fragments from being sliced and uploaded, because for a host with a poor network or often disconnected, a live broadcast may produce dozens of fragments, if every two minutes or three minutes of connection is sliced again, the redundant content is not good for the audience, so I set a threshold of 200 MB to ensure that only long enough fragments will be sliced. -解决方案:修改 `src/config` 中的 `MIN_VIDEO_SIZE` 数值为你所需要的限制,然后重新执行 `./scan.sh` 即可。 +Solution: Modify the `MIN_VIDEO_SIZE` value in `src/config` to the limit you need, then re-execute `./scan.sh` again. ## RuntimeError: CUDA error: no kernel image is available for execution on the device -日志显示你的 ubuntu 的 nvidia gpu 驱动和 cuda 版本可能存在不匹配的问题,不能正确调用 cuda 核心。 +The log shows that the nvidia gpu driver and cuda version of your ubuntu may not match, and the cuda core may not be correctly called. -解决方案:详细参考[这篇文章](https://zhuanlan.zhihu.com/p/466793485)。 \ No newline at end of file +Solution: Refer to [this article](https://zhuanlan.zhihu.com/p/466793485). \ No newline at end of file diff --git a/docs/test-hardware.md b/docs/test-hardware.md index ff0b36a..f0fd3d6 100644 --- a/docs/test-hardware.md +++ b/docs/test-hardware.md @@ -1,28 +1,35 @@ # Test hardware -## 测试硬件环境 1 (极低配置服务器) -+ OS: Ubuntu 22.04.4 LTS -+ CPU:2核 Intel(R) Xeon(R) Platinum 85 -+ GPU:无 -+ 内存:2G -+ 硬盘:40G -+ 带宽: 3Mbps -+ Python 版本: 3.10 - > [!TIP] -> 个人经验:若想尽可能快地更新视频,主要取决于上传速度而非弹幕渲染速度,因此建议网络带宽越大越好。 +> Personal experience: If you want to update the video as quickly as possible, the upload speed is more important than the speed of rendering the bullet screen. Therefore, it is recommended to have as large a network bandwidth as possible. +## Test hardware 1 (the alicloud server) ++ OS: Ubuntu 22.04.4 LTS ++ Architecture: x86_64 ++ CPU: 2-core Intel(R) Xeon(R) Platinum 85 ++ GPU: None ++ Memory: 2G ++ Disk: 40G ++ Bandwidth: 3Mbps ++ Python version: 3.10 -## 测试硬件环境 2 (低配置显卡电脑) - -+ OS: Ubuntu 20.04.4 LTS +## Test hardware 2 (the oracle cloud server) ++ OS: Ubuntu 22.04.4 LTS ++ Architecture: aarch64 ++ CPU: 1-core Neoverse-N1 ++ GPU: None ++ Memory: 2G ++ Disk: 30G ++ Bandwidth: 100Mbps ++ Python version: 3.10 -> [!WARNING] -> 尽量使用 22.04+ 的版本,更早版本的 ubuntu 自带 gcc 版本无法更新至 biliup-rs 所需版本,若使用较早版本,请参考 [version `GLIBC_2.34‘ not found简单有效解决方法](https://blog.csdn.net/huazhang_001/article/details/128828999)。 +## Test hardware 3 (the low-configuration GPU server) -+ CPU:Intel(R) Core(TM) i5-9300H CPU 8 核 -+ GPU:NVIDIA GeForce GTX 1650 显存 4GB -+ 内存:24G -+ 硬盘:100G -+ 带宽: 50Mbps -+ Python 版本: 3.10 \ No newline at end of file ++ OS: Ubuntu 20.04.4 LTS ++ Architecture: x86_64 ++ CPU: 8-core Intel(R) Core(TM) i5-9300H CPU ++ GPU: NVIDIA GeForce GTX 1650 VRAM 4GB ++ Memory: 24G ++ Disk: 100G ++ Bandwidth: 50Mbps ++ Python version: 3.10 \ No newline at end of file diff --git a/docs/upload.md b/docs/upload.md index a509c20..124c64b 100644 --- a/docs/upload.md +++ b/docs/upload.md @@ -1,15 +1,18 @@ -# upload 常见问题 +# upload common issues -> 如果没有找到遇到的问题,请及时在 [issues](https://github.com/timerring/bilive/issues/new/choose) 中提出。 +> If you don't find the problem you encountered, please submit it in [issues](https://github.com/timerring/bilive/issues/new/choose). -## 上传默认参数 +## Upload default parameters -上传默认参数如下,[]中内容全部自动替换。上传会根据以上模版生成上传视频对应的 `yaml` 配置文件, 可以在 `src/config.py` 中自定义相关配置,映射关键词为 `{artist}`、`{date}`、`{title}`、`{source_link}`,可自行组合删减定制模板: -+ 标题模板是`{artist}直播回放-{date}-{title}`,效果为"【弹幕+字幕】[XXX]直播回放-[日期]-[直播间标题]",可自行修改。 -+ 简介模板是`{artist}直播,直播间地址:{source_link} 内容仅供娱乐,直播中主播的言论、观点和行为均由主播本人负责,不代表录播员的观点或立场。`,效果为"【弹幕+字幕】[XXX]直播,直播间地址:[https://live.bilibili.com/XXX] 内容仅供娱乐,直播中主播的言论、观点和行为均由主播本人负责,不代表录播员的观点或立场。",可自行修改。 -+ 默认标签是根据主播名字自动在 b 站搜索推荐中抓取的[热搜词],详见[bilibili-API-collect](https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/search/suggest.md)。 +Customize the relevant configuration in `bilive.toml`, map the keywords to `{artist}`、`{date}`、`{title}`、`{source_link}`, please customize the template by combining and deleting: -## 投稿过于频繁 +- `title` title template. +- `description` description template. +- `gift_price_filter = 1` means filtering gifts with a price lower than 1 yuan. +- `reserve_for_fixing = false` means if the video is uploaded with an error, it will not be reserved for fixing, it is recommended to set false for users with limited hard disk space. +- `upload_line = "auto"` means automatically detecting the upload line and uploading, if you need to specify a fixed line, you can set it to `bldsa`、`ws`、`tx`、`qn`、`bda2`. + +## Overly frequent upload ``` Error: ResponseData { code: 137022, data: None, message: "投稿过于频繁,请稍后再试", ttl: Some(1) } @@ -30,8 +33,8 @@ Error: ResponseData { code: 137022, data: None, message: "投稿过于频繁, 2024-12-14 23:32:51 2024-12-14 23:40:56 2024-12-14 23:51:25 -2024-12-15 00:10:02 触发 Error +2024-12-15 00:10:02 Error ``` -此类报错常出现在短时间内连续投稿,因此个人建议最小分段不要少于半小时,否则会触发此类错误。同时,如果存在录制多位的情况,推荐将权重低的直播间分段间隔调整大,尽量减少投稿频率,而给较为重要的直播间设置较短的间隔。 +This error often occurs when uploading frequently in a short period of time, so I personally recommend that the minimum segment should not be less than half an hour, otherwise it will trigger this error. At the same time, if there is a situation where multiple hosts are recorded, it is recommended to adjust the segment interval of the host with lower weight to a larger value, and try to reduce the upload frequency, while setting a shorter interval for the host with higher weight. -解决方案:找官方客服解除短时间内的账号投稿限制。 \ No newline at end of file +Solution: Find the official customer service to lift the account upload restriction within a short period of time. \ No newline at end of file