Prompt
How do I process uploaded video files and extract speech to text?
Latest observation
Oct 11, 2026
OpenAI APIWeb search: off
A common way to do this is:
- Accept the uploaded video file
- Extract the audio track
- Run speech-to-text on the audio
- Store/display the transcript
Typical pipeline
1) Upload video
Accept formats like:
.mp4.mov.avi.mkv
Store the file temporarily on your server or in object storage (S3, GCS, etc.).
2) Extract audio from the video
Use a tool like FFmpeg to convert the video into an audio format your speech model accepts, usually:
.wav.mp3.m4a
Example FFmpeg command:
ffmpeg -i input_video.mp4 -vn -acodec pcm_s16le -ar 16000 -ac 1 output.wav
This:
- removes video (
-vn) - converts to 16 kHz mono WAV, which is commonly good for STT
3) Transcribe the audio
You can use:
- OpenAI Whisper
- OpenAI API speech-to-text
- Google Speech-to-Text
- AWS Transcribe
- Azure Speech
- local models like Whisper.cpp or faster-whisper
4) Return/store transcript
Save the text, and optionally:
- timestamps
- speaker labels
- confidence scores
- translations
Example: Python with FFmpeg + Whisper
Install
pip install openai-whisper
sudo apt-get install ffmpeg
Code
import whisper
import subprocess
import os
def extract_audio(video_path, audio_path):
cmd = [
"ffmpeg", "-y",
"-i", video_path,
"-vn",
"-acodec", "pcm_s16le",
"-ar", "16000",
"-ac", "1",
audio_path
]
subprocess.run(cmd, check=True)
def transcribe_video(video_path):
audio_path = "temp_audio.wav"
extract_audio(video_path, audio_path)
model = whisper.load_model("base")
result = model.transcribe(audio_path)
os.remove(audio_path)
return result["text"]
transcript = transcribe_video("uploaded_video.mp4")
print(transcript)
Example: Using OpenAI transcription API
If you already have the extracted audio file:
from openai import OpenAI
client = OpenAI()
with open("output.wav", "rb") as f:
transcript = client.audio.transcriptions.create(
model="gpt-4o-mini-transcribe",
file=f
)
print(transcript.text)
If you’re building a web app
A good architecture is:
- Frontend: upload video
- Backend:
- receive upload
- save file
- enqueue background job
- extract audio with FFmpeg
- transcribe with STT service
- save transcript in DB
- Frontend polls / gets websocket update when transcript is ready
This avoids request timeouts for long videos.
Important considerations
- Large files: process asynchronously
- File validation: check type/size
- Privacy/security: scan uploads, restrict formats
- Scalability: use queue workers
- Accuracy: better audio quality = better transcripts
- Long videos: chunk audio if your STT provider has limits
Recommended simple stack
If you want something practical and reliable:
- FFmpeg for audio extraction
- Whisper / faster-whisper for transcription
- Celery / BullMQ / Sidekiq for background jobs
- S3/GCS for storage
If you want, I can give you a full example in:
- Python (FastAPI)
- Node.js (Express/NestJS)
- React + backend
- AWS Lambda / serverless