Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mutonby/openshorts/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Thesubtitles.py module handles subtitle generation from transcripts and burns them into videos using FFmpeg. It supports both pre-existing transcripts and auto-transcription for dubbed videos.
Key Functions
generate_srt
transcript(dict): Transcript with word-level timestamps (frommain.transcribe_video())clip_start(float): Clip start time in seconds (absolute)clip_end(float): Clip end time in seconds (absolute)output_path(str): Path to save .srt filemax_chars(int): Maximum characters per subtitle line (default: 20 for vertical)max_duration(float): Maximum duration per subtitle block in seconds (default: 2.0)
bool: True if successful, False if no words found in range
- Extracts words within
[clip_start, clip_end]range - Groups words into blocks based on:
- Character limit (default 20 for readability on vertical video)
- Duration limit (default 2 seconds)
- Adjusts timestamps relative to clip start (0-based)
- Writes SRT format with proper timing
generate_srt_from_video
video_path(str): Path to video fileoutput_path(str): Path to save .srt filemax_chars(int): Maximum characters per line (default: 20)max_duration(float): Maximum duration per block (default: 2.0s)
bool: True if successful, False otherwise
- Calls
transcribe_audio()to get transcript - Probes video duration using OpenCV
- Calls
generate_srt()for full video range[0, duration]
burn_subtitles
video_path(str): Input video pathsrt_path(str): Path to .srt subtitle fileoutput_path(str): Output video pathalignment(int): Subtitle position (2=bottom, 6=top, 10=middle)fontsize(int): Font size in pixels (default: 16, scaled 0.5x for libass)
bool: True if successful (raises exception on failure)
- Font: Verdana Bold
- Color: White (
&H00FFFFFF) - Background: Opaque box with 40% opacity black (
&H60000000) - Border Style: 3 (opaque box)
- Alignment: User-specified (default: bottom center)
- Margin: 25px vertical margin
| Value | Position | ASS Code |
|---|---|---|
| 2 | Bottom Center | 2 |
| 6 | Top Center | 6 |
| 10 | Middle Center | 10 |
"top", "middle", "bottom"
transcribe_audio
video_path(str): Path to video file
dictwith keys:segments(list): Transcript segments with word timestampslanguage(str): Detected language code
- Model:
"base" - Device:
"cpu" - Compute Type:
"int8"(optimized for speed)
format_srt_block
index(int): Subtitle sequence number (1-based)start(float): Start time in secondsend(float): End time in secondstext(str): Subtitle text content
str: Formatted SRT block with newlines
00:00:12,340 (12.34 seconds)
SRT Format
Standard SubRip (.srt) format:Example Usage
For Clips with Existing Transcript
For Dubbed Videos (Auto-transcribe)
Dependencies
faster-whisper: Audio transcription (base model, CPU int8)opencv-python(cv2): Video duration extractionffmpeg: Subtitle burning (subprocess)subprocess: FFmpeg execution