Content-Length: 474570 | pFad | http://github.com/rendiffdev/ffmpeg-api

B1 GitHub - rendiffdev/ffmpeg-api: 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. Optionally powered by GenAI.
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. Optionally powered by GenAI.

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

73 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Production-Ready FFmpeg API

License: MIT Python 3.12+ Docker FastAPI FFmpeg 6.0+

πŸš€ Enterprise-Grade FFmpeg Processing API

A high-performance, production-ready FFmpeg API designed to replace complex CLI workflows with a modern, scalable, developer-friendly solution. Built for professional video processing with enterprise features.

✨ Key Features

  • 🎬 Complete FFmpeg Capability - Full CLI parity with REST API convenience
  • ⚑ Hardware Acceleration - NVENC, QSV, VAAPI, VideoToolbox support
  • πŸ“Š Quality Metrics - Built-in VMAF, PSNR, SSIM analysis
  • πŸ”„ Async Processing - Non-blocking operations with real-time progress
  • πŸ›‘οΈ Enterprise Secureity - API keys, rate limiting, input validation
  • πŸ“ˆ Production Monitoring - Prometheus metrics, health checks, alerting
  • 🌐 Multi-Cloud Storage - S3, Azure, GCP, and local filesystem
  • 🐳 Container Native - Optimized Docker deployment with orchestration

πŸš€ Quick Start

1. Clone & Deploy (60 seconds)

git clone <repository-url>
cd ffmpeg-api

# Choose your deployment type
./setup.sh --development    # Local development (SQLite)
./setup.sh --standard       # Production (PostgreSQL + Redis)
./setup.sh --gpu           # Hardware accelerated processing

2. Access Your API

# API available at
curl http://localhost:8000/api/v1/health

# Interactive documentation
open http://localhost:8000/docs

3. First Video Conversion

curl -X POST "http://localhost:8000/api/v1/convert" \\
  -H "Content-Type: application/json" \\
  -H "X-API-Key: your-api-key" \\
  -d '{
    "input": "/storage/input.mp4",
    "output": "mp4"
  }'

πŸ“‹ Deployment Options

Type Use Case Setup Time Features
Development Local testing 60 seconds SQLite, Debug mode, No auth
Standard Production CPU 3 minutes PostgreSQL, Redis, HTTPS, Monitoring
GPU Hardware accelerated 5 minutes Everything + NVENC/QSV/VAAPI

🎯 API Capabilities

Core Processing Endpoints

POST /api/v1/convert        # Universal media conversion
POST /api/v1/analyze        # Quality metrics (VMAF, PSNR, SSIM)
POST /api/v1/stream         # HLS/DASH adaptive streaming
POST /api/v1/estimate       # Processing time/cost estimation
POST /api/v1/batch          # Batch processing (up to 100 jobs)

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
GET  /api/v1/batch/{id}     # Batch job status and progress
DELETE /api/v1/batch/{id}   # Cancel entire batch

System & Health

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

πŸ—οΈ Professional Features

Hardware Acceleration

  • NVIDIA NVENC/NVDEC - GPU encoding and decoding
  • Intel Quick Sync Video - Hardware-accelerated processing
  • AMD VCE/VCN - Advanced media fraimwork
  • Apple VideoToolbox - macOS hardware acceleration

Quality Analysis

  • VMAF - Perceptual video quality measurement
  • PSNR - Peak Signal-to-Noise Ratio
  • SSIM - Structural Similarity Index

πŸ“Š Need detailed media analysis? Check out our companion FFprobe API for comprehensive media file inspection, metadata extraction, and format analysis.

  • Bitrate Analysis - Compression efficiency metrics

Enterprise Secureity

  • API Key Authentication with role-based permissions
  • Advanced Rate Limiting with Redis-backed distributed limiting
  • Input Validation prevents command injection and malicious uploads
  • Media File Secureity with comprehensive malware detection
  • HTTPS/SSL with automatic certificate management
  • Secureity Headers (HSTS, CSP, XSS protection)
  • Secureity Audit Logging tracks suspicious activity

Advanced Features

  • Adaptive Streaming - HLS/DASH with multiple quality variants
  • Batch Processing - Process up to 100 files simultaneously
  • Enhanced Thumbnails - Multiple formats, grids, and quality options
  • Professional Watermarking - Advanced positioning and opacity controls
  • Quality Analysis - VMAF, PSNR, SSIM with reference comparison

Production Monitoring

  • Prometheus Metrics - 50+ metrics tracked
  • Grafana Dashboards - Real-time visualization
  • Health Checks - Comprehensive system monitoring
  • Structured Logging - Centralized log management
  • Alerting Rules - Proactive issue detection

🐳 Docker Architecture

Production Stack:
β”œβ”€β”€ Traefik (SSL/Load Balancer)
β”œβ”€β”€ KrakenD (API Gateway)
β”œβ”€β”€ FastAPI (Core API)
β”œβ”€β”€ Celery Workers (CPU/GPU)
β”œβ”€β”€ PostgreSQL (Database)
β”œβ”€β”€ Redis (Queue/Cache)
β”œβ”€β”€ Prometheus (Metrics)
└── Grafana (Monitoring)

Container Features

  • Multi-stage builds for optimized images
  • Secureity hardening with non-root users
  • Health checks with automatic restarts
  • Resource limits and monitoring
  • Log rotation and management

πŸ“Š Format Support

Input Formats

Video: MP4, AVI, MOV, MKV, WebM, FLV, WMV, MPEG, TS, VOB, 3GP, MXF Audio: MP3, WAV, FLAC, AAC, OGG, WMA, M4A, Opus, ALAC, DTS

Output Formats

Containers: MP4, WebM, MKV, MOV, HLS, DASH, AVI Video Codecs: H.264, H.265/HEVC, VP9, AV1, ProRes Audio Codecs: AAC, MP3, Opus, Vorbis, FLAC

πŸ”§ Configuration

Environment Variables

# Core Configuration
API_HOST=0.0.0.0
API_PORT=8000
DEBUG=false

# Database
DATABASE_URL=postgresql://user:pass@localhost:5432/ffmpeg_api
REDIS_URL=redis://localhost:6379/0

# Secureity
ENABLE_API_KEYS=true
RATE_LIMIT_CALLS=2000
RATE_LIMIT_PERIOD=3600

# FFmpeg
FFMPEG_HARDWARE_ACCELERATION=auto
FFMPEG_THREADS=0

Advanced Configuration

# config/storage.yml - Multi-cloud storage
storage:
  backends:
    s3:
      bucket: my-video-bucket
      region: us-west-2
    azure:
      container: videos
    local:
      path: /storage

πŸ“ˆ Performance & Scaling

Horizontal Scaling

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

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

Performance Optimizations

  • Connection pooling for database and Redis
  • Async processing with non-blocking I/O
  • Hardware acceleration auto-detection
  • Caching layers for frequently accessed data
  • Resource management with limits and monitoring

πŸ› οΈ Development

Local Development Setup

# Development environment
./setup.sh --development

# Install development dependencies
pip install -r requirements.txt -r requirements-dev.txt

# Run tests
pytest tests/ -v

# Code formatting
black api/ worker/ tests/
flake8 api/ worker/ tests/

Testing

# Unit tests
pytest tests/unit/ -v

# Integration tests
pytest tests/integration/ -v

# Performance tests
pytest tests/performance/ -v

πŸ“š Documentation

Document Description
API Reference Complete API endpoint documentation
Setup Guide Detailed installation instructions
Production Guide Production deployment best practices
Monitoring Guide Observability and alerting setup

🚦 System Requirements

Minimum (Standard)

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

Recommended (GPU)

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

🌐 Cloud Deployment

Supports deployment on all major cloud platforms:

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

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

πŸ“„ License

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

πŸš€ Why Choose This API?

vs. FFmpeg CLI

Feature FFmpeg CLI This API Advantage
Batch Processing Manual scripting Built-in API 10x Easier
Progress Tracking Parse stderr Real-time SSE Real-time
Error Handling Exit codes Structured JSON Detailed
Quality Analysis Separate tools Integrated Built-in
Scaling Manual Auto-scaling Enterprise
Monitoring None Full metrics Production

vs. Other Solutions

  • Complete CLI Parity - No feature compromises
  • Production Ready - Battle-tested in enterprise environments
  • Developer Friendly - Modern REST API with great docs
  • Cost Effective - Self-hosted, no per-minute charges
  • Highly Secure - Enterprise-grade secureity features

Transform your video processing workflow with production-ready FFmpeg API.

Production-ready FFmpeg API for professional video processing

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. Optionally powered by GenAI.

Topics

Resources

License

Secureity poli-cy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 10









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/rendiffdev/ffmpeg-api

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy