A powerful and intuitive video captioning tool with automatic speech recognition and custom font support.
- 📽️ Video preview with real-time captioning
- 🎙️ Automatic speech transcription using OpenAI's Whisper model
- 🎭 Custom caption style presets
- 🔤 Custom TTF font support
- 🗣️ Multi-language support, including mixed language detection
- 🖥️ GPU acceleration with automatic detection
- 🎬 High-quality video rendering with perfect captions
- Python 3.8 or higher
- FFmpeg (must be installed and available in your PATH)
- PyQt6
- NVIDIA GPU (optional, for faster transcription)
- Clone the repository:
git clone https://github.com/yourusername/captioner.git
cd captioner- Create a virtual environment (optional but recommended):
python -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Run the application:
python caption-tool/main.py- Load a video file using the "Load Video" button
- Navigate through the video using the playback controls
- Download the Whisper model if you haven't already (one-time setup)
- Use auto-transcribe for automatic captions or manually type captions
- Apply style presets to your captions
- Render the final video with embedded captions
- Go to the caption editor by clicking "Edit Presets"
- Click "Upload TTF..." to upload your own TTF font files
- Select your custom font from the dropdown when creating or editing presets
- Your custom fonts will be used when rendering the final video
The tool supports multiple languages for transcription:
- English
- Hindi (Romanized)
- Mixed language detection
The tool automatically detects and uses your GPU for faster transcription. If your GPU isn't being used, check the "GPU Diagnostics" section in the application.
caption-tool/
├── data/ # Stores captions data
├── gui/ # UI components
│ ├── caption_preview.py # Video preview widget
│ ├── main_ui.py # Main application window
│ └── preset_editor.py # Caption style editor
├── presets/ # Caption style presets
│ ├── fonts/ # Custom TTF fonts directory
│ └── presets.json # Preset configurations
├── utils/ # Utility modules
│ ├── audio_player.py # Audio playback handling
│ ├── ffmpeg.py # FFmpeg integration
│ ├── preset_manager.py # Manages caption presets
│ └── whisper_transcriber.py # Speech recognition
└── main.py # Application entry point
The main application window that manages the overall workflow:
- Video Preview: Displays the current video frame with captions
- Playback Controls: Navigate through the video in 5-second segments
- Transcription: Integrates with Whisper for automatic speech recognition
- Caption Editing: UI for creating and editing captions
- Rendering: Exports videos with embedded captions
Manages all video and audio processing:
- Video Information: Extracts metadata from video files
- Frame Extraction: Captures specific frames for preview
- Audio Extraction: Separates audio for transcription
- Caption Rendering: Generates drawtext filters for captions
- Final Rendering: Combines video, audio, and captions into output file
Handles speech recognition:
- Model Management: Downloads and loads Whisper models
- Transcription: Processes audio segments to text
- GPU Acceleration: Automatically uses GPU when available
- Language Support: Handles multiple languages and mixed speech
Manages caption style presets:
- Preset Storage: Saves and loads presets from JSON
- Font Management: Handles custom TTF fonts
- Style Application: Applies styles to captions in preview and rendering
-
Navigation Anti-Glitch
- Added timer-based cooldown between navigation actions
- Prevents rapid clicking that can cause playback issues
- Disabled navigation during active playback
-
Playback Monitoring
- Implemented thread-based playback monitoring
- Properly signals when audio playback completes
- Updates UI state automatically after playback
-
Aspect Ratio Handling
- Improved aspect ratio calculation based on original video dimensions
- Fixed 9:16 conversion issues by calculating appropriate dimensions
- Ensured minimum dimensions to prevent encoder errors
-
Font Handling
- Enhanced font path handling for custom TTF fonts
- Added validation to check if font files exist
- Implemented proper fallback to system fonts
-
Error Prevention
- Added validation for directories before file operations
- Implemented comprehensive error handling in FFmpeg operations
- Added better diagnostics for rendering issues
-
Open Folder Integration
- Added button to directly open the render output folder
- Provides easier access to rendered videos
-
UI Responsiveness
- Added proper signals and slots for background operations
- Ensured UI updates during long-running processes
Create and customize caption presets with:
- Font selection
- Size
- Color
- Position
- Animation effects
The tool supports:
- Custom aspect ratios
- Different scaling modes
- Fine-tuned caption positioning
If your GPU isn't being utilized:
- Check that you have the latest NVIDIA drivers installed
- Try using the "Force GPU" option in the GPU Diagnostics dialog
- Ensure you have PyTorch installed with CUDA support
- For faster transcription, use a smaller Whisper model (tiny or base)
- Close other GPU-intensive applications while transcribing
- For higher quality, use the "medium" or "large-v3" models (requires more GPU memory)
- If custom fonts aren't appearing, check that TTF files are properly installed
- For aspect ratio problems, try the "contain" mode instead of "cover"
- If FFmpeg errors occur, check the detailed error message in the render dialog
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI Whisper for the speech recognition
- FFmpeg for video processing
- PyQt6 for the GUI