Server to execute ffmpeg commands
4.3K
A production-ready HTTP server for executing FFmpeg commands with automatic file upload to Supabase Storage. Built with TypeScript, Express, and modern best practices.
linux/amd64 and linux/arm64docker run -p 5675:5675 \
-e SUPABASE_URL=your_supabase_url \
-e SUPABASE_SERVICE_ROLE_KEY=your_service_role_key \
-e SUPABASE_BUCKET=ffmpeg-outputs \
udaian/ffmpeg-server:latest
The server will be available at http://localhost:5675
# Health check
curl http://localhost:5675/health
# Execute FFmpeg command
curl -X POST http://localhost:5675/execute-ffmpeg \
-H "Content-Type: application/json" \
-d '{
"command": "ffmpeg -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 -c:v libx264 -pix_fmt yuv420p output.mp4"
}'
| Variable | Required | Default | Description |
|---|---|---|---|
PORT | No | 5675 | HTTP server port |
SUPABASE_URL | Yes | - | Your Supabase project URL |
SUPABASE_SERVICE_ROLE_KEY | Yes | - | Service role key for server-side operations |
SUPABASE_BUCKET | No | ffmpeg-outputs | Storage bucket name for processed files |
GET /healthHealth check endpoint that verifies FFmpeg availability.
Response:
{
"status": "healthy",
"timestamp": "2025-12-06T10:30:00.000Z",
"ffmpegVersion": "ffmpeg version 7.1"
}
POST /execute-ffmpegExecute FFmpeg commands with automatic file upload to Supabase.
Request Body:
{
"command": "ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4"
}
Requirements:
ffmpeg (space after ffmpeg)>, |, &&, etc.) are not allowedSuccess Response (200):
{
"success": true,
"stdout": "",
"stderr": "ffmpeg output logs...",
"exitCode": 0,
"outputs": [
{
"filename": "output.mp4",
"path": "1733481000000-output.mp4",
"url": "https://your-project.supabase.co/storage/v1/object/public/ffmpeg-outputs/1733481000000-output.mp4",
"size": 1048576,
"contentType": "video/mp4"
}
]
}
Error Response (4xx/5xx):
{
"success": false,
"error": "Error message",
"errorType": "validation|timeout|spawn|execution|parse|storage",
"details": [
{
"field": "command",
"message": "Command must start with 'ffmpeg '"
}
]
}
curl -X POST http://localhost:5675/execute-ffmpeg \
-H "Content-Type: application/json" \
-d '{
"command": "ffmpeg -i input.mp4 -c:v libx264 -preset fast output.mp4"
}'
curl -X POST http://localhost:5675/execute-ffmpeg \
-H "Content-Type: application/json" \
-d '{
"command": "ffmpeg -i video.mp4 -vn -acodec libmp3lame -q:a 2 audio.mp3"
}'
curl -X POST http://localhost:5675/execute-ffmpeg \
-H "Content-Type: application/json" \
-d '{
"command": "ffmpeg -i video.mp4 -ss 00:00:05 -vframes 1 thumbnail.jpg"
}'
curl -X POST http://localhost:5675/execute-ffmpeg \
-H "Content-Type: application/json" \
-d '{
"command": "ffmpeg -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 -c:v libx264 -pix_fmt yuv420p test.mp4"
}'
curl -X POST http://localhost:5675/execute-ffmpeg \
-H "Content-Type: application/json" \
-d '{
"command": "ffmpeg -i input.mp4 -vf scale=1920:1080 hd.mp4 -vf scale=1280:720 sd.mp4"
}'
Create a docker-compose.yml:
version: '3.8'
services:
ffmpeg-server:
image: udaian/ffmpeg-server:latest
ports:
- "5675:5675"
environment:
- PORT=5675
- SUPABASE_URL=${SUPABASE_URL}
- SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}
- SUPABASE_BUCKET=ffmpeg-outputs
restart: unless-stopped
Run with:
docker-compose up -d
docker run -p 8080:8080 \
-e PORT=8080 \
-e SUPABASE_URL=your_url \
-e SUPABASE_SERVICE_ROLE_KEY=your_key \
udaian/ffmpeg-server:latest
docker run -p 5675:5675 \
-v $(pwd)/logs:/app/logs \
-e SUPABASE_URL=your_url \
-e SUPABASE_SERVICE_ROLE_KEY=your_key \
udaian/ffmpeg-server:latest
docker run -p 5675:5675 \
--cpus="2.0" \
--memory="4g" \
-e SUPABASE_URL=your_url \
-e SUPABASE_SERVICE_ROLE_KEY=your_key \
udaian/ffmpeg-server:latest
min(max(floor(CPU_COUNT / 2), 2), 8)ffmpeg )>, |, &&, etc.)If you see "Failed to spawn FFmpeg process", the image should include FFmpeg. Verify with:
docker run udaian/ffmpeg-server:latest ffmpeg -version
Ensure the port mapping matches the PORT environment variable:
docker run -p 5675:5675 -e PORT=5675 udaian/ffmpeg-server:latest
Check your environment variables:
# Test with debug output
docker run -p 5675:5675 \
-e SUPABASE_URL=your_url \
-e SUPABASE_SERVICE_ROLE_KEY=your_key \
-e SUPABASE_BUCKET=ffmpeg-outputs \
udaian/ffmpeg-server:latest
For longer operations, consider:
-preset ultrafast)--cpus and --memorylinux/amd64 (x86_64)linux/arm64 (ARM64/Apple Silicon)Built on Node.js v24.11.1 with FFmpeg 7.1
latest - Latest stable release1 - Major version 11.0 - Minor version 1.01.0.0 - Specific patch versionMIT License - See LICENSE file for details
Udayan Maurya
Note: This server is designed for controlled environments. Always validate and sanitize FFmpeg commands in production. Never expose directly to untrusted users without additional authentication and authorization layers.
Content type
Image
Digest
sha256:cb1bc1bef…
Size
117.5 MB
Last updated
27 days ago
docker pull udaian/ffmpeg-server