Production-Ready Media Analysis API π
A comprehensive, enterprise-grade REST API that provides complete FFmpeg ffprobe functionality with advanced video quality analysis, AI-powered insights, cloud storage integration, and multi-format reporting. Built with Go for maximum performance, scalability, and reliability.
- β Complete FFprobe Integration: 100% CLI compatibility with identical output
- π All Output Formats: JSON, XML, CSV, HTML, PDF, Excel, Markdown, Text
- π Deep Analysis: Streams, format, frames, packets, chapters, programs
- β‘ Large File Support: Optimized for files up to 50GB+ with streaming
- π Multi-Source: Local files, URLs, cloud storage (S3/GCS/Azure)
- π VMAF Integration: Industry-standard video quality assessment
- π PSNR/SSIM Analysis: Peak Signal-to-Noise Ratio & Structural Similarity
- β±οΈ Frame-Level Metrics: Temporal quality analysis with timestamps
- π Quality Comparison: Reference vs distorted video workflows
- ποΈ Custom Models: Support for custom-trained VMAF models
- π HLS Analysis: Complete HTTP Live Streaming manifest processing
- β Playlist Validation: m3u8 syntax and structure verification
- π§© Segment Analysis: Individual segment quality and metadata
- π Bitrate Ladders: Quality analysis across adaptive variants
- π₯ Live Streams: Real-time streaming analysis support
- π AWS S3: Complete S3 integration with IAM roles
- π Google Cloud: GCS with service account authentication
- π· Azure Blob: Full Azure storage integration
- π Signed URLs: Secure, time-limited access links
- π€ Direct Upload: Multi-part uploads with progress tracking
- π PDF Reports: Professional, formatted analysis documents
- π HTML Reports: Interactive web-based analysis views
- π Excel Reports: Spreadsheet format with charts and data
- π Markdown: GitHub-compatible documentation format
- π¨ Custom Templates: Branded, customizable report layouts
- π§ Local LLM: Privacy-focused on-premise AI analysis
- βοΈ Cloud Fallback: OpenRouter integration for advanced models
- π¬ Natural Language: Human-readable video quality insights
- β Interactive Q&A: Ask specific questions about your media
- π Smart Recommendations: AI-driven optimization suggestions
Metric | Target | Production Ready |
---|---|---|
Small Files (<100MB) | <3s response | β |
Large Files (50GB+) | <30s with progress | β |
VMAF Analysis | <2x processing time | β |
HLS Processing | <5s/segment + <10s manifest | β |
Concurrent Requests | 1000+ standard / 200+ quality | β |
Memory Footprint | <100MB regardless of file size | β |
Database Performance | <50ms query time | β |
API Response Time | <200ms average | β |
Component | Technology | Version | Purpose |
---|---|---|---|
Backend | Go + Gin | 1.21+ | High-performance REST API |
Database | PostgreSQL | 15+ | Primary data storage |
Cache | Redis | 7+ | Session & response caching |
Video Processing | FFmpeg + libvmaf | 6.1+ | Media analysis engine |
Quality Metrics | VMAF/PSNR/SSIM | Latest | Industry-standard metrics |
Cloud Storage | AWS/GCP/Azure SDKs | Latest | Multi-cloud support |
Containers | Docker + Compose | Latest | Production deployment |
Monitoring | Prometheus + Grafana | Latest | Observability stack |
Documentation | OpenAPI 3.0 | - | Complete API specs |
graph TB
subgraph "Load Balancer"
LB[Nginx/HAProxy]
end
subgraph "Application Tier"
API1[FFprobe API Instance 1]
API2[FFprobe API Instance 2]
API3[FFprobe API Instance N]
end
subgraph "Data Tier"
PG[(PostgreSQL 15+<br/>Primary Database)]
REDIS[(Redis 7+<br/>Cache & Sessions)]
end
subgraph "Processing Tier"
FFmpeg[FFmpeg + libvmaf<br/>Quality Analysis]
LLM[Local LLM<br/>AI Insights]
end
subgraph "Storage Tier"
S3[AWS S3]
GCS[Google Cloud Storage]
AZURE[Azure Blob Storage]
LOCAL[Local Storage]
end
subgraph "Monitoring"
PROM[Prometheus]
GRAF[Grafana]
ALERT[AlertManager]
end
LB --> API1
LB --> API2
LB --> API3
API1 --> PG
API2 --> PG
API3 --> PG
API1 --> REDIS
API2 --> REDIS
API3 --> REDIS
API1 --> FFmpeg
API1 --> LLM
API1 --> S3
API1 --> GCS
API1 --> AZURE
API1 --> LOCAL
API1 --> PROM
PROM --> GRAF
PROM --> ALERT
Endpoint | Method | Description | Status |
---|---|---|---|
Core Analysis | |||
/api/v1/probe/file |
POST | Upload & analyze media files | β |
/api/v1/probe/url |
POST | Analyze remote URLs & cloud storage | β |
/api/v1/probe/status/{id} |
GET | Get analysis status & progress | β |
/api/v1/probe/analyses |
GET | List all analyses with pagination | β |
Quality Metrics | |||
/api/v1/probe/compare |
POST | Video quality comparison (VMAF/PSNR/SSIM) | β |
/api/v1/quality/analysis/{id} |
GET | Detailed quality metrics | β |
/api/v1/quality/statistics |
GET | Quality analysis statistics | β |
HLS & Streaming | |||
/api/v1/probe/hls |
POST | HLS playlist analysis | β |
/api/v1/probe/hls/validate |
POST | HLS playlist validation | β |
/api/v1/probe/hls/{id} |
GET | HLS analysis results | β |
Reports & Downloads | |||
/api/v1/probe/report |
POST | Generate reports (PDF/HTML/Excel/etc) | β |
/api/v1/probe/download/{id} |
GET | Download generated reports | β |
/api/v1/probe/raw/{id} |
GET | Raw FFprobe JSON output | β |
Cloud Storage | |||
/api/v1/storage/upload |
POST | Upload files to cloud storage | β |
/api/v1/storage/download/{key} |
GET | Download from cloud storage | β |
/api/v1/storage/signed-url |
POST | Generate signed URLs | β |
AI Features | |||
/api/v1/ask |
POST | Ask AI about analysis results | β |
/api/v1/genai/analysis |
POST | Generate AI insights | β |
System | |||
/health |
GET | Health check endpoint | β |
/metrics |
GET | Prometheus metrics | β |
# Clone the repository
git clone https://github.com/rendiffdev/ffprobe-api.git
cd ffprobe-api
# Production deployment
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# Development environment
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
# View logs
docker-compose logs -f ffprobe-api
# Prerequisites
# - Go 1.21+, PostgreSQL 15+, Redis 7+, FFmpeg 6.1+
# Clone and build
git clone https://github.com/rendiffdev/ffprobe-api.git
cd ffprobe-api
go mod download
make build
# Database setup
make migrate-up
# Run the application
./bin/ffprobe-api
# Apply Kubernetes manifests
kubectl apply -f k8s/
# Check deployment status
kubectl get pods -l app=ffprobe-api
# View service
kubectl get svc ffprobe-api
# Copy example configuration
cp .env.example .env
# Edit configuration
nano .env
Essential Configuration:
# π Security
API_KEY=your-super-secret-api-key-change-in-production
JWT_SECRET=your-super-secret-jwt-key-change-in-production
# ποΈ Database
POSTGRES_HOST=postgres
POSTGRES_DB=ffprobe_api
POSTGRES_USER=ffprobe
POSTGRES_PASSWORD=secure_password_here
# π¦ Redis
REDIS_HOST=redis
REDIS_PASSWORD=redis_password_here
# βοΈ Cloud Storage (Choose one)
STORAGE_PROVIDER=s3 # s3, gcs, azure, or local
STORAGE_BUCKET=your-bucket-name
STORAGE_ACCESS_KEY=your-access-key
STORAGE_SECRET_KEY=your-secret-key
# π€ AI Features (Optional)
OPENROUTER_API_KEY=your-openrouter-key
LLM_MODEL_PATH=/models/phi-3-mini.gguf
# π Monitoring
LOG_LEVEL=info
ENABLE_METRICS=true
π Security Checklist:
- Change default API keys and secrets
- Use strong database passwords
- Configure CORS origins for production
- Enable HTTPS/TLS termination
- Set up proper firewall rules
- Configure rate limiting
# Upload and analyze a video file
curl -X POST "http://localhost:8080/api/v1/probe/file" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"file_path": "/path/to/video.mp4",
"options": {
"include_streams": true,
"include_format": true,
"include_chapters": true
}
}'
# Response: {"analysis_id": "uuid", "status": "processing"}
# Compare original vs compressed video quality
curl -X POST "http://localhost:8080/api/v1/probe/compare" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"reference_file": "s3://my-bucket/original.mp4",
"distorted_file": "s3://my-bucket/compressed.mp4",
"metrics": ["vmaf", "psnr", "ssim"]
}'
# Get detailed quality metrics
curl "http://localhost:8080/api/v1/quality/analysis/comparison-id" \
-H "X-API-Key: your-api-key"
# Analyze HLS streaming playlist
curl -X POST "http://localhost:8080/api/v1/probe/hls" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"manifest_url": "https://cdn.example.com/playlist.m3u8",
"analyze_segments": true,
"segment_limit": 10
}'
# Validate HLS playlist structure
curl -X POST "http://localhost:8080/api/v1/probe/hls/validate" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{"manifest_url": "https://cdn.example.com/playlist.m3u8"}'
# Generate a comprehensive PDF report
curl -X POST "http://localhost:8080/api/v1/probe/report" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"analysis_id": "your-analysis-id",
"format": "pdf",
"template": "professional"
}'
# Download the generated report
curl "http://localhost:8080/api/v1/probe/download/report-id" \
-H "X-API-Key: your-api-key" \
-o "media_analysis_report.pdf"
# Upload file to cloud storage
curl -X POST "http://localhost:8080/api/v1/storage/upload" \
-H "X-API-Key: your-api-key" \
-F "file=@large_video.mp4"
# Get signed URL for secure download
curl -X POST "http://localhost:8080/api/v1/storage/signed-url" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{"key": "uploads/video.mp4", "expiration": 3600}'
# Ask AI about your video analysis
curl -X POST "http://localhost:8080/api/v1/ask" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"analysis_id": "your-analysis-id",
"question": "What are the main quality issues in this video?"
}'
# Generate AI insights
curl -X POST "http://localhost:8080/api/v1/genai/analysis" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{"analysis_id": "your-analysis-id"}'
ffprobe-api/
βββ π cmd/ # Application entrypoints
β βββ ffprobe-api/ # Main application
βββ π internal/ # Private application code
β βββ api/ # HTTP routes & handlers
β βββ services/ # Business logic layer
β βββ handlers/ # HTTP request handlers
β βββ models/ # Data models & schemas
β βββ database/ # Database operations
β βββ storage/ # Cloud storage providers
β βββ middleware/ # HTTP middleware
β βββ config/ # Configuration management
β βββ reports/ # Report generation
βββ π tests/ # Test suites
β βββ storage_test.go # Storage provider tests
β βββ handlers_test.go # API handler tests
β βββ services_test.go # Service layer tests
β βββ integration_test.go # End-to-end tests
βββ π docs/ # Documentation
β βββ openapi.yaml # OpenAPI 3.0 specification
β βββ README.md # API documentation
βββ π docker/ # Docker configurations
βββ π migrations/ # Database migrations
βββ π³ docker-compose.yml # Production setup
βββ π³ docker-compose.dev.yml # Development setup
βββ π³ docker-compose.prod.yml# Production overrides
βββ π§ Makefile # Build automation
βββ π .env.example # Configuration template
# ποΈ Build & Development
make build # Build the application
make dev # Run in development mode
make deps # Download dependencies
make fmt # Format code
# π§ͺ Testing & Quality
make test # Run unit tests
make test-integration # Run integration tests
make test-coverage # Generate coverage report
make benchmark # Run performance benchmarks
make lint # Code linting
make security # Security scanning
# π³ Docker & Deployment
make docker-build # Build Docker image
make docker-dev # Development environment
make docker-prod # Production environment
make docker-run # Standard environment
# ποΈ Database Management
make migrate-up # Apply migrations
make migrate-down # Rollback migrations
make migrate-create # Create new migration
# π Documentation
make docs # Generate API docs
make swagger # Update Swagger UI
Test Type | Coverage | Purpose |
---|---|---|
Unit Tests | 85%+ | Individual component testing |
Integration Tests | API workflows | End-to-end functionality |
Performance Tests | Benchmarks | Load & stress testing |
Security Tests | Vulnerability scans | Security validation |
# Run specific test suites
go test ./tests/storage_test.go -v # Storage tests
go test ./tests/handlers_test.go -v # Handler tests
go test ./tests/integration_test.go -v # Integration tests
# Coverage with HTML report
make test-coverage
open coverage.html
# Available at http://localhost:9090
- ffprobe_requests_total
- ffprobe_request_duration_seconds
- ffprobe_active_analyses
- ffprobe_database_queries_total
- ffprobe_storage_operations_total
- ffprobe_quality_analysis_duration_seconds
# Available at http://localhost:3000
- API Performance Dashboard
- Database Performance Dashboard
- Storage Operations Dashboard
- Quality Analysis Dashboard
- System Resources Dashboard
Endpoint | Purpose | Status |
---|---|---|
GET /health |
Basic service health | β |
GET /health/deep |
Database connectivity | β |
GET /metrics |
Prometheus metrics | β |
{
"timestamp": "2024-01-01T12:00:00Z",
"level": "info",
"service": "ffprobe-api",
"request_id": "req-123",
"method": "POST",
"path": "/api/v1/probe/file",
"duration_ms": 1500,
"status_code": 200,
"user_id": "user-456",
"analysis_id": "analysis-789"
}
- β API Key Authentication: Secure API access control
- β JWT Bearer Tokens: Stateless authentication
- β Role-Based Access: User permissions management
- β Rate Limiting: Per-key/IP request throttling (60/min, 1000/hour, 10000/day)
- β Input Validation: Comprehensive request sanitization
- β SQL Injection Prevention: Parameterized queries
- β XSS Protection: Content Security Policy headers
- β CSRF Protection: Cross-site request forgery prevention
- β File Upload Security: Type validation, size limits (50GB max)
- β CORS Configuration: Configurable cross-origin policies
- β Security Headers: HSTS, X-Frame-Options, X-Content-Type-Options
- β TLS/HTTPS: End-to-end encryption support
- β IP Whitelisting: Configurable access restrictions
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes with tests
- Test thoroughly:
make test-all
- Lint your code:
make lint
- Commit with conventional commits:
git commit -m 'feat: add amazing feature'
- Push to your branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Code follows project style guidelines
- Tests added for new functionality
- Documentation updated (if applicable)
- All tests pass locally
- Security considerations addressed
- Performance impact evaluated
This project is licensed under the MIT License - see the LICENSE file for details.
Resource | Link | Purpose |
---|---|---|
π Documentation | API Docs | Complete API reference |
π Bug Reports | GitHub Issues | Report bugs & request features |
π¬ Discussions | GitHub Discussions | Community discussions |
π§ Email Support | dev@rendiff.dev | Direct support |
π Website | https://rendiff.dev | Official website |
π¦ Twitter/X | @rendiffdev | Updates and news |
- GraphQL API - Alternative query interface
- WebSocket Streaming - Real-time analysis updates
- Kubernetes Operator - Native K8s deployment
- Advanced Caching - Redis Cluster support
- GPU Acceleration - NVIDIA CUDA support for VMAF
- WebAssembly Build - Browser-based analysis
- Custom Metrics - User-defined quality plugins
- ML Insights - Advanced AI-powered recommendations
- Real-time Streaming - Live stream analysis
- Advanced ML Models - Custom neural network integration
- Multi-tenant Architecture - Enterprise isolation
- Global CDN Integration - Edge processing capabilities