Automatically generate subtitles for video files using FFmpeg and Whisper. Supports English subtitles and Korean translation.
- π¬ Extract audio from video files using FFmpeg
- π€ Generate English subtitles using Whisper AI
- π Translate English subtitles to Korean (free, no API key required)
- π Merge Korean and English subtitles into a single file
- π§Ή Automatic cleanup of temporary files
Download and install Python 3.7 or higher from python.org
Verify installation:
python --versionFFmpeg is used to extract audio from video files.
Option A: Using Chocolatey
First, install Chocolatey (if not already installed):
- Open PowerShell as Administrator
- Run this command:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))- Verify installation:
choco --version
Then install FFmpeg:
choco install ffmpegOption B: Using Winget (Recommended - No extra installation needed)
Winget is built into Windows 10 (version 1809+) and Windows 11. No additional installation required.
Check if winget is available:
winget --versionIf available, install FFmpeg:
winget install ffmpegNote: If winget is not found, you may need to update Windows or use Option A or C instead.
Option C: Manual Installation
- Download from ffmpeg.org
- Extract and add to system PATH
- Or download Windows builds from ffmpeg.zeranoe.com
Verify installation:
ffmpeg -versionInstall all required Python packages using requirements.txt:
pip install -r requirements.txtThis will install:
openai-whisper- For subtitle generationdeep-translator- For translation
Alternative: Install individually
pip install openai-whisper
pip install deep-translatorNote: First run will download the Whisper model (medium size, ~1.4GB). This is a one-time download.
GPU Acceleration (Optional):
By default, pip install openai-whisper installs PyTorch CPU version, which works but is slower. If you have an NVIDIA GPU and want faster processing:
-
First, install the regular packages:
pip install -r requirements.txt
-
Then install PyTorch with CUDA support:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
(Replace
cu118with your CUDA version if different. Check your CUDA version withnvidia-smi)
Note:
- If you don't have an NVIDIA GPU β Skip this step, CPU version will work fine (just slower)
- If you have an NVIDIA GPU β Installing CUDA PyTorch will make processing much faster
Verify installation:
whisper --helpRun these commands to install everything:
# Install Python (if not already installed)
# Download from https://www.python.org/downloads/
# Install FFmpeg (choose one method)
# Option 1: Using Chocolatey (requires Chocolatey installation first)
choco install ffmpeg
# Option 2: Using Winget (Windows 10/11 built-in, no extra installation needed)
winget install ffmpeg
# Option 3: Manual download from ffmpeg.org
# Install Python libraries (recommended)
pip install -r requirements.txt
# OR install individually:
# pip install openai-whisper
# pip install deep-translator# Generate English subtitles only (default)
subtitle_generator.bat video.mp4
# Generate Korean subtitles only (translated from English)
subtitle_generator.bat video.mp4 ko
# Generate both Korean and English subtitles (Korean on top)
subtitle_generator.bat video.mp4 both# Translate SRT file (auto-detects Korean <-> English)
subtitle_generator.bat english.srt translate
subtitle_generator.bat korean.srt translate
# Merge Korean and English SRT files into one file
subtitle_generator.bat korean.srt english.srt merge# English subtitles
subtitle_generator.bat my_video.mp4
# Korean subtitles (translated)
subtitle_generator.bat my_video.mp4 ko
# Bilingual subtitles
subtitle_generator.bat my_video.mp4 both# Translate English SRT to Korean (auto-detected)
subtitle_generator.bat video.srt translate
# Output: video.ko.srt
# Translate Korean SRT to English (auto-detected)
subtitle_generator.bat video.ko.srt translate
# Output: video.en.srt
# Merge Korean and English SRT files
subtitle_generator.bat video.ko.srt video.srt merge
# Output: video.merged.srt (Korean on top, English below)- English only:
video.srt - Korean only:
video.srt(translated from English) - Both languages:
video.srt(Korean on top, English below)
- Translate:
- English β Korean:
video.ko.srt(auto-detected) - Korean β English:
video.en.srt(auto-detected)
- English β Korean:
- Merge:
video.merged.srt(Combined Korean + English subtitles)
Example bilingual subtitle format:
1
00:00:00,000 --> 00:00:02,000
μλ
μ’μ μμΉ¨μ΄μΌ
hi good morning
- Audio Extraction: FFmpeg extracts audio from video file
- Subtitle Generation: Whisper generates English subtitles from audio
- Translation (if needed): Google Translate API (via deep-translator) translates English to Korean
- Merging (if both): Python script merges Korean and English subtitles by time
- Cleanup: Temporary files (WAV, intermediate SRT files) are automatically deleted
subtitle_generator.bat- Main batch script (handles both video and SRT files)process_subtitle.py- Main Python script that orchestrates the workflowmerge_srt.py- Merges Korean and English SRT filestranslate_srt.py- Translates English SRT to Koreanrequirements.txt- Python package dependencies
- Internet Connection: Required for translation feature (uses Google Translate)
- Processing Time: Translation may take time depending on subtitle count
- Rate Limiting: Excessive use may result in temporary blocking (built-in delays help prevent this)
- Model Size: Whisper medium model (~1.4GB) is downloaded on first use
- Supported Formats: Any video format supported by FFmpeg (MP4, AVI, MKV, etc.)
To check if your system can use GPU acceleration:
Method 1: Check PyTorch CUDA support
python -c "import torch; print('CUDA available:', torch.cuda.is_available()); print('CUDA version:', torch.version.cuda if torch.cuda.is_available() else 'N/A')"- If output shows
CUDA available: Trueβ GPU will be used automatically - If output shows
CUDA available: Falseβ Only CPU will be used (slower)
Method 2: Check NVIDIA GPU and driver
nvidia-smi- If this command works and shows GPU info β NVIDIA GPU is detected
- If command not found β No NVIDIA GPU or driver not installed
Method 3: Check if CUDA toolkit is installed
nvcc --version- If this shows CUDA version β CUDA toolkit is installed
- If command not found β CUDA toolkit may not be installed
Note: Even if you have an NVIDIA GPU, you need:
- NVIDIA GPU driver installed
- CUDA toolkit installed (optional, but recommended)
- PyTorch with CUDA support installed (see Prerequisites section for installation)
When do you need CUDA PyTorch?
- β You have NVIDIA GPU + want faster processing β Install CUDA PyTorch
- β You don't have NVIDIA GPU β Use default CPU version (no extra installation needed)
- β You have GPU but don't mind slower processing β Use default CPU version
- Make sure FFmpeg is installed and added to system PATH
- Restart command prompt after installation
- Verify installation:
pip install openai-whisper - Check if Python Scripts folder is in PATH
- Check internet connection
- Verify deep-translator is installed:
pip install deep-translator - Wait a few minutes if rate limited
- Install Python from python.org
- Make sure "Add Python to PATH" is checked during installation
This project uses:
- FFmpeg - Audio/video processing
- OpenAI Whisper - Speech recognition
- deep-translator - Translation service