Skip to content

CLI 参考

安装

bash
# Option 1: npx (无需安装)
npx sublens-cli extract video.mp4 --output ./subs

# Option 2: Build locally
cd cli && pnpm install && pnpm build
node dist/extract.js

# Option 3: Install via Cargo (完整 Rust 后端)
cargo install --path src-tauri
sublens-cli extract video.mp4 --output ./subs

全局参数

FlagShortTypeDefaultDescription
--help-hflagShow help
--version-vflagShow version
--verboseflagfalseVerbose output
--config-cpathCustom config file

extract — 提取字幕

bash
sublens-cli extract <video> [options]

Arguments

ArgumentDescription
<video>输入视频文件路径

Options

OptionShortTypeDefaultDescription
--output-opath./subsOutput directory
--format-fstringsrtComma-separated formats
--roistringbottomROI preset or x,y,w,h
--ocrstringtesseractEngine: paddle, easyocr, tesseract
--lang-lstringengLanguages (e.g. ch,en, ja, kor)
--confidencenumber70Min confidence 0–100
--frame-intervalnumber1Process every N frames
--scene-thresholdnumber0.3Scene change sensitivity
--no-postprocessflagfalseSkip text post-processing
--no-mergeflagfalseSkip subtitle merging

Supported formats: srt, vtt, ass, ssa, json, txt, lrc, sbv, csv

Examples

bash
# Basic extraction to SRT
sublens-cli extract video.mp4 --output ./subs

# Multi-format output
sublens-cli extract video.mp4 --format srt,vtt,json --output ./subs

# Chinese + English, PaddleOCR engine
sublens-cli extract video.mp4 --ocr paddle --lang ch,en --roi bottom

# Custom ROI coordinates (x,y,width,height in percent)
sublens-cli extract video.mp4 --roi 0,85,100,15

# High confidence threshold
sublens-cli extract video.mp4 --confidence 85

# Process every 2 frames (faster, lower accuracy)
sublens-cli extract video.mp4 --frame-interval 2

Sample output

SubLens CLI v3.2.0 — Video Info
================================
File: video.mp4
Resolution: 1920x1080
Duration: 00:05:23
FPS: 30.00
Total frames: 9688

OCR Engine: tesseract (langs: eng+chi_sim)
ROI: bottom (0, 85, 100, 15)%
Frame interval: 1

Processing: 29% [2812/9688 frames]  ETA: 42s

Done. 47 subtitles extracted.
================================
Output: ./subs/
  video.srt  (47 entries)
  video.json (47 entries + frame mapping)

preview — 预览帧

bash
sublens-cli preview <video> [options]
OptionShortTypeDefaultDescription
--frame-fnumber0Frame number to extract
--roistringDraw ROI rectangle on output
--output-opathstdoutSave preview image
bash
sublens-cli preview video.mp4 --frame 1500 --roi bottom

info — 视频信息

bash
sublens-cli info <video>
video.mp4
========================
Resolution: 1920x1080
Duration: 00:05:23.45
FPS: 30.00
Total frames: 9688
Audio: AAC 48kHz stereo
Codec: H.264 / AVC

退出码

CodeMeaning
0Success
1General error
2Video file not found
3OCR engine initialization failed
4No subtitles found
5Output directory not writable

基于 MIT 许可证发布。