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 輸出(供代理使用)
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]
- 鏡像穩定的後端合成介面
- 字幕外觀由字幕資產/後端版本控制,而非額外的 harness 標誌
--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 種。