Prompt
How do I transcode uploaded videos into multiple formats with an API?
Latest observation
Nov 1, 2026
OpenAI APIWeb search: off
A common pattern is:
- Upload the source video
- Create a transcode job specifying output formats/resolutions/codecs
- Process asynchronously in a worker/queue
- Store outputs in object storage/CDN
- Report job status back through polling or webhooks
Typical API flow
1) Upload
POST /videos
Content-Type: multipart/form-data
Response:
{
"videoId": "vid_123",
"uploadUrl": "https://storage.example.com/...",
"status": "uploaded"
}
2) Start transcoding
POST /videos/vid_123/transcode
Content-Type: application/json
Example body:
{
"outputs": [
{ "format": "mp4", "resolution": "1080p", "videoCodec": "h264", "audioCodec": "aac" },
{ "format": "mp4", "resolution": "720p", "videoCodec": "h264", "audioCodec": "aac" },
{ "format": "webm", "resolution": "720p", "videoCodec": "vp9", "audioCodec": "opus" }
]
}
Response:
{
"jobId": "job_456",
"status": "queued"
}
3) Check status
GET /transcode-jobs/job_456
Response:
{
"jobId": "job_456",
"status": "processing",
"progress": 65,
"outputs": [
{ "format": "mp4", "resolution": "1080p", "url": null },
{ "format": "mp4", "resolution": "720p", "url": null },
{ "format": "webm", "resolution": "720p", "url": null }
]
}
When finished:
{
"jobId": "job_456",
"status": "completed",
"progress": 100,
"outputs": [
{ "format": "mp4", "resolution": "1080p", "url": "https://cdn.example.com/vid_123_1080p.mp4" },
{ "format": "mp4", "resolution": "720p", "url": "https://cdn.example.com/vid_123_720p.mp4" },
{ "format": "webm", "resolution": "720p", "url": "https://cdn.example.com/vid_123_720p.webm" }
]
}
Backend implementation ideas
Option A: Use FFmpeg in your own workers
- API receives job request
- Save job to DB/queue
- Worker pulls job
- Runs
ffmpegto generate each output - Uploads files to S3/GCS/Azure Blob
- Updates job status
Example FFmpeg commands:
ffmpeg -i input.mp4 -c:v libx264 -preset medium -b:v 5M -c:a aac output_1080p.mp4
ffmpeg -i input.mp4 -c:v libx264 -preset medium -b:v 3M -c:a aac output_720p.mp4
ffmpeg -i input.mp4 -c:v libvpx-vp9 -c:a libopus output_720p.webm
Option B: Use a managed video API
If you don’t want to manage encoding infrastructure, use a service like:
- AWS Elemental MediaConvert
- Mux
- Cloudflare Stream
- Bitmovin
- Zencoder
These usually provide:
- Upload URLs
- Transcode presets
- Webhooks for completion
- CDN delivery
Recommended API features
- Asynchronous jobs (don’t block the request)
- Presets instead of raw FFmpeg settings for easier client use
- Webhooks for completion/failure notifications
- Idempotency keys to avoid duplicate jobs
- Retry logic for transient failures
- Signed URLs for secure uploads/downloads
- Rate limiting and validation of supported outputs
Minimal endpoint design
POST /videos→ create video record / upload URLPOST /videos/{id}/transcode→ start jobGET /transcode-jobs/{id}→ statusPOST /webhooks/video-transcode→ receive completion callback
If you want, I can sketch a complete example in Node.js, Python/FastAPI, or Go with FFmpeg and a job queue.