Skip to content

A containerized FastAPI microservice that exposes FFmpeg capabilities via a REST API. This service supports advanced codecs (VP9, AV1, H.265, etc.), streaming formats (HLS, DASH), API key-based authentication, webhook notifications, and background processing for large jobs.

License

Notifications You must be signed in to change notification settings

rendiffdev/ffmpeg-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Rendiff FFmpeg API

License: MIT Python Version Docker FFmpeg PostgreSQL Redis

πŸš€ Production-Ready FFmpeg API with AI Enhancement

A comprehensive, containerized FFmpeg processing API with optional AI features. Deploy with a single command - everything from development to enterprise production with GPU acceleration.

✨ Core Features

  • 🎬 Complete FFmpeg API - Process video/audio with RESTful endpoints
  • ⚑ Async Processing - Background jobs with real-time progress tracking
  • πŸ€– AI Enhancement - Optional GPU-accelerated AI features (upscaling, analysis)
  • ☁️ Multi-Cloud Storage - S3, Azure, GCP, and local filesystem support
  • πŸ“Š Quality Analysis - VMAF, PSNR, SSIM metrics and AI-powered insights
  • πŸ›‘οΈ Production Security - API keys, HTTPS, rate limiting, monitoring
  • πŸ“ˆ Observability - Prometheus metrics, Grafana dashboards, health checks
  • 🐳 Docker Native - Complete containerization with auto-scaling

πŸš€ Quick Start

Choose Your Setup Type

# Clone repository
git clone https://github.com/rendiffdev/ffmpeg-api.git
cd ffmpeg-api

# Single command setup - choose your deployment type:
./setup.sh --development    # Quick local development
./setup.sh --standard       # Production (PostgreSQL, Redis, monitoring)
./setup.sh --genai          # AI-enhanced (GPU support, AI models)
./setup.sh --interactive    # Interactive setup wizard

That's it! Your API will be running at:

  • Development: http://localhost:8000
  • Production: https://localhost (HTTPS with self-signed certificate)

πŸƒβ€β™‚οΈ Development (60 seconds)

Perfect for testing and local development:

./setup.sh --development

Features: SQLite, local storage, no auth required, debug mode

🏭 Standard Production

Enterprise-ready deployment:

./setup.sh --standard

Features: PostgreSQL, Redis, monitoring, API keys, HTTPS by default, 2 CPU workers

πŸ€– AI-Enhanced Production

GPU-accelerated AI features:

./setup.sh --genai

Features: Everything in Standard + GPU workers, AI models, upscaling, scene analysis

πŸ“‹ Deployment Comparison

Feature Development Standard GenAI
Setup Time 1 minute 3 minutes 10 minutes
Database SQLite PostgreSQL PostgreSQL
Queue Redis Redis Redis
Authentication Disabled API Keys API Keys
HTTPS/SSL ❌ βœ… (Self-signed + Let's Encrypt) βœ… (Self-signed + Let's Encrypt)
Monitoring Basic Full (Prometheus/Grafana) Full
Workers 1 CPU 2 CPU 2 CPU + 1 GPU
AI Features ❌ ❌ βœ…
GPU Support ❌ ❌ βœ…
Production Ready ❌ βœ… βœ…

🎯 API Endpoints

Core Processing

POST /api/v1/convert      # Universal media conversion
POST /api/v1/analyze      # Quality analysis (VMAF, PSNR, SSIM)
POST /api/v1/stream       # Generate HLS/DASH streaming
POST /api/v1/estimate     # Processing time estimates

Job Management

GET  /api/v1/jobs         # List and filter jobs
GET  /api/v1/jobs/{id}    # Job status and progress
GET  /api/v1/jobs/{id}/events  # Real-time progress (SSE)
DELETE /api/v1/jobs/{id}  # Cancel job

AI Features (GenAI Setup)

POST /api/genai/v1/enhance/upscale     # Real-ESRGAN 2x/4x upscaling
POST /api/genai/v1/analyze/scenes      # AI scene detection
POST /api/genai/v1/optimize/parameters # Smart encoding optimization
POST /api/genai/v1/predict/quality     # Quality prediction

System & Health

GET  /api/v1/health       # Service health check
GET  /api/v1/capabilities # Supported formats and features
GET  /docs                # Interactive API documentation

πŸ”§ Configuration & Management

API Key Management

# Generate secure API keys
./scripts/manage-api-keys.sh generate

# List current keys (masked)
./scripts/manage-api-keys.sh list

# Test API access (development)
curl -H "X-API-Key: your-key" http://localhost:8000/api/v1/health

# Test API access (production - HTTPS)
curl -k -H "X-API-Key: your-key" https://localhost/api/v1/health

HTTPS/SSL Setup

πŸ”’ HTTPS is enabled by default in ALL production deployments with self-signed certificates.

SSL Certificate Options:

Self-signed (Default) - Works immediately:

./setup.sh --standard  # HTTPS ready with self-signed cert

Let's Encrypt (Production) - Free trusted certificates:

# Configure your domain
export DOMAIN_NAME=api.yourdomain.com
export CERTBOT_EMAIL=admin@yourdomain.com

# Setup with Let's Encrypt
./setup.sh --interactive  # Choose HTTPS option during setup

Commercial SSL - EV/OV certificates:

# Install commercial certificate
./scripts/enhanced-ssl-manager.sh install-commercial cert.crt private.key

Comprehensive SSL Management:

# Show all SSL management options
./scripts/enhanced-ssl-manager.sh --help

# Monitor SSL certificates
./scripts/enhanced-ssl-manager.sh monitor-start

# Test SSL configuration
./scripts/enhanced-ssl-manager.sh test-ssl yourdomain.com

Monitoring & Health

# Check deployment status
./setup.sh --status

# Validate configuration
./setup.sh --validate

# Health check all services
./scripts/health-check.sh

# View logs
docker-compose logs -f api

πŸ“Š What's Included

πŸ”§ Core Infrastructure

  • FastAPI - Modern async web framework
  • Celery - Distributed task processing
  • PostgreSQL 15 - Production database with optimizations
  • Redis 7 - Queue and caching layer
  • FFmpeg 6.0 - Latest video processing capabilities

πŸ›‘οΈ Security & Production

  • API Key Authentication with rotation support
  • Rate Limiting at gateway and application level
  • HTTPS/SSL with automatic Let's Encrypt certificates
  • Security Headers (HSTS, CSP, XSS protection)
  • Network Isolation via Docker networks
  • Resource Limits and health monitoring

πŸ“ˆ Monitoring & Observability

  • Prometheus metrics collection
  • Grafana dashboards and visualizations
  • Structured Logging with correlation IDs
  • Health Checks for all services
  • Real-time Progress via Server-Sent Events

πŸ€– AI Features (Optional)

  • Real-ESRGAN - Video/image upscaling (2x, 4x)
  • VideoMAE - Scene detection and analysis
  • VMAF Integration - Perceptual quality metrics
  • Smart Encoding - AI-optimized compression settings
  • Content Analysis - Complexity and scene classification

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Traefik       │────│   KrakenD    │────│   FastAPI       β”‚
β”‚   (SSL/Proxy)   β”‚    β”‚   (Gateway)  β”‚    β”‚   (Core API)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   PostgreSQL    β”‚    β”‚    Redis     β”‚    β”‚   Celery        β”‚
β”‚   (Database)    β”‚    β”‚   (Queue)    β”‚    β”‚   (Workers)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Prometheus    β”‚    β”‚   Grafana    β”‚    β”‚   GPU Workers   β”‚
β”‚   (Metrics)     β”‚    β”‚ (Dashboards) β”‚    β”‚   (AI/GenAI)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“– Documentation

Document Description
Setup Guide Complete setup documentation for all deployment types
API Reference Detailed API endpoint documentation
Installation Guide Advanced installation and configuration
Production Setup Production deployment best practices
HTTPS/SSL Setup Security configuration and best practices

🎯 Use Cases

🎬 Media Companies

  • Automated video transcoding pipelines
  • Quality analysis and optimization
  • Multi-format delivery (HLS, DASH, MP4)
  • AI-enhanced upscaling for archive content

πŸ“Ί Streaming Platforms

  • Adaptive bitrate ladder generation
  • Real-time encoding for live streams
  • Content analysis for recommendation engines
  • Automated thumbnail generation

🏒 Enterprise

  • Internal video processing workflows
  • Compliance and quality monitoring
  • Cost optimization through intelligent encoding
  • Integration with existing media management systems

πŸ”¬ Research & Development

  • Video analysis and metrics collection
  • A/B testing for encoding parameters
  • Machine learning dataset preparation
  • Performance benchmarking

πŸ› οΈ Advanced Features

Storage Backends

# Configure multiple storage options
storage:
  backends:
    s3:          # AWS S3 or compatible
    azure:       # Azure Blob Storage  
    gcp:         # Google Cloud Storage
    local:       # Local filesystem

GPU Acceleration

# Enable hardware acceleration
./setup.sh --genai

# Supports:
# - NVIDIA NVENC/NVDEC
# - Intel Quick Sync Video
# - AMD VCE/VCN
# - Apple VideoToolbox (macOS)

Horizontal Scaling

# Scale API instances
docker-compose up -d --scale api=3

# Scale workers based on load
docker-compose up -d --scale worker-cpu=4
docker-compose up -d --scale worker-genai=2

πŸš€ Production Deployment

Minimum Requirements

  • CPU: 4 cores
  • RAM: 8GB
  • Storage: 50GB SSD
  • Network: 1Gbps

Recommended (GenAI)

  • CPU: 8+ cores
  • RAM: 32GB
  • GPU: NVIDIA RTX 3080/4080 (8GB+ VRAM)
  • Storage: 200GB NVMe SSD
  • Network: 10Gbps

Cloud Deployment

Supports deployment on:

  • AWS (EC2, ECS, EKS)
  • Google Cloud (GCE, GKE)
  • Azure (VM, AKS)
  • DigitalOcean (Droplets, Kubernetes)
  • Self-hosted infrastructure

πŸ“ž Support & Community

🀝 Contributing

We welcome contributions! Please open an issue or submit a pull request on our GitHub repository.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❀️ by the Rendiff team

Transform your video processing workflow with production-ready FFmpeg API and optional AI enhancement.

About

A containerized FastAPI microservice that exposes FFmpeg capabilities via a REST API. This service supports advanced codecs (VP9, AV1, H.265, etc.), streaming formats (HLS, DASH), API key-based authentication, webhook notifications, and background processing for large jobs.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published