# wizlijun/claude_video_tranlater architecture

> Architecture diagram of the GitHub repository wizlijun/claude_video_tranlater, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wizlijun/claude_video_tranlater
- Repository: https://github.com/wizlijun/claude_video_tranlater

## Overview

##### Project Type and Purpose
- This is a command-line, full-workflow video subtitle extraction, translation, and dubbing pipeline.
- It stitches together download, audio extraction, Whisper ASR, subtitle optimization, Claude AI translation, IndexTTS voice synthesis, and FFmpeg–based video composition into a single automated toolchain.

##### Main Components
A. Ingestion & Download
- Scripts: `getvideo.sh`, `download_and_process.sh`
- External: YouTube-dl or similar fetcher
- Output: raw video file (e.g., `video.mp4`)
B. Pre-Processing (process_video_part1.sh)
- Audio Extraction: FFmpeg → `original_audio.wav`
- ASR & Subtitle Extraction: `get_srt_by_wisper.py` (OpenAI Whisper) → `step2_whisper.srt`
- Subtitle Optimization: built-in in `get_srt_by_wisper.py` (merging, segmentation, clean-up)
C. Translation (translate_by_claude.sh)
- Input: `step2_whisper.srt`
- Service: Claude CLI → `step3_translated.srt`
D. Post-Processing (process_video_part2.sh / process_video_part2_plus.sh)
- Text-to-Speech: IndexTTS → `step5_chinese_audio.wav`
- Final Composition: FFmpeg overlays translated SRT + dubs audio → final `video_translated.mp4`
E. Offline Text-Normalization Library
- Path: `models/wetext/…` containing FSTs for tokenization, punctuation removal, ITN, etc.
- Used by `get_srt_by_wisper.py` for local text cleanup.
F. Auxiliary Tools
- Markdown Generation: `genmarkdown_by_claude.sh` → `{video}.md`
- Publishing: `post_to_bilibili.sh`, `post_to_xiaohongshu.sh`

##### Data Flow & Relationships
raw video → audio (.wav) → ASR SRT → optimized SRT → translated SRT → TTS audio → final video
- Each stage reads upstream artifacts from `{video}_temp/` folder.
- Scripts detect existing files for checkpoint/ resume.
- External services (Whisper, Claude, IndexTTS) are called via Python or CLI wrappers.

##### Architectural Patterns & Principles
- Batch Processing Pipeline: clear sequential stages with checkpoint support.
- Modular CLI Components: each logical step (download, ASR, translate, TTS, compose) isolated in its own script.
- Pluggable External Services: Whisper, Claude AI, IndexTTS, FFmpeg.
- Local Model Library: FST-based normalization for offline subtitle optimization.

##### Technologies & Frameworks
- Bash / shell scripts for orchestration.
- Python 3.8+ for ASR (`get_srt_by_wisper.py`) and utilities (`utils/`).
- FFmpeg for audio/video processing.
- OpenAI Whisper (`pip install openai-whisper`).
- Claude CLI for translation.
- IndexTTS for Chinese voice synthesis.
- FST models under `models/wetext/`.

- Notes for critical design choices (e.g., “supports resume”, “modular CLI”).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Ingestion Layer
    subgraph "Ingestion Layer"
        getvideo["getvideo.sh"]:::internal
        download_and_process["download_and_process.sh"]:::internal
    end

    %% Storage / Checkpoint
    temp["{video}_temp/ (Resume Point)"]:::storage

    getvideo --> temp
    download_and_process --> temp

    %% Core Processing Layer
    subgraph "Core Processing Layer"
        subgraph "Pre-Processing"
            proc1["process_video_part1.sh"]:::internal
            ffmpeg_audio["FFmpeg (Audio Extraction)"]:::external
            orig_audio["original_audio.wav"]:::storage
            whisper_script["get_srt_by_wisper.py"]:::internal
            path_helper["path_helper.sh / utils/path_helper.sh"]:::internal
            opt_srt["step2_whisper.srt"]:::storage
            offline_model["Offline Model Library\n(models/wetext)"]:::storage
        end

        subgraph "Translation"
            translate_by_claude["translate_by_claude.sh"]:::internal
            claude["Claude CLI"]:::external
            step3_srt["step3_translated.srt"]:::storage
        end

        subgraph "Post-Processing"
            tts_service["IndexTTS (TTS)"]:::external
            dub_audio["step5_chinese_audio.wav"]:::storage
            process2["process_video_part2.sh"]:::internal
            process2p["process_video_part2_plus.sh"]:::internal
            ffmpeg_comp["FFmpeg (Composition)"]:::external
            final_video["video_translated.mp4"]:::storage
        end
    end

    %% Publishing Layer
    subgraph "Publishing Layer"
        genmd["genmarkdown_by_claude.sh"]:::internal
        post_bili["post_to_bilibili.sh"]:::internal
        post_xhs["post_to_xiaohongshu.sh"]:::internal
    end

    %% Data Flow
    temp --> proc1
    proc1 --> ffmpeg_audio
    ffmpeg_audio --> orig_audio
    orig_audio --> whisper_script
    whisper_script --> opt_srt
    offline_model -.-> whisper_script

    opt_srt --> translate_by_claude
    translate_by_claude --> claude
    claude --> step3_srt

    step3_srt --> tts_service
    tts_service --> dub_audio
    dub_audio --> process2
    dub_audio --> process2p
    process2 --> ffmpeg_comp
    process2p --> ffmpeg_comp
    ffmpeg_comp --> final_video

    final_video --> genmd
    genmd --> post_bili
    genmd --> post_xhs

    %% Click Events
    click getvideo "https://github.com/wizlijun/claude_video_tranlater/blob/main/./getvideo.sh"
    click download_and_process "https://github.com/wizlijun/claude_video_tranlater/blob/main/./download_and_process.sh"
    click proc1 "https://github.com/wizlijun/claude_video_tranlater/blob/main/./process_video_part1.sh"
    click whisper_script "https://github.com/wizlijun/claude_video_tranlater/blob/main/./get_srt_by_wisper.py"
    click path_helper "https://github.com/wizlijun/claude_video_tranlater/blob/main/./utils/path_helper.sh"
    click translate_by_claude "https://github.com/wizlijun/claude_video_tranlater/blob/main/./translate_by_claude.sh"
    click process2 "https://github.com/wizlijun/claude_video_tranlater/blob/main/./process_video_part2.sh"
    click process2p "https://github.com/wizlijun/claude_video_tranlater/blob/main/./process_video_part2_plus.sh"
    click offline_model "https://github.com/wizlijun/claude_video_tranlater/blob/main/./models/wetext/configuration.json"
    click genmd "https://github.com/wizlijun/claude_video_tranlater/blob/main/./genmarkdown_by_claude.sh"
    click post_bili "https://github.com/wizlijun/claude_video_tranlater/blob/main/./post_to_bilibili.sh"
    click post_xhs "https://github.com/wizlijun/claude_video_tranlater/blob/main/./post_to_xiaohongshu.sh"

    %% Styles
    classDef internal fill:#cfe2f3,stroke:#000;
    classDef external fill:#f4cccc,stroke:#000;
    classDef storage fill:#d9ead3,stroke:#000;
```
