介绍
# Video Message
从文本或音频生成虚拟人视频消息。输出为 Telegram 视频笔记(圆形格式)。
## 安装
```bash npm install -g openclaw-avatarcam ```
## 配置
在 `TOOLS.md` 中进行配置:
```markdown ### Video Message (avatarcam) - avatar: default.vrm - background: #00FF00 ```
### 设置参考
| 设置 | 默认值 | 描述 | |---------|---------|-------------| | `avatar` | `default.vrm` | VRM 虚拟人文件路径 | | `background` | `#00FF00` | 颜色(十六进制)或图像路径 |
## 前置要求
### 系统依赖
| 平台 | 命令 | |----------|---------| | **macOS** | `brew install ffmpeg` | | **Linux** | `sudo apt-get install -y xvfb xauth ffmpeg` | | **Windows** | 安装 ffmpeg 并添加到 PATH | | **Docker** | 请参阅下方的 Docker 部分 |
> **注意:** macOS 和 Windows 不需要 xvfb —— 它们拥有原生显示支持。
### Docker 用户
添加到 `OPENCLAW_DOCKER_APT_PACKAGES`: ``` build-essential procps curl file git ca-certificates xvfb xauth libgbm1 libxss1 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libasound2 libnss3 ffmpeg ```
## 用法
```bash # With color background avatarcam --audio voice.mp3 --output video.mp4 --background "#00FF00"
# With image background avatarcam --audio voice.mp3 --output video.mp4 --background "./bg.png"
# With custom avatar avatarcam --audio voice.mp3 --output video.mp4 --avatar "./custom.vrm" ```
## 作为视频笔记发送
使用 OpenClaw 的 `message` 工具并设置 `asVideoNote`:
``` message action=send filePath=/tmp/video.mp4 asVideoNote=true ```
## 工作流程
1. **读取配置** 从 TOOLS.md(虚拟人、背景) 2. **生成 TTS** 如果给定文本:`tts text="..."` → 音频路径 3. **运行 avatarcam** 使用音频 + 设置 → MP4 输出 4. **作为视频笔记发送** 通过 `message action=send filePath=... asVideoNote=true` 5. **返回 NO_REPLY** 发送后
## 示例流程
用户:“给我发一段说 hello 的视频消息”
```bash # 1. TTS tts text="Hello! How are you today?" → /tmp/voice.mp3
# 2. Generate video avatarcam --audio /tmp/voice.mp3 --output /tmp/video.mp4 --background "#00FF00"
# 3. Send as video note message action=send filePath=/tmp/video.mp4 asVideoNote=true
# 4. Reply NO_REPLY ```
## 技术细节
| 设置 | 值 | |---------|-------| | 分辨率 | 384x384 (正方形) | | 帧率 | 30fps 固定 | | 最大时长 | 60 秒 | | 视频编解码器 | H.264 (libx264) | | 音频编解码器 | AAC | | 质量 | CRF 18 (高质量) | | 封装格式 | MP4 |
### 处理流程 1. Electron 以 1280x720 分辨率渲染带有口型同步的 VRM 虚拟人 2. 通过 `canvas.captureStream(30)` 捕获 WebM 3. FFmpeg 处理:裁剪 → 帧率标准化 → 缩放 → 编码 4. 消息工具通过 Telegram `sendVideoNote` API 发送
## 平台支持
| 平台 | 显示 | 备注 | |----------|---------|-------| | macOS | 原生 Quartz | 无需额外依赖 | | Linux | xvfb (无头模式) | `apt install xvfb` | | Windows | 原生 | 无需额外依赖 |
## 无头渲染
Avatarcam 会自动检测无头环境: - 当 `$DISPLAY` 未设置时使用 `xvfb-run`(仅限 Linux) - macOS/Windows 使用原生显示 - GPU 停滞警告可以安全忽略 - 生成时间:约为实时的 1.5 倍(20 秒音频 ≈ 30 秒处理)
## 备注
- 配置从 TOOLS.md 读取 - 发送后清理临时文件:`rm /tmp/video*.mp4` - 对于普通视频(非圆形),请省略 `asVideoNote=true`