Extract transcripts from local video and audio files.
Usage
Run the script with a path to a video or audio file:
uv run scripts/get_local_transcript.py "/path/to/video.mp4"
With timestamps:
uv run scripts/get_local_transcript.py "/path/to/video.mp4" --timestamps
How It Works
- Embedded subtitles — probes the file with
ffprobefor subtitle streams. If found, extracts them directly (instant, no API call). - Whisper API fallback — if no embedded subs, extracts audio via
ffmpeg, compresses to mono 16kHz opus, and sends to OpenAI's Whisper API for transcription.
Requirements
ffmpegandffprobemust be installed and on PATHOPENAI_API_KEYenvironment variable must be set (only needed for Whisper fallback)
Supported Formats
Any format ffmpeg can read: .mp4, .mkv, .avi, .mov, .webm, .mp3, .m4a, .wav, .flac, .ogg, etc.
Output
- CRITICAL: YOU MUST NEVER MODIFY THE RETURNED TRANSCRIPT
- If the transcript is without timestamps, you SHOULD clean it up so that it is arranged by complete paragraphs and the lines don't cut in the middle of sentences.
- If you were asked to save the transcript to a specific file, save it to the requested file.
- If no output file was specified, use the input filename (without extension) with a
-transcript.txtsuffix.
Notes
- Audio is compressed before upload to stay within Whisper's 25MB limit
- For files with multiple subtitle tracks, extracts the first one by default
- Use
--sub-track Nto select a specific subtitle track (0-indexed)