Powerful serverless API for merging audio and video files using E2B sandboxes and FFmpeg.
Cost-effective (~$0.20/month for 10k requests), fast, and reliable.
API Endpoints
1. Merge Video & Audio (Async)
POST /api/merge
{
"videoUrl": "https://example.com/video.mp4",
"audioUrl": "https://example.com/audio.mp3",
"outputFormat": "mp4"
}
Response (Immediate, ~100ms):
{
"success": true,
"jobId": "uuid",
"status": "queued",
"message": "Job queued for processing",
"statusUrl": "/api/status?jobId=uuid"
}
2. Upload Files
POST /api/upload
Content-Type: multipart/form-data
FormData:
- file:
- type: "video" | "audio"
Response:
{
"success": true,
"fileName": "video-123456789-input.mp4",
"fileUrl": "https://..."
}
3. Check Job Status (Real-time)
GET /api/status?jobId=uuid
Response (queued):
{
"jobId": "uuid",
"status": "queued",
"createdAt": "2024-10-21T12:00:00Z"
}
Response (processing):
{
"jobId": "uuid",
"status": "processing",
"progress": 50,
"updatedAt": "2024-10-21T12:00:30Z"
}
Response (completed):
{
"jobId": "uuid",
"status": "completed",
"progress": 100,
"resultUrl": "https://...",
"completedAt": "2024-10-21T12:01:00Z"
}
4. Health Check
GET /api/health
Response:
{
"status": "ok",
"service": "video-audio-merger-e2b",
"version": "2.0.0"
}
Quick Start (Async Workflow)
# Step 1: Submit job (returns immediately)
curl -X POST https://your-worker.workers.dev/api/merge \
-H "Content-Type: application/json" \
-H "X-API-Key: your-key" \
-d '{
"videoUrl": "https://example.com/video.mp4",
"audioUrl": "https://example.com/audio.mp3",
"outputFormat": "mp4"
}'
# Response: { "jobId": "abc-123", "status": "queued" }
# Step 2: Check status (poll every 5-10 seconds)
curl https://your-worker.workers.dev/api/status?jobId=abc-123 \
-H "X-API-Key: your-key"
# When status="completed", use resultUrl to download