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]
- 与稳定后端的 synthesize 接口保持一致
- 字幕外观由字幕资产/后端版本控制,而非额外的工具标志位
--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 种。