ViLAMP(VIdeo-LAnguage Model with Mixed Precision)是蚂蚁集团和中国人民大学联合推出的视觉语言模型,专门用在高效处理长视频内容。基于混合精度策略,对视频中的关键帧保持高精度分析,显著降低计算成本提高处理效率。ViLAMP在多个视频理解基准测试中表现出色,在长视频理解任务中,展现出显著优势。ViLAMP能在单张A100 GPU上处理长达1万帧(约3小时)的视频,同时保持稳定的理解准确率,为长视频分析提供新的解决方案。

ViLAMP的主要功能

  • 长视频理解:支持处理长达数小时的视频。
  • 关键信息提取:精准提取视频中的关键信息,同时压缩冗余信息。
  • 高效计算:在单张A100 GPU上处理长达1万帧(约3小时)的视频,显著降低内存和计算成本,提高处理效率。
  • 多任务处理:支持多种视频理解任务,如视频内容问答、动作识别、场景理解等。

ViLAMP的技术原理

  • 差分关键帧选择:基于贪心算法选择与用户查询高度相关且具有时间多样性的关键帧。确保选中的关键帧既能捕捉重要信息,避免冗余。
  • 差分特征合并:对非关键帧进行压缩,将每个非关键帧的多个patch合并为单个token。基于差分加权池化,赋予与用户查询相关且具有独特性的patch更高的权重,同时降低与关键帧重复的patch的权重。保留关键信息的同时,显著减少计算量。

ViLAMP的项目地址

⚙️ 设置

git clone https://github.com/steven-ccq/ViLAMP.git
cd ViLAMP
 

环境

# python 3.8
pip install -r requirements.txt
 

安装 ViLAMP

请安装🤗ViLAMP-llava-qwen并将其放入models/

🎯 推理

我们提供了五个基准的评估脚本:Video-MME、、、和MLVU。更多详情,请参阅。LongVideoBenchActivityNetQAEgoSchemascripts/eval/

在运行这些脚本之前,请下载评估数据集并将其放在dataset/目录中。以下是输入参数的说明:

--dataset_path  Path to the test dataset
--video_dir    Path to the folder containing the videos required for testing
--output_dir   Path to the folder where the results will be saved
--version      Path to the model
--split        Split the dataset in the format i_N, where N is the total number of splits and i is the current split index (starting from 1). Default is 1_1.
--max_frame_num Maximum number of frames to sample per video. Default is 600.
 

以下是评估 Video-MME 的示例

python exp_vMME.py \
    --dataset_path dataset/Video-MME/videomme/test-00000-of-00001.parquet \
    --video_dir dataset/Video-MME/data \
    --output_dir dataset/Video-MME/output \
    --version models/ViLAMP-llava-qwen \
    --split 1_1 \
    --max_frame_num 600
 

🚀 培训

我们提供针对单节点和多节点环境设计的训练脚本。更多详细说明,请查看scripts/train/目录。

为了简化数据集的组织,我们利用该training_data.yaml文件来整合训练数据。在开始训练之前,请确保您的数据集已注册到此文件中。我们提供了一个简单的示例example-10.json来演示预期的数据集格式。

请注意,如果您的训练数据集需要特定的处理方法,则需要修改llava/train/train.py文件的第 1225 行,并在该行之前插入自定义视频处理功能,以满足您的数据集的需求。

引文

@article{cheng2025vilamp,
  title={Scaling Video-Language Models to 10K Frames via Hierarchical Differential Distillation},
  author={Cheng, Chuanqi and Guan, Jian and Wu, Wei and Yan, Rui},
  journal={arXiv preprint arXiv:2504.02438},
  year={2025}
}

相关推荐

BILIVE

BILIVE

<p>BILIVE 是基于 AI 技术的开源工具,专为 B 站直播录制与处理设计。工具支持自动录制直播、渲染弹幕和字幕,支持语音识别、自动切片精彩片段,生成有趣的标题和风格化的视频封面。BILIVE 能自动将处理后的视频投稿至 B 站,综合多种模态模型,兼容超低配置机器,无需 GPU 即可运行,适合个人用户和小型服务器使用。</p> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">1. Introduction</h2> <a id="user-content-1-introduction" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#1-introduction" aria-label="Permalink: 1. Introduction"></a></div> <blockquote> <p>Have you noticed that Live-In is a wordplay :)</p> <p>如果您觉得项目不错,欢迎 ⭐ 也欢迎 PR 合作,如果有任何疑问,欢迎提 issue 交流。</p> <p>敬告:本项目仅供学习交流使用,请在征得对方许可的情况下录制,请勿未经授权私自将内容用于商业用途,请勿用于大规模录制,违者会被官方封禁,法律后果自负。</p> </blockquote> <p>自动监听并录制B站直播和弹幕(含付费留言、礼物等),根据分辨率转换弹幕、语音识别字幕并渲染进视频,根据弹幕密度切分精彩片段并通过视频理解大模型生成有趣的标题,根据图像生成模型自动生成视频封面,自动投稿视频和切片至B站,兼容无GPU版本,兼容 x64 及 arm64 超低配置服务器与主机。</p> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">2. Major features</h2> <a id="user-content-2-major-features" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#2-major-features" aria-label="Permalink: 2. Major features"></a></div> <ul dir="auto"> <li>速度快:采用 <code>pipeline</code> 流水线处理视频,理想情况下录播与直播相差半小时以内,没下播就能上线录播,已知 b 站录播最快的稳定版本!</li> <li>( 🎉 NEW)多架构:适配 amd64 及 arm64 架构!</li> <li>多房间:同时录制多个直播间内容视频以及弹幕文件(包含普通弹幕,付费弹幕以及礼物上舰等信息)。</li> <li>占用小:自动删除本地已上传的视频,极致节省空间。</li> <li>模版化:无需复杂配置,开箱即用,通过 b 站搜索建议接口自动抓取相关热门标签。</li> <li>检测片段并合并:对于网络问题或者直播连线导致的视频流分段,能够自动检测合并成为完整视频。</li> <li>自动渲染弹幕:自动转换xml为ass弹幕文件,该转换工具库已经开源 <a href="https://github.com/timerring/DanmakuConvert">DanmakuConvert</a> 并且渲染到视频中形成有弹幕版视频并自动上传。</li> <li>硬件要求极低:无需GPU,只需最基础的单核CPU搭配最低的运存即可完成录制,弹幕渲染,上传等等全部过程,无最低配置要求,10年前的电脑或服务器依然可以使用!</li> <li>( 🎉 NEW)自动渲染字幕:采用 OpenAI 的开源模型 <code>whisper</code>,自动识别视频内语音并转换为字幕渲染至视频中。</li> <li>( 🎉 NEW)自动切片上传:根据弹幕密度计算寻找高能片段并切片,该自动切片工具库已开源 <a href="https://github.com/timerring/auto-slice-video">auto-slice-video</a>,结合多模态视频理解大模型自动生成有意思的切片标题及内容,并且自动上传,目前已经支持的模型有: <ul dir="auto"> <li><code>GLM-4V-PLUS</code></li> <li><code>Gemini-2.0-flash</code></li> <li><code>Qwen-2.5-72B-Instruct</code></li> <li><code>SenseNova V6 Pro</code></li> </ul> </li> <li>( 🎉 NEW)持久化登录/下载/上传视频(支持多p投稿):<a href="https://github.com/timerring/bilitool">bilitool</a> 已经开源,实现持久化登录,下载视频及弹幕(含多p)/上传视频(可分p投稿),查询投稿状态,查询详细信息等功能,一键pip安装,可以使用命令行 cli 操作,也可以作为api调用。</li> <li>( 🎉 NEW)自动多平台循环直播推流:该工具已经开源 <a href="https://github.com/timerring/looplive">looplive</a> 是一个 7 x 24 小时全自动循环多平台同时推流直播工具。</li> <li>( 🎉 NEW)自动生成风格变换的视频封面:采用图生图多模态模型,自动获取视频截图并上传风格变换后的视频封面。 <ul dir="auto"> <li><code>Minimax image-01</code></li> <li><code>Kwai Kolors</code></li> <li><code>Tencent Hunyuan</code></li> <li><code>Baidu ERNIE irag-1.0</code></li> <li><code>Stable Diffusion 3.5 large turbo</code></li> <li><code>Luma Photon</code></li> <li><code>Ideogram V_2</code></li> <li><code>Recraft</code></li> <li><code>Amazon Titan Image Generator V2</code></li> <li><code>Hidream I1</code></li> <li><code>kling-v1-5</code></li> </ul> </li> </ul> <p>项目架构流程如下:</p> <p><a href="https://camo.githubusercontent.com/df9302abc9dcf088ff572cf5f2057539220e9239f8094a36c9779a9b2e3368bb/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f74696d657272696e672f73637261746368706164323032332f323032342f323032352d30352d30332d32322d30392d35362e706e67" target="_blank" rel="noopener noreferrer nofollow"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://camo.githubusercontent.com/df9302abc9dcf088ff572cf5f2057539220e9239f8094a36c9779a9b2e3368bb/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f74696d657272696e672f73637261746368706164323032332f323032342f323032352d30352d30332d32322d30392d35362e706e67"></a></p> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">3. 测试硬件</h2> <a id="user-content-3-测试硬件" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#3-%E6%B5%8B%E8%AF%95%E7%A1%AC%E4%BB%B6" aria-label="Permalink: 3. 测试硬件"></a></div> <table> <thead> <tr> <th>Machine</th> <th>Alicloud</th> <th>Oracle Cloud</th> <th>local server</th> </tr> </thead> <tbody> <tr> <td>OS</td> <td>Ubuntu 22.04.4 LTS</td> <td>debian 6.1.0</td> <td>Ubuntu 22.04.4 LTS</td> </tr> <tr> <td>Architecture</td> <td>x64</td> <td>aarch64</td> <td>x64</td> </tr> <tr> <td>CPU</td> <td>2-core Intel(R) Xeon(R) Platinum 85</td> <td>1-core Neoverse-N1</td> <td>8-core Intel(R) Core(TM) i5-9300H CPU</td> </tr> <tr> <td>GPU</td> <td>None</td> <td>None</td> <td>Nvidia GeForce GTX 1650</td> </tr> <tr> <td>Memory</td> <td>2G</td> <td>4G</td> <td>24G</td> </tr> <tr> <td>Disk</td> <td>40G</td> <td>30G</td> <td>100G</td> </tr> <tr> <td>Bandwidth</td> <td>3Mbps</td> <td>100Mbps</td> <td>50Mbps</td> </tr> <tr> <td>Python Version</td> <td>3.10</td> <td>3.10</td> <td>3.10</td> </tr> </tbody> </table> <blockquote> <p>个人经验:若想尽可能快地更新视频,主要取决于上传速度而非渲染速度,因此建议网络带宽越大越好。由于 <a href="https://github.com/triton-lang/triton/issues/5561" data-hovercard-type="issue" data-hovercard-url="/triton-lang/triton/issues/5561/hovercard">aarch64 版本 PyPI 没有 release</a> 的 <a href="https://pypi.org/project/triton/#history" rel="nofollow">triton 库</a>,因此 aarch64 版本暂时不支持本地部署 whisper,pip 时请自行注释 requirement 中的 triton 环境,配置均测试可用。</p> </blockquote> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">4. Quick start</h2> <a id="user-content-4-quick-start" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#4-quick-start" aria-label="Permalink: 4. Quick start"></a></div> <p>更详细的教程请参考文档 <a href="https://timerring.github.io/bilive/" rel="nofollow">bilive</a></p> <div class="markdown-alert markdown-alert-note" dir="auto"> <p>Note</p> <p>如果你是 windows 用户,请使用 WSL 运行本项目。</p> </div> <div class="markdown-heading" dir="auto"> <h3 class="heading-element" dir="auto" tabindex="-1">Mode</h3> <a id="user-content-mode" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#mode" aria-label="Permalink: Mode"></a></div> <p>首先介绍本项目三种不同的处理模式:(以下特指 asr_method="deploy" 的情况,如填"none"或者"api"则不涉及 GPU, 可以忽略对 GPU 的描述)</p> <ol dir="auto"> <li><code>pipeline</code> 模式(默认): 目前最快的模式,需要 GPU 支持,最好在 <code>blrec</code> 设置片段为半小时以内,asr 识别和渲染并行执行,分 p 上传视频片段。 <a href="https://camo.githubusercontent.com/7dd3a18c6da3aa2b50f8665e11d9cb1d5438ac4067ef6dbc7ed62a7ca86fac89/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f74696d657272696e672f73637261746368706164323032332f323032342f323032342d31322d31312d31372d33332d31352e706e67" target="_blank" rel="noopener noreferrer nofollow"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://camo.githubusercontent.com/7dd3a18c6da3aa2b50f8665e11d9cb1d5438ac4067ef6dbc7ed62a7ca86fac89/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f74696d657272696e672f73637261746368706164323032332f323032342f323032342d31322d31312d31372d33332d31352e706e67"></a></li> <li><code>append</code> 模式: 基本同上,但 asr 识别与渲染过程串行执行,比 pipeline 慢预计 25% 左右,对 GPU 显存要求较低,兼顾硬件性能与处理上传效率。 <a href="https://camo.githubusercontent.com/6e53fea505d9808dc6b14cb5d9fd81bfcd822476fe03213960c4553554e2df74/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f74696d657272696e672f73637261746368706164323032332f323032342f323032342d31322d31312d31392d30372d31322e706e67" target="_blank" rel="noopener noreferrer nofollow"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://camo.githubusercontent.com/6e53fea505d9808dc6b14cb5d9fd81bfcd822476fe03213960c4553554e2df74/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f74696d657272696e672f73637261746368706164323032332f323032342f323032342d31322d31312d31392d30372d31322e706e67"></a></li> <li><code>merge</code> 模式: 等待所有录制完成,再进行识别渲染合并过程,上传均为完整版录播(非分 P 投稿),等待时间较长,效率较慢,适合需要上传完整录播的场景。 <a href="https://camo.githubusercontent.com/6aa4615a44f2e0c9ee2ef91d29f8032a6e49213e440e23bed54523075341a7bd/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f74696d657272696e672f73637261746368706164323032332f323032342f323032342d31322d31312d31392d30382d35382e706e67" target="_blank" rel="noopener noreferrer nofollow"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://camo.githubusercontent.com/6aa4615a44f2e0c9ee2ef91d29f8032a6e49213e440e23bed54523075341a7bd/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f74696d657272696e672f73637261746368706164323032332f323032342f323032342d31322d31312d31392d30382d35382e706e67"></a></li> </ol> <div class="markdown-alert markdown-alert-important" dir="auto"> <p>Important</p> <p>凡是用到 GPU 均需保证 GPU 显存大于运行程序所需 VRAM,具体计算 VRAM 方法可以参考<a href="https://timerring.github.io/bilive/models.html#calculate-vram-requirements" rel="nofollow">该部分</a>。</p> </div> <div class="markdown-heading" dir="auto"> <h3 class="heading-element" dir="auto" tabindex="-1">Installation</h3> <a id="user-content-installation" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#installation" aria-label="Permalink: Installation"></a></div> <div class="markdown-alert markdown-alert-tip" dir="auto"> <p>Tip</p> <p>如果你是 windows 用户,请使用 WSL 运行本项目。</p> </div> <div class="markdown-heading" dir="auto"> <p>0. clone 项目</p> <a id="user-content-0-clone-项目" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#0-clone-%E9%A1%B9%E7%9B%AE" aria-label="Permalink: 0. clone 项目"></a></div> <p>由于项目引入了我写的 submodule <a href="https://github.com/timerring/DanmakuConvert">DanmakuConvert</a>,<a href="https://github.com/timerring/bilitool">bilitool</a> 和 <a href="https://github.com/timerring/auto-slice-video">auto-slice-video</a>,因此推荐 clone 项目时就更新 submodules。</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto"> <pre>git clone --recurse-submodules https://github.com/timerring/bilive.git</pre> <div class="zeroclipboard-container"> </div> </div> <p>如果你没有采用上述方式 clone 项目,请更新 submodules:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto"> <pre>git submodule update --init --recursive</pre> <div class="zeroclipboard-container"> </div> </div> <div class="markdown-heading" dir="auto"> <p>1. 安装依赖(推荐创建虚拟环境)</p> <a id="user-content-1-安装依赖推荐创建虚拟环境" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#1-%E5%AE%89%E8%A3%85%E4%BE%9D%E8%B5%96%E6%8E%A8%E8%8D%90%E5%88%9B%E5%BB%BA%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83" aria-label="Permalink: 1. 安装依赖(推荐创建虚拟环境)"></a></div> <div class="snippet-clipboard-content notranslate position-relative overflow-auto"> <pre class="notranslate"><code>cd bilive pip install -r requirements.txt </code></pre> <div class="zeroclipboard-container"> </div> </div> <p>此外请根据各自的系统类型安装对应的 <a href="https://www.ffmpeg.org/download.html" rel="nofollow"><code>ffmpeg</code></a>,例如 <a href="https://gcore.com/learning/how-to-install-ffmpeg-on-ubuntu/" rel="nofollow">ubuntu 安装 ffmpeg</a>。</p> <p><a href="https://timerring.github.io/bilive/install-questions.html" rel="nofollow">常见问题收集</a></p> <div class="markdown-heading" dir="auto"> <p>2. 配置参数</p> <a id="user-content-2-配置参数" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#2-%E9%85%8D%E7%BD%AE%E5%8F%82%E6%95%B0" aria-label="Permalink: 2. 配置参数"></a></div> <div class="markdown-heading" dir="auto"> <p>2.1 whisper 语音识别(渲染字幕功能)</p> <a id="user-content-21-whisper-语音识别渲染字幕功能" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#21-whisper-%E8%AF%AD%E9%9F%B3%E8%AF%86%E5%88%AB%E6%B8%B2%E6%9F%93%E5%AD%97%E5%B9%95%E5%8A%9F%E8%83%BD" aria-label="Permalink: 2.1 whisper 语音识别(渲染字幕功能)"></a></div> <div class="markdown-alert markdown-alert-tip" dir="auto"> <p>Tip</p> <ul dir="auto"> <li>有关语音识别的配置在 <code>bilive.toml</code> 文件的 <code>[asr]</code> 部分。</li> <li><code>asr_method</code> 默认为 none, 即不进行语音字幕识别。</li> </ul> </div> <div class="markdown-heading" dir="auto"> <p>2.1.1 采用 api 方式</p> <a id="user-content-211-采用-api-方式" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#211-%E9%87%87%E7%94%A8-api-%E6%96%B9%E5%BC%8F" aria-label="Permalink: 2.1.1 采用 api 方式"></a></div> <p>将 <code>bilive.toml</code> 文件中的 <code>asr_method</code> 参数设置为 <code>api</code>,然后填写 <code>WHISPER_API_KEY</code> 参数为你的 <a href="https://console.groq.com/keys" rel="nofollow">API Key</a>。</p> <p>本项目采用 groq 提供 free tier 的 <code>whisper-large-v3-turbo</code> 模型,上传限制为 40 MB(约半小时),因此如需采用 api 识别的方式,请将视频录制分段调整为 30 分钟(默认即 30 分钟)。此外,free tier 请求限制为 7200秒/20次/小时,28800秒/2000次/天。如果有更多需求,也欢迎升级到 dev tier,更多信息见<a href="https://console.groq.com/docs/rate-limits" rel="nofollow">groq 官网</a>。</p> <div class="markdown-heading" dir="auto"> <p>2.1.2 采用本地部署方式(需保证有 NVIDIA 显卡)</p> <a id="user-content-212-采用本地部署方式需保证有-nvidia-显卡" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#212-%E9%87%87%E7%94%A8%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2%E6%96%B9%E5%BC%8F%E9%9C%80%E4%BF%9D%E8%AF%81%E6%9C%89-nvidia-%E6%98%BE%E5%8D%A1" aria-label="Permalink: 2.1.2 采用本地部署方式(需保证有 NVIDIA 显卡)"></a></div> <p>将 <code>bilive.toml</code> 文件中的 <code>asr_method</code> 参数设置为 <code>deploy</code>,然后下载所需模型文件,并放置在 <code>src/subtitle/models</code> 文件夹中。</p> <p>项目默认采用 <a href="https://openaipublic.azureedge.net/main/whisper/models/9ecf779972d90ba49c06d968637d720dd632c55bbf19d441fb42bf17a411e794/small.pt" rel="nofollow"><code>small</code></a> 模型,请点击下载所需文件,并放置在 <code>src/subtitle/models</code> 文件夹中。</p> <div class="markdown-alert markdown-alert-tip" dir="auto"> <p>Tip</p> <ul dir="auto"> <li>请保证 NVIDIA 显卡驱动安装正确 <code>nvidia-smi</code> <code>nvcc -V</code>,并能够调用 CUDA 核心 <code>print(torch.cuda.is_available())</code> 返回 <code>True</code>。如果未配置显卡驱动或未安装 <code>CUDA</code>,即使有 GPU 也无法使用,而会使用 CPU 推理,非常消耗 CPU 计算资源,不推荐,如果 CPU 硬件条件好可以尝试。</li> <li>使用该参数模型至少需要保证有显存大于 2.7GB 的 GPU,否则请使用其他参数量的模型。</li> <li>更多模型请参考 <a href="https://timerring.github.io/bilive/models.html" rel="nofollow">whisper 参数模型</a> 部分。</li> <li>更换模型方法请参考 <a href="https://timerring.github.io/bilive/models.html#change-model-method" rel="nofollow">更换模型方法</a> 部分。</li> </ul> </div> <div class="markdown-heading" dir="auto"> <p>2.2 MLLM 模型(自动切片功能)</p> <a id="user-content-22-mllm-模型自动切片功能" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#22-mllm-%E6%A8%A1%E5%9E%8B%E8%87%AA%E5%8A%A8%E5%88%87%E7%89%87%E5%8A%9F%E8%83%BD" aria-label="Permalink: 2.2 MLLM 模型(自动切片功能)"></a></div> <div class="markdown-alert markdown-alert-tip" dir="auto"> <p>Tip</p> <ul dir="auto"> <li>有关自动切片的配置在 <code>bilive.toml</code> 文件的 <code>[slice]</code> 部分。</li> <li><code>auto_slice</code> 默认为 false, 即不进行自动切片。</li> <li>可以通过单元测试调试你自己的 prompt,单元测试在 <code>tests/test_autoslice.py</code>,执行 <code>python -m unittest</code> 即可,后接 <code>tests.test_autoslice</code> 测试整个模块,<code>tests.test_autoslice.TestXXXMain</code> 测试某个模型。部分模型会返回多个标题及 emoji,请在 prompt 中指出,仅返回一个标题的字符串即可,推荐先自行调试确保您的 prompt works,欢迎在 issue 中分享你的 prompt。</li> </ul> </div> <p>MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关闭,如果需要打开请将 <code>auto_slice</code> 参数设置为 <code>true</code>,并且写下你自己的 <code>slice_prompt</code>(可以包含 <code>{artist}</code> 关键词会自动替换),其他配置分别有:</p> <ul dir="auto"> <li><code>slice_duration</code> 以秒为单位设置切片时长(不建议超过 180 秒)。</li> <li><code>slice_num</code> 设置切片数量。</li> <li><code>slice_overlap</code> 设置切片重叠时长。切片采用滑动窗口法处理,细节内容请见 <a href="https://github.com/timerring/auto-slice-video">auto-slice-video</a></li> <li><code>slice_step</code> 设置切片步长。</li> <li><code>min_video_size</code> 设置最小被切片视频大小,防止对一些连线或者网络波动原因造成的短片段再切片。</li> </ul> <p>接下来配置模型有关的 <code>mllm_model</code> 参数即对应的 api-key,请自行根据链接注册账号并且申请对应 api key,填写在对应的参数中,请注意以下模型只有你在 <code>mllm_model</code> 参数中设置的那个模型会生效。</p> <table> <thead> <tr> <th>Company</th> <th>Alicloud</th> <th>zhipu</th> <th>Google</th> <th>SenseNova</th> </tr> </thead> <tbody> <tr> <td>Name</td> <td>Qwen-2.5-72B-Instruct</td> <td>GLM-4V-PLUS</td> <td>Gemini-2.0-flash</td> <td>SenseNova V6 Pro</td> </tr> <tr> <td><code>mllm_model</code></td> <td><code>qwen</code></td> <td><code>zhipu</code></td> <td><code>gemini</code></td> <td><code>sensenova</code></td> </tr> <tr> <td><code>API key</code></td> <td><a href="https://bailian.console.aliyun.com/?apiKey=1" rel="nofollow">qwen_api_key</a></td> <td><a href="https://www.bigmodel.cn/invite?icode=shBtZUfNE6FfdMH1R6NybGczbXFgPRGIalpycrEwJ28%3D" rel="nofollow">zhipu_api_key</a></td> <td><a href="https://aistudio.google.com/app/apikey" rel="nofollow">gemini_api_key</a></td> <td><a href="https://console.sensecore.cn/aistudio/management/api-key" rel="nofollow">sensenova_api_key</a></td> </tr> </tbody> </table> <div class="markdown-heading" dir="auto"> <p>2.3 Image Generation Model(自动生成视频封面)</p> <a id="user-content-23-image-generation-model自动生成视频封面" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#23-image-generation-model%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90%E8%A7%86%E9%A2%91%E5%B0%81%E9%9D%A2" aria-label="Permalink: 2.3 Image Generation Model(自动生成视频封面)"></a></div> <div class="markdown-alert markdown-alert-tip" dir="auto"> <p>Tip</p> <ul dir="auto"> <li>有关自动生成视频封面的配置在 <code>bilive.toml</code> 文件的 <code>[cover]</code> 部分。</li> <li><code>generate_cover</code> 默认为 false, 即不进行自动生成视频封面。</li> <li>可以通过单元测试调试你自己的 prompt,单元测试在 <code>tests/test_cover.py</code>,执行 <code>python -m unittest</code> 即可,后接 <code>tests.test_cover</code> 测试整个模块,<code>tests.test_cover.TestXXXMain</code> 测试某个模型。</li> </ul> </div> <p>采用图生图多模态模型,自动获取视频截图并上传风格变换后的视频封面,如需使用本功能,请将 <code>generate_cover</code> 参数设置为 <code>true</code>,并且写下你自己的 prompt,注意部分模型只支持英文,接下来需要配置的参数有 image_gen_model 和对应的 api key,请自行根据链接注册账号并且申请对应 api key,填写在对应的参数中,请注意以下模型只有你在 <code>image_gen_model</code> 参数中设置的那个模型会生效。</p> <p>推荐使用大模型API(<a href="https://www.dmxapi.cn/register?aff=vRzR" rel="nofollow">dmxapi.cn</a>),一个 Key 用全球大模型,<a href="https://github.com/timerring/bilive?tab=readme-ov-file#%E7%89%B9%E5%88%AB%E6%84%9F%E8%B0%A2">查看详细介绍</a>。</p> <table> <thead> <tr> <th>Company</th> <th>Model Name</th> <th><code>image_gen_model</code></th> <th><code>API Key</code></th> </tr> </thead> <tbody> <tr> <td>Kwai</td> <td>v1-5</td> <td><code>kling</code></td> <td><a href="https://www.dmxapi.cn/token" rel="nofollow">dmx_api_token</a></td> </tr> </tbody> </table> <details> <summary>其他支持的图像生成模型</summary> <table> <thead> <tr> <th> </th> <th> </th> <th> </th> <th> </th> </tr> </thead> <tbody> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </tbody> </table> </details> <div class="markdown-heading" dir="auto"> <p>3. 配置上传参数</p> <a id="user-content-3-配置上传参数" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#3-%E9%85%8D%E7%BD%AE%E4%B8%8A%E4%BC%A0%E5%8F%82%E6%95%B0" aria-label="Permalink: 3. 配置上传参数"></a></div> <p>在 <code>bilive.toml</code> 中自定义相关配置,映射关键词为 <code>{artist}</code>、<code>{date}</code>、<code>{title}</code>、<code>{source_link}</code>,请自行组合删减定制模板:</p> <ul dir="auto"> <li><code>title</code> 标题模板。</li> <li><code>description</code> 简介模板。</li> <li><code>tid</code> 视频分区,请参考 <a href="https://bilitool.timerring.com/tid.html" rel="nofollow">bilitool tid</a> 文档。</li> <li><code>gift_price_filter = 1</code> 表示过滤价格低于 1 元的礼物。</li> <li><code>reserve_for_fixing = false</code> 表示如果视频出现错误,重试失败后不保留视频用于修复,推荐硬盘空间有限的用户设置 false。</li> <li><code>upload_line = "auto"</code> 表示自动探测上传线路并上传,如果需要指定固定的线路,可以设置为 <code>bldsa</code>、<code>ws</code>、<code>tx</code>、<code>qn</code>、<code>bda2</code>。</li> </ul> <div class="markdown-heading" dir="auto"> <p>4. 配置录制参数</p> <a id="user-content-4-配置录制参数" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#4-%E9%85%8D%E7%BD%AE%E5%BD%95%E5%88%B6%E5%8F%82%E6%95%B0" aria-label="Permalink: 4. 配置录制参数"></a></div> <div class="markdown-alert markdown-alert-important" dir="auto"> <p>Important</p> <p>请不要修改任何有关路径的任何配置,否则会导致上传模块不可用</p> </div> <blockquote> <p>录制模块采用第三方 package <code>blrec</code>,参数配置在 <code>settings.toml</code> 文件,也可以直接在录制启动后在对应的端口可视化页面配置。Quick start 只介绍关键配置,其他配置可自行在页面中对照配置项理解,支持热修改。</p> </blockquote> <ul dir="auto"> <li>房间的添加按照文件中 <code>[[tasks]]</code> 对应的格式即可。</li> <li>录制模块不登录状态下默认的录制质量为超清。如果需要登录,请将 cookie.json 文件(获取方式见步骤 5)中的 <code>SESSDATA</code> 参数值填写到 <code>[header]</code> 的 cookie 部分,形式<code>cookie = "SESSDATA=XXXXXXXXXXX"</code>,登录后即可录制更高质量画质。(推荐不登录)</li> <li><code>duration_limit</code> 表示录制时长,如果采用 whisper api 识别语音,请将分段控制在 1800 秒以内,其他情况没有限制。</li> </ul> <div class="markdown-heading" dir="auto"> <p>5. bilitool 登录(持久化登录,该步只需执行一次)</p> <a id="user-content-5-bilitool-登录持久化登录该步只需执行一次" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#5-bilitool-%E7%99%BB%E5%BD%95%E6%8C%81%E4%B9%85%E5%8C%96%E7%99%BB%E5%BD%95%E8%AF%A5%E6%AD%A5%E5%8F%AA%E9%9C%80%E6%89%A7%E8%A1%8C%E4%B8%80%E6%AC%A1" aria-label="Permalink: 5. bilitool 登录(持久化登录,该步只需执行一次)"></a></div> <blockquote> <p>对于 docker 部署,可以忽略这一步,因为 <code>docker logs</code> 在控制台中可以打印出二维码,直接扫码即可登录,以下内容针对源码部署。</p> </blockquote> <div class="markdown-heading" dir="auto"> <p>5.1 方式一 通过 cookie 登录</p> <a id="user-content-51-方式一-通过-cookie-登录" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#51-%E6%96%B9%E5%BC%8F%E4%B8%80-%E9%80%9A%E8%BF%87-cookie-%E7%99%BB%E5%BD%95" aria-label="Permalink: 5.1 方式一 通过 cookie 登录"></a></div> <p>一般日志文件打印不出二维码效果,所以这步需要提前在机器上安装 <a href="https://github.com/timerring/bilitool">bilitool</a>:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto"> <pre class="notranslate"><code>pip install bilitool bilitool login --export # 然后使用 app 端扫码登录,会自动导出 cookie.json 文件 </code></pre> <div class="zeroclipboard-container"> </div> </div> <p>将登录的 cookie.json 文件留在本项目根目录下,<code>./upload.sh</code> 启动后即可删除该文件。</p> <div class="markdown-heading" dir="auto"> <p>5.2 方式二 通过 submodule 登录</p> <a id="user-content-52-方式二-通过-submodule-登录" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#52-%E6%96%B9%E5%BC%8F%E4%BA%8C-%E9%80%9A%E8%BF%87-submodule-%E7%99%BB%E5%BD%95" aria-label="Permalink: 5.2 方式二 通过 submodule 登录"></a></div> <p>或者在 submodule 中登录也可以,方式如下:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto"> <pre class="notranslate"><code>cd src/upload/bilitool python -m bilitool.cli login # 然后使用 app 端扫码即可登录 </code></pre> <div class="zeroclipboard-container"> </div> </div> <p><a href="https://timerring.github.io/bilive/biliup.html" rel="nofollow">常见问题收集</a></p> <div class="markdown-heading" dir="auto"> <p>6. 启动自动录制</p> <a id="user-content-6-启动自动录制" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#6-%E5%90%AF%E5%8A%A8%E8%87%AA%E5%8A%A8%E5%BD%95%E5%88%B6" aria-label="Permalink: 6. 启动自动录制"></a></div> <div class="markdown-alert markdown-alert-important" dir="auto"> <p>Important</p> <p>在有公网 ip 的服务器上使用默认密码并暴露端口号有潜在的暴露 cookie 风险,因此不推荐在有公网 ip 的服务器映射端口号。</p> <ul dir="auto"> <li>如需使用 https,可以考虑 openssl 自签名证书并在 <code>record.sh</code> 中添加参数 <code>--key-file path/to/key-file --cert-file path/to/cert-file</code>。</li> <li>可以自行限制服务器端口入站 ip 规则或者采用 nginx 等反向代理配置限制他人访问。</li> </ul> </div> <p>启动前请先设置录制前端页面的密码,并保存在 <code>RECORD_KEY</code> 环境变量中, <code>your_password</code> 由字母数字组成,最少 8 位,最多 80 位。</p> <ul dir="auto"> <li>临时设置密码 <code>export RECORD_KEY=your_password</code>。(推荐)</li> <li>持久化设置密码 <code>echo "export RECORD_KEY=your_password" >> ~/.bashrc && source ~/.bashrc</code>,其中 <code>~/.bashrc</code> 根据你所用的 shell 自行修改即可。</li> </ul> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto"> <pre>./record.sh</pre> <div class="zeroclipboard-container"> </div> </div> <p><a href="https://timerring.github.io/bilive/record.html" rel="nofollow">常见问题收集</a></p> <div class="markdown-heading" dir="auto"> <p>7. 启动自动上传</p> <a id="user-content-7-启动自动上传" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#7-%E5%90%AF%E5%8A%A8%E8%87%AA%E5%8A%A8%E4%B8%8A%E4%BC%A0" aria-label="Permalink: 7. 启动自动上传"></a></div> <blockquote> <p>如果你使用 deploy 的方式本地部署 whisper,请先确保你已经正确下载并放置了对应的模型文件,并确保 CUDA 可用。</p> </blockquote> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto"> <pre>./upload.sh</pre> <div class="zeroclipboard-container"> </div> </div> <p><a href="https://timerring.github.io/bilive/upload.html" rel="nofollow">常见问题收集</a></p> <div class="markdown-heading" dir="auto"> <p>日志信息</p> <a id="user-content-日志信息" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#%E6%97%A5%E5%BF%97%E4%BF%A1%E6%81%AF" aria-label="Permalink: 日志信息"></a></div> <p>相应的执行日志请在 <code>logs</code> 文件夹中查看,如果有问题欢迎在 <a href="https://github.com/timerring/bilive/issues/new/choose"><code>issue</code></a> 中提出,有异常请优先提供 [debug] 级别的日志。</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto"> <pre class="notranslate"><code>logs # 日志文件夹 ├── record # blrec 录制日志 │ └── ... ├── scan # scan 处理日志 [debug]级别 │ └── ... ├── upload # upload 上传日志 [debug]级别 │ └── ... └── runtime # 每次执行的日志 [info]级别 └── ... </code></pre> <div class="zeroclipboard-container"> </div> </div> <div class="markdown-heading" dir="auto"> <h3 class="heading-element" dir="auto" tabindex="-1">Docker 运行</h3> <a id="user-content-docker-运行" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#docker-%E8%BF%90%E8%A1%8C" aria-label="Permalink: Docker 运行"></a></div> <p>Docker 版本的配置参考同上,登录方式更加简洁,启动后直接 <code>docker logs bilive_docker</code> 在日志中会打印登录二维码,扫码登录即可。</p> <div class="markdown-heading" dir="auto"> <p>无 GPU 版本</p> <a id="user-content-无-gpu-版本" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#%E6%97%A0-gpu-%E7%89%88%E6%9C%AC" aria-label="Permalink: 无 GPU 版本"></a></div> <p>已构建 amd64 及 arm64 版本,会自动根据架构选择。</p> <p><code>your_record_password</code> 为录制页面的密码,请自行设置,最短 8 最长 80。</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto"> <pre>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.1</pre> <div class="zeroclipboard-container"> </div> </div> <div class="markdown-heading" dir="auto"> <p>有 GPU 版本</p> <a id="user-content-有-gpu-版本" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#%E6%9C%89-gpu-%E7%89%88%E6%9C%AC" aria-label="Permalink: 有 GPU 版本"></a></div> <div class="markdown-alert markdown-alert-tip" dir="auto"> <p>Tip</p> <p>使用前请确保你有足够的使用前置知识,如果不熟悉在 docker 中使用 GPU,可以参考 <a href="https://blog.timerring.com/posts/docker-with-gpu/" rel="nofollow">Docker With GPU</a>。</p> </div> <p>有 GPU 版本仅支持 amd64 架构,已内置 small 参数量的模型,如需使用其他参数量模型,请自行按照 2.1.2 步骤调整。<code>your_record_password</code> 规则同上。</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto"> <pre>sudo 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 \ --gpus 'all,"capabilities=compute,utility,video"' \ --name bilive_docker_gpu \ -e RECORD_KEY=your_record_password \ -p 22333:2233 \ ghcr.io/timerring/bilive-gpu:0.3.1</pre> <div class="zeroclipboard-container"> </div> </div> <div class="markdown-heading" dir="auto"> <h3 class="heading-element" dir="auto" tabindex="-1">Docker Compose</h3> <a id="user-content-docker-compose" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#docker-compose" aria-label="Permalink: Docker Compose"></a></div> <p><code>compose.yml</code> 调整方法见 <a href="https://bilive.timerring.com/installation.html" rel="nofollow">Installation</a>。</p> <div class="markdown-heading" dir="auto"> <p>使用镜像</p> <a id="user-content-使用镜像" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#%E4%BD%BF%E7%94%A8%E9%95%9C%E5%83%8F" aria-label="Permalink: 使用镜像"></a></div> <p>如需使用 GPU 版本,请自行在 <code>compose.yml</code> 中调整。</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto"> <pre>docker compose up -d</pre> <div class="zeroclipboard-container"> </div> </div> <div class="markdown-heading" dir="auto"> <p>自行构建</p> <a id="user-content-自行构建" class="anchor" href="https://github.com/timerring/bilive?tab=readme-ov-file#%E8%87%AA%E8%A1%8C%E6%9E%84%E5%BB%BA" aria-label="Permalink: 自行构建"></a></div> <p>请先在 <code>compose.yml</code> 中调整相关配置,然后执行以下命令:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto"> <pre>docker build docker compose up -d</pre> <div class="zeroclipboard-container"> </div> </div> <div class="markdown-heading" dir="auto"> </div>

Medeo

Medeo

<p>Medeo是创新的AI驱动视频制作工具。用户输入简短描述,Medeo能快速生成包含完整剧情、配音和字幕的高清视频。Medeo支持多种视频类型,如故事片、产品演示、培训视频等。Medeo提供从URL生成新闻视频、基于脚本生成悬疑小说视频及生成吉卜力风格动画等功能。Medeo能帮助用户大大节省时间和精力,让视频创作变得简单高效。</p> <p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://img.medsci.cn/aisite/img//7q2VtYPOadiFDgEA7ZBtedes7fvgc3172XCtiYcX.png"></p> <h2 style="font-size: 20px;">Medeo的主要功能</h2> <ul> <li>快速生成视频:输入描述快速生成含剧情、配音和字幕的高清视频,支持故事片、产品演示、培训视频等多种类型。</li> <li>多样化生成方式:从URL生成新闻视频,基于脚本生成悬疑小说视频。</li> <li>智能匹配与调整:具备智能匹配功能,根据描述匹配合适风格和内容,支持对生成视频进行微调。</li> <li>丰富风格选择:提供多种视频风格,如悬疑、喜剧、科幻等。</li> </ul> <h2 style="font-size: 20px;">Medeo的官网地址</h2> <ul> <li>官网地址:<a href="https://ai.medeo.app/create">ai.medeo</a></li> </ul>