How timerring/bilive works
Project Type and Purpose
• This is a backend-oriented, full-stack pipeline application (a modular monolith) for 24×7 automated recording of Bilibili live streams, rendering of subtitles and danmaku, intelligent slicing, thumbnail generation, and automatic upload.
• Key goals:
• Ingest live streams (video + bullet comments)
• Process/transcode/merge segments
• Generate and burn subtitles and danmaku overlay
• Use LLM/image-gen APIs for slice-title and cover creation
• Upload finished assets back to Bilibili
High-Level Components
Based on file tree and README, the system breaks down into these main modules:
A. Ingestion & Recording
• blrec (in src/upload/bilitool and launched via record.sh)
• Web UI / REST API for task management (settings.toml config)
• Output: raw video files and XML danmaku
B. Pre-Processing / Merging
• src/burn/scan.py & render_then_merge.py
• Merges fragmented streams into continuous MP4
C. Subtitle Generation
• src/subtitle/whisper (local or Whisper API)
• Produces SRT/ASS transcripts
D. Danmaku Conversion
• src/danmaku/DanmakuConvert
• Converts XML bullet files into ASS overlay format
E. Burn / Render
• src/burn/render_video.py
• Uses FFmpeg to burn subtitles (ASS) and danmaku onto video
F. Auto-Slicing & Title Generation
• src/autoslice/auto_slice_video + mllm_sdk/*_sdk.py
• Calls external MLLM APIs (Gemini, Qwen, Zhipu, etc.)
• Identifies high-density segments, returns clip timestamps & titles
G. Cover Generation
• src/cover/cover_generator.py + image_model_sdk/*_sdk.py
• Takes frame snapshots, calls image-gen APIs (DMXAPI, Stability, etc.)
H. Upload
• src/upload/upload.py
• Uses biliup submodule to authenticate & upload full videos & slices
• Reads configuration from bilive.toml
I. Supporting Services
• Configuration (bilive.toml, settings.toml)
• Logging (src/log/logger.py)
• Database connection (lightweight metadata store, src/db/conn.py)
• Shell scripts (record.sh, upload.sh)
• Containerization (Dockerfiles, compose.yml)
Relationships and Data Flow
• Live stream ingestion ↦ raw files (Videos/)
• Raw files ↦ scan & merge ↦ continuous MP4
• MP4 ↦ subtitle generation ↦ ASS/SRT
• XML danmaku ↦ DanmakuConvert ↦ ASS overlay
• MP4 + ASS subtitles + ASS danmaku ↦ burn/render ↦ final MP4
• Final MP4 ↦ autoslice ↦ clip segments + titles
• Final MP4 ↦ cover generator ↦ image assets
• Finished artifacts ↦ upload module ↦ Bilibili via bilitool API
• Throughout: logs to logs/, metadata to DB
Architectural Patterns & Principles
• Pipeline pattern: each stage reads outputs of the previous
• Modular SDK wrappers for external APIs (e.g., one file per model)
• Configuration-driven behavior (three modes: pipeline, append, merge)
• Submodules to separate concerns (DanmakuConvert, bilitool, auto-slice)
• Container-first deployment with Docker & Docker Compose
Technologies & Frameworks
• Python 3.10+ with sub-packages in src/
• FFmpeg for video encoding and overlay
• OpenAI Whisper (local or API) for ASR
• LLM APIs (Gemini, Qwen, etc.) via DMXAPI.cn
• Image generation APIs (Stable Diffusion, Luma, Ideogram, etc.)
• Bilibili upload via bilitool (Python CLI submodule)
• blrec for Bilibili live capture
• VitePress for docs (not part of runtime)
Detail Level
• 8 major components above as separate nodes.
• 3 operation modes (pipeline, append, merge) as variants or notes on the Burn/Subtitle stages.
• Shell scripts (record.sh & upload.sh) kicking off the ingestion and upload flows.