Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Rendiff FFmpeg API - Production Environment Configuration
# FFmpeg API - Production Environment Configuration
# Copy this file to .env and configure for your environment

# =============================================================================
Expand All @@ -24,8 +24,8 @@ API_LOG_LEVEL=info
# Production PostgreSQL (Recommended)
DATABASE_URL=postgresql://ffmpeg_user:your_secure_password@postgres:5432/ffmpeg_api

# Alternative: SQLite (Development Only)
# DATABASE_URL=sqlite+aiosqlite:///data/rendiff.db
# Alternative: SQLite (Development Only)
# DATABASE_URL=sqlite+aiosqlite:///data/ffmpeg_api.db

# Database Pool Settings
DATABASE_POOL_SIZE=20
Expand All @@ -52,7 +52,7 @@ WORKER_TASK_TIME_LIMIT=21600
# Storage Paths
STORAGE_CONFIG=/app/config/storage.yml
STORAGE_PATH=./storage
TEMP_PATH=/tmp/rendiff
TEMP_PATH=/tmp/ffmpeg_api

# Data Persistence Paths (for Docker volumes)
POSTGRES_DATA_PATH=./data/postgres
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,15 @@ jobs:
- component: api
dockerfile: docker/api/Dockerfile
context: .
build_args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
build_args: "PYTHON_VERSION=${{ env.PYTHON_VERSION }}"
- component: worker-cpu
dockerfile: docker/worker/Dockerfile
context: .
build_args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
WORKER_TYPE=cpu
build_args: "PYTHON_VERSION=${{ env.PYTHON_VERSION }}\nWORKER_TYPE=cpu"
- component: worker-gpu
dockerfile: docker/worker/Dockerfile
context: .
build_args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
WORKER_TYPE=gpu
build_args: "PYTHON_VERSION=${{ env.PYTHON_VERSION }}\nWORKER_TYPE=gpu"

steps:
- name: Checkout code
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/stable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,13 @@ jobs:
include:
- component: api
dockerfile: docker/api/Dockerfile.new
build_args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
build_args: "PYTHON_VERSION=${{ env.PYTHON_VERSION }}"
- component: worker-cpu
dockerfile: docker/worker/Dockerfile
build_args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
WORKER_TYPE=cpu
build_args: "PYTHON_VERSION=${{ env.PYTHON_VERSION }}\nWORKER_TYPE=cpu"
- component: worker-gpu
dockerfile: docker/worker/Dockerfile
build_args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
WORKER_TYPE=gpu
build_args: "PYTHON_VERSION=${{ env.PYTHON_VERSION }}\nWORKER_TYPE=gpu"

steps:
- name: Checkout code
Expand Down Expand Up @@ -155,8 +150,7 @@ jobs:
with:
context: .
file: docker/api/Dockerfile.new
build-args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
build-args: "PYTHON_VERSION=${{ env.PYTHON_VERSION }}"
tags: ffmpeg-api:ffmpeg-test
load: true

Expand Down Expand Up @@ -226,8 +220,7 @@ jobs:
with:
context: .
file: docker/api/Dockerfile.new
build-args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
build-args: "PYTHON_VERSION=${{ env.PYTHON_VERSION }}"
tags: ffmpeg-api:security-scan
load: true

Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A high-performance, production-ready FFmpeg API designed to replace complex CLI
### 1. Clone & Deploy (60 seconds)

```bash
git clone https://github.com/rendiffdev/ffmpeg-api.git
git clone <repository-url>
cd ffmpeg-api

# Choose your deployment type
Expand All @@ -50,12 +50,10 @@ open http://localhost:8000/docs
```bash
curl -X POST "http://localhost:8000/api/v1/convert" \\
-H "Content-Type: application/json" \\
-H "X-API-Key: your-api-key" \\
-d '{
"input": "/path/to/input.mp4",
"output": "/path/to/output.webm",
"operations": [
{"type": "transcode", "params": {"video_codec": "vp9", "crf": 30}}
]
"input": "/storage/input.mp4",
"output": "mp4"
}'
```

Expand Down Expand Up @@ -322,4 +320,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file

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

*Built with ❤️ by the Rendiff team*
*Production-ready FFmpeg API for professional video processing*
10 changes: 5 additions & 5 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
# Traefik Reverse Proxy
traefik:
image: traefik:v3.1
container_name: rendiff_traefik
container_name: ffmpeg_traefik
command:
- --configFile=/etc/traefik/traefik.yml
ports:
Expand All @@ -34,7 +34,7 @@ services:
# API Gateway (now behind Traefik)
krakend:
image: devopsfaith/krakend:2.7
container_name: rendiff_gateway
container_name: ffmpeg_gateway
volumes:
- ./config/krakend.json:/etc/krakend/krakend.json:ro
# No port exposure - accessed through Traefik
Expand All @@ -53,7 +53,7 @@ services:
# Database Service
postgres:
image: postgres:16-alpine
container_name: rendiff_postgres
container_name: ffmpeg_postgres
environment:
POSTGRES_DB: ffmpeg_api
POSTGRES_USER: ffmpeg_user
Expand Down Expand Up @@ -93,7 +93,7 @@ services:
# Queue Service (Redis)
redis:
image: redis:7.2-alpine
container_name: rendiff_redis
container_name: ffmpeg_redis
command: >
redis-server
--appendonly yes
Expand Down Expand Up @@ -148,7 +148,7 @@ services:
platforms:
- linux/amd64
- linux/arm64
container_name: rendiff_api
container_name: ffmpeg_api
environment:
DATABASE_URL: ${DATABASE_URL:-postgresql://ffmpeg_user:defaultpassword@postgres:5432/ffmpeg_api}
REDIS_URL: redis://redis:6379/0
Expand Down
149 changes: 85 additions & 64 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rendiff API Documentation
# FFmpeg API Documentation

Complete API reference for the Rendiff FFmpeg API service.
Complete API reference for the production-ready FFmpeg API service.

## Table of Contents

Expand All @@ -15,20 +15,20 @@ Complete API reference for the Rendiff FFmpeg API service.

## Overview

The Rendiff API provides a RESTful interface to FFmpeg's media processing capabilities with hardware acceleration support.
The FFmpeg API provides a RESTful interface to FFmpeg's media processing capabilities with hardware acceleration support.

> **💡 New to setup?** See the [Setup Guide](SETUP.md) for deployment instructions.

All API requests should be made to:

```
http://your-server:8000/api/v1
http://localhost:8000/api/v1
```

### Base URL Structure

- Development: `http://localhost:8000/api/v1`
- Production: `https://your-domain.com/api/v1` (HTTPS recommended)
- Production: `https://your-domain.com/api/v1` (Configure with your domain)

### HTTPS Configuration

Expand All @@ -38,31 +38,31 @@ For production deployments, HTTPS is strongly recommended. The API supports both

1. **Interactive Setup**: Run the setup wizard and choose HTTPS options
```bash
./scripts/interactive-setup.sh
# Choose option 2 (self-signed) or 3 (Let's Encrypt) for SSL configuration
./setup.sh --standard
# Production setup includes HTTPS with self-signed certificates
```

2. **Manual Certificate Generation**:
2. **Certificate Management**:
```bash
# Self-signed certificate
./scripts/manage-ssl.sh generate-self-signed your-domain.com
# Standard setup includes HTTPS with self-signed certificates
./setup.sh --standard

# Let's Encrypt certificate
./scripts/manage-ssl.sh generate-letsencrypt your-domain.com admin@example.com
# For custom certificates, edit traefik configuration
# and place certificates in ./traefik/certs/
```

3. **Deploy with HTTPS**:
```bash
# Production deployment with Traefik (includes HTTPS)
docker compose -f docker compose.prod.yml --profile traefik up -d
# Production deployment with HTTPS enabled by default
./setup.sh --standard
```

#### SSL Certificate Management

- **List certificates**: `./scripts/manage-ssl.sh list`
- **Test SSL setup**: `./scripts/manage-ssl.sh test your-domain.com`
- **Validate configuration**: `./scripts/manage-ssl.sh validate your-domain.com`
- **Renew certificates**: `./scripts/manage-ssl.sh renew`
- **Check deployment status**: `./setup.sh --status`
- **View Traefik logs**: `docker compose logs traefik`
- **Restart SSL services**: `docker compose restart traefik`
- **Certificate location**: `./traefik/certs/`

See the [SSL Management Guide](SETUP.md#httpssl-configuration) for detailed information.

Expand Down Expand Up @@ -519,59 +519,80 @@ curl -X POST http://localhost:8000/api/v1/stream \
}'
```

## SDKs
## API Client Examples

### Python SDK
### Python Client

```python
from rendiff import RendiffClient

client = RendiffClient(api_key="your-api-key", base_url="http://localhost:8000")

# Simple conversion
job = client.convert(
input="/storage/input/video.avi",
output="mp4"
)

# Monitor progress
for progress in job.watch():
print(f"Progress: {progress.percentage}%")

# Get result
result = job.wait()
print(f"Output: {result.output_path}")
```

### JavaScript SDK
import requests
import time

class FFmpegAPIClient:
def __init__(self, api_key, base_url="http://localhost:8000"):
self.api_key = api_key
self.base_url = base_url
self.headers = {"X-API-Key": api_key, "Content-Type": "application/json"}

def convert(self, input_path, output_format):
response = requests.post(
f"{self.base_url}/api/v1/convert",
json={"input": input_path, "output": output_format},
headers=self.headers
)
return response.json()

def get_job_status(self, job_id):
response = requests.get(
f"{self.base_url}/api/v1/jobs/{job_id}",
headers=self.headers
)
return response.json()

# Usage
client = FFmpegAPIClient(api_key="your-api-key")
job = client.convert("/storage/input/video.avi", "mp4")
print(f"Job ID: {job['job']['id']}")
```

### JavaScript Client

```javascript
import { RendiffClient } from '@rendiff/sdk';

const client = new RendiffClient({
apiKey: 'your-api-key',
baseUrl: 'http://localhost:8000'
});

// Convert with async/await
const job = await client.convert({
input: '/storage/input/video.avi',
output: 'mp4'
});

// Watch progress
job.onProgress((progress) => {
console.log(`Progress: ${progress.percentage}%`);
});
class FFmpegAPIClient {
constructor(apiKey, baseUrl = 'http://localhost:8000') {
this.apiKey = apiKey;
this.baseUrl = baseUrl;
this.headers = {
'X-API-Key': apiKey,
'Content-Type': 'application/json'
};
}

async convert(input, output) {
const response = await fetch(`${this.baseUrl}/api/v1/convert`, {
method: 'POST',
headers: this.headers,
body: JSON.stringify({ input, output })
});
return response.json();
}

async getJobStatus(jobId) {
const response = await fetch(`${this.baseUrl}/api/v1/jobs/${jobId}`, {
headers: this.headers
});
return response.json();
}
}

// Wait for completion
const result = await job.wait();
console.log(`Output: ${result.outputPath}`);
// Usage
const client = new FFmpegAPIClient('your-api-key');
const job = await client.convert('/storage/input/video.avi', 'mp4');
console.log(`Job ID: ${job.job.id}`);
```

### cURL Examples

See the [examples directory](../examples/) for more cURL examples and use cases.
Basic API usage with cURL commands.

## Rate Limiting

Expand All @@ -580,7 +601,7 @@ Default rate limits per API key:
- 1000 requests/hour
- 10 concurrent jobs

These can be configured in the KrakenD gateway configuration.
Rate limits are configurable through environment variables and can be adjusted based on your API key tier.

## Webhooks

Expand Down Expand Up @@ -790,5 +811,5 @@ The API automatically redirects HTTP traffic to HTTPS when SSL is enabled.

- API Documentation: http://localhost:8000/docs
- OpenAPI Schema: http://localhost:8000/openapi.json
- GitHub: https://github.com/rendiffdev/ffmpeg-api
- Discord: https://discord.gg/rendiff
- Health Check: http://localhost:8000/api/v1/health
- Metrics: http://localhost:9090 (if monitoring enabled)
Loading
Loading