Prompt
How do I integrate a video encoding API with S3 or another storage bucket?
Latest observation
Nov 1, 2026
OpenAI APIWeb search: off
To integrate a video encoding API with S3 or another storage bucket, the usual pattern is:
- Upload the source video to storage
- Send the encoder a reference to that file
- Have the encoder write outputs back to storage
- Use webhooks or polling to track job status
Common architecture
Option A: Encoder pulls from S3
- You upload
input.mp4to S3. - Your app creates an encoding job and passes the S3 URL or object reference to the API.
- The encoder fetches the file from S3, processes it, and uploads results back to S3.
Option B: App uploads directly to the encoding service
- You send the file to the encoding API directly.
- The service stores and processes it.
- Outputs are copied to S3 afterward, or the service stores them in its own CDN/storage.
Option C: Pre-signed URLs
- Your backend generates a pre-signed S3 URL for secure upload.
- The client uploads the file directly to S3.
- Your backend tells the encoder where the source file is.
This is often the best approach for large video files.
Typical flow with S3
1. Upload video to S3
Use a pre-signed URL so users can upload directly from the browser/app.
Example flow:
- Client asks your backend for an upload URL
- Backend returns a pre-signed PUT URL
- Client uploads the file to S3
2. Create encoding job
Your backend calls the encoding API with:
- input file location
- output settings, like resolution, bitrate, container format
- destination bucket/path for outputs
- callback/webhook URL for job completion
Example payload might include:
{
"input": "s3://my-bucket/uploads/video.mp4",
"outputs": [
{
"format": "mp4",
"resolution": "1280x720",
"destination": "s3://my-bucket/encoded/video-720p.mp4"
}
],
"webhook_url": "https://api.example.com/encoding-callback"
}
3. Encoder processes and stores outputs
The encoder:
- reads the input from S3
- transcodes it
- uploads the resulting files to S3 or another bucket
4. Receive completion notification
Use:
- webhooks for event-driven updates, or
- polling if the API doesn’t support callbacks
When complete, update your database with:
- job status
- output URLs
- duration/bitrate/thumbnail metadata
AWS S3 permissions
The encoding service needs permission to:
GetObjecton the input bucket/pathPutObjecton the output bucket/path
If the service is in your AWS account, use an IAM role.
If it’s external, you may need:
- bucket policies allowing the service’s AWS principal
- temporary pre-signed URLs
- or access via a proxy service you control
Security best practices
- Use pre-signed URLs instead of long-lived credentials
- Restrict bucket access to specific prefixes, like
uploads/andoutputs/ - Use server-side encryption on S3
- Validate file type and size before encoding
- Set lifecycle rules to delete temporary uploads after processing
- Verify webhook signatures to avoid spoofed callbacks
Example implementation pattern
Backend steps
- Generate pre-signed upload URL
- Save an upload record in DB
- Client uploads file to S3
- Backend submits encoding job with input/output locations
- Encoder processes file
- Webhook updates job status
- App serves output URL or CDN URL
If your encoder supports S3 natively
Some APIs allow you to pass:
- S3 bucket
- object key
- AWS region
- IAM role or access credentials
In that case, configuration is usually just:
- input bucket
- output bucket
- permissions
- job parameters
If it doesn’t support S3 natively
Use one of these:
- pre-signed GET URL for the input file
- pre-signed PUT URL for the output file
- or your backend acts as a bridge:
- downloads from S3
- uploads to the encoding API
- downloads processed output
- stores output back to S3
Minimal pseudo-flow
Client -> Backend: request upload URL
Backend -> S3: generate pre-signed URL
Client -> S3: upload video
Client -> Backend: notify upload complete
Backend -> Encoder API: create transcode job with S3 input/output
Encoder API -> S3: download input, upload output
Encoder API -> Backend: webhook job complete
Backend -> DB: mark finished
If you want, I can also give you:
- a Node.js example
- a Python example
- an AWS Lambda / S3 / transcoding architecture
- or an example for a specific encoder like Mux, Cloudflare Stream, Bitmovin, AWS MediaConvert, or Zencoder.