cli-anything-videocaptioner
AI 驱动的视频字幕工具。转录语音 → 优化字幕 → 翻译 → 嵌入视频。
安装
pip install cli-anything-videocaptioner
前置条件:
- Python 3.10-3.12(
videocaptioner1.4.1 需要>=3.10,<3.13) - 必须安装
videocaptioner(pip install videocaptioner) - 视频合成需要 FFmpeg
使用
基本命令
# 显示帮助
cli-anything-videocaptioner --help
# 启动交互式 REPL 模式
cli-anything-videocaptioner
# 转录视频(免费,无需配置)
cli-anything-videocaptioner transcribe video.mp4 --asr bijian
# 翻译字幕(免费 Bing 翻译器)
cli-anything-videocaptioner subtitle input.srt --translator bing --target-language en
# 完整流水线:转录 → 翻译 → 嵌入字幕
cli-anything-videocaptioner process video.mp4 --asr bijian --translator bing --target-language en --subtitle-mode hard
# 在最终硬编码前审查字幕/脚本一致性
cli-anything-videocaptioner synthesize video.mp4 -s subtitles.srt \
--subtitle-mode hard \
--review-script approved_script.txt
# 渲染一帧字幕预览以供审查
cli-anything-videocaptioner review subtitles.srt \
--script approved_script.txt \
--preview-video video.mp4 \
--preview-output review_5s.png
# JSON 输出(供 Agent 消费)
cli-anything-videocaptioner --json transcribe video.mp4 --asr bijian
REPL 模式
当未带子命令调用时,CLI 会进入交互式 REPL 会话:
cli-anything-videocaptioner
# 使用 Tab 补全和历史记录交互式输入命令
命令组
transcribe — 语音转字幕
transcribe <input> [--asr bijian|jianying|whisper-api|whisper-cpp] [--language CODE] [--format srt|ass|txt|json] [-o PATH]
bijian(默认):免费,支持中英文,无需配置whisper-api:支持所有语言,需要--whisper-api-key
subtitle — 优化和翻译
subtitle <input.srt> [--translator llm|bing|google] [--target-language CODE] [--layout target-above|source-above|target-only|source-only] [--no-optimize] [--no-translate] [-o PATH]
- 三个步骤:分句 → 优化 → 翻译
- Bing/Google 翻译器免费
- 支持 38 种目标语言(BCP 47 代码)
synthesize — 将字幕嵌入视频
synthesize <video> -s <subtitle> [--subtitle-mode soft|hard] [--quality ultra|high|medium|low] [-o PATH] [--review-script PATH] [--max-script-diff-ratio FLOAT]
- 镜像稳定后端合成接口
- 字幕外观由字幕资源/后端版本控制,而非额外的封装标记
--review-script在最终导出前检查字幕/脚本偏差- 当复制准确性比容错性更重要时,使用较低的
--max-script-diff-ratio
process — 完整流水线
process <input> [--asr ...] [--translator ...] [--target-language ...] [--subtitle-mode ...] [--layout ...] [--no-optimize] [--no-translate] [--no-synthesize] [-o PATH]
review — 一致性检查和预览
review <input.srt|input.ass> [--script PATH] [--max-diff-ratio FLOAT] [--preview-video PATH] [--preview-at TC] [--preview-output PATH]
- 在硬编码前检测字幕/脚本偏差
- 可以渲染单个审查帧,而不是生成完整的最终视频
styles — 列出样式预设
styles
- 报告已安装的后端是否暴露了预设样式支持
config — 管理设置
config show
config set <key> <value>
download — 下载在线视频
download <URL> [-o DIR]
JSON 输出
所有命令均支持 --json 以实现机器可读输出:
cli-anything-videocaptioner --json transcribe video.mp4 --asr bijian
# {"output_path": "/path/to/output.srt"}
后端说明
- 上游后端当前要求 Python
>=3.10,<3.13;对于矩阵运行,推荐 Python3.12。 - 高级合成时样式标记依赖于后端版本。使用
styles检查已安装的后端是否暴露了这些标记。 - 像
layout、render_mode、style、style_override和font_file这样的兼容性标记,除非styles和已安装的后端确认支持,否则应视为非稳定。
目标语言
BCP 47 代码:zh-Hans zh-Hant en ja ko fr de es ru pt it ar th vi id 以及另外 23 种。