A Python project for generating video subtitles using speech-to-text and overlaying captions on videos. Built with MoviePy, Faster-Whisper, and ffmpeg-python.
- Extracts audio from MP4 videos
- Transcribes speech to text using Faster-Whisper
- Automatically generates and formats subtitles
- Overlays styled captions onto the original video
- Fully configurable subtitle appearance (font, color, stroke, etc.)
- Python 3.8+
- See
requirements.txtfor dependencies - ImageMagick (required by MoviePy for text rendering)
- Clone this repository:
git clone https://github.com/alex45101/Video-Caption.git cd Video-Caption - Install Python dependencies:
pip install -r requirements.txt
- Install ImageMagick and add it to your PATH (Windows users: ensure legacy utilities are enabled).
- Place your video file (e.g.,
IMG_0002.mp4) in the project directory. - Edit
info.jsonto configure subtitle options and specify the video filename. - Run the main script:
python main.py
- The output video with captions will be saved as
output.mp4.
info.json: Set subtitle appearance, timing, and video filename.requirements.txt: Minimal dependencies for the project.
{
"Filename" : "IMG_0002.mp4",
"Subtitle Info" : {
"Max Chars" : 20,
"Max Duration" : 2.0,
"Max Gap" : 1.5,
"Font" : "Segoe UI Semibold",
"Font Size" : 120,
"Color" : "#fdff7a",
"Stroke Color" : "black",
"Stroke Width" : 2,
"Shadow" : true,
"Shadow Color" : "black"
}
}
MIT License
Feel free to open issues or contribute!