Skip to main content

Crate video_subtitle

Crate video_subtitle 

Source
Expand description

§video-subtitle

视频自动字幕库:串联 FFmpeg 与 Whisper,完成「提取音频 → 语音识别 → 生成 SRT → 烧录字幕」全流程。

§流水线

输入视频
  → ffmpeg::extract_audio   (16 kHz 单声道 WAV)
  → whisper::transcribe     (带时间轴的 [`Caption`])
  → srt::write_srt          (SubRip `.srt`)
  → ffmpeg::burn_subtitles  (可选,硬字幕输出)

§作为库使用

use clap::Parser;
use video_subtitle::cli::Cli;
use video_subtitle::pipeline::run;

let cli = Cli::parse();
let output = run(&cli)?;

命令行入口见 src/main.rs

Re-exports§

pub use error::AppError;
pub use error::Result;
pub use pipeline::run;
pub use pipeline::PipelineOutput;
pub use types::Caption;

Modules§

cli
命令行参数定义(基于 clap)。
error
库内统一错误类型与 Result 别名。
ffmpeg
FFmpeg 子进程封装:音频提取与字幕烧录。
pipeline
四步流水线编排:串联 crate::ffmpegcrate::whispercrate::srt 模块。
srt
SubRip(.srt)字幕生成:时间格式化与文件写入。
types
跨模块共享的领域类型与时间换算。
whisper
Whisper 语音识别:加载 WAV、调用 whisper-rs 推理并产出 crate::Caption 列表。