From 0f9382a765c1c2db6828d9ea0d62112a2ee7b041 Mon Sep 17 00:00:00 2001 From: aloke majumder Date: Sun, 27 Jul 2025 21:02:27 +0530 Subject: [PATCH 1/2] Fix Actions --- .github/workflows/ci-cd.yml | 11 +++-------- .github/workflows/stable-build.yml | 17 +++++------------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 132ecf7..99fba7f 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -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 diff --git a/.github/workflows/stable-build.yml b/.github/workflows/stable-build.yml index 441f91b..9c99073 100644 --- a/.github/workflows/stable-build.yml +++ b/.github/workflows/stable-build.yml @@ -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 @@ -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 @@ -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 From e83dae97e902569c31035797489189147c4afb67 Mon Sep 17 00:00:00 2001 From: aloke majumder Date: Mon, 4 Aug 2025 15:01:49 +0530 Subject: [PATCH 2/2] Fixed Issues --- .env.example | 8 +-- README.md | 12 ++-- compose.yml | 10 +-- docs/API.md | 149 ++++++++++++++++++++++++------------------- docs/INSTALLATION.md | 10 +-- docs/SETUP.md | 29 ++++----- setup.sh | 10 +-- 7 files changed, 120 insertions(+), 108 deletions(-) diff --git a/.env.example b/.env.example index fcef2d9..ec8780c 100644 --- a/.env.example +++ b/.env.example @@ -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 # ============================================================================= @@ -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 @@ -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 diff --git a/README.md b/README.md index ca9f198..b2e13b3 100644 --- a/README.md +++ b/README.md @@ -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 cd ffmpeg-api # Choose your deployment type @@ -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" }' ``` @@ -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* \ No newline at end of file +*Production-ready FFmpeg API for professional video processing* \ No newline at end of file diff --git a/compose.yml b/compose.yml index 8a8e1a0..80cf73d 100644 --- a/compose.yml +++ b/compose.yml @@ -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: @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/docs/API.md b/docs/API.md index 90d5767..f4593cb 100644 --- a/docs/API.md +++ b/docs/API.md @@ -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 @@ -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 @@ -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. @@ -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 @@ -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 @@ -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 \ No newline at end of file +- Health Check: http://localhost:8000/api/v1/health +- Metrics: http://localhost:9090 (if monitoring enabled) \ No newline at end of file diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 7568d68..258358b 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -1,6 +1,6 @@ -# Rendiff Installation Guide +# FFmpeg API Installation Guide -This guide covers various installation methods for the Rendiff FFmpeg API service. +This guide covers various installation methods for the FFmpeg API service. > **🚀 Quick Setup?** Use the [unified setup script](../setup.sh) for one-command deployment. > **📖 Detailed Setup?** See the [Setup Guide](SETUP.md) for comprehensive deployment documentation. @@ -32,16 +32,16 @@ This guide covers various installation methods for the Rendiff FFmpeg API servic - Git - Python 3.12+ (for manual installation) -> **Note**: PostgreSQL is no longer required! Rendiff now uses SQLite as the default database, which is automatically managed within the application. No external database setup is needed. +> **Note**: PostgreSQL is optional! The API supports both SQLite (for development) and PostgreSQL (for production), which can be configured during setup. ## Quick Start with Setup Wizard -The fastest and easiest way to get Rendiff running: +The fastest and easiest way to get the FFmpeg API running: ### Step 1: Clone Repository ```bash -git clone https://github.com/rendiffdev/ffmpeg-api.git +git clone cd ffmpeg-api ``` diff --git a/docs/SETUP.md b/docs/SETUP.md index 6ebb935..1e1eee5 100644 --- a/docs/SETUP.md +++ b/docs/SETUP.md @@ -25,10 +25,8 @@ cd ffmpeg-api # Choose your setup type ./setup.sh --help # Show all options ./setup.sh --development # Quick dev setup -./setup.sh --interactive # Interactive setup wizard ./setup.sh --standard # Standard production ./setup.sh --gpu # Hardware accelerated production -./setup.sh --interactive # Full configuration wizard ``` ## Setup Options @@ -85,12 +83,12 @@ cd ffmpeg-api **Best for: Internet-facing deployments with domain names** ```bash -# Set your domain first -export DOMAIN_NAME=api.yourdomain.com -export CERTBOT_EMAIL=admin@yourdomain.com +# Configure domain in .env file +DOMAIN_NAME=api.yourdomain.com +CERTBOT_EMAIL=admin@yourdomain.com -./setup.sh --interactive -# Choose HTTPS option during setup +# Then run standard setup +./setup.sh --standard ``` **What you get:** @@ -102,19 +100,14 @@ export CERTBOT_EMAIL=admin@yourdomain.com - SSL monitoring and alerts - Access at https://your-domain.com -### ⚙️ Interactive Setup -**Best for: Custom configurations, first-time setup** - -```bash -./setup.sh --interactive -``` +### ⚙️ Manual Configuration +**Best for: Custom configurations, advanced setups** -**What you get:** -- Step-by-step configuration wizard -- Custom storage backends (S3, Azure, GCP) -- Custom SSL certificates +Edit the `.env` file directly for custom configurations: +- Storage backends (S3, Azure, GCP) +- SSL certificates - Advanced networking options -- Database migration choices +- Database settings ## Development Setup diff --git a/setup.sh b/setup.sh index 93c5d93..c0daadf 100755 --- a/setup.sh +++ b/setup.sh @@ -6,14 +6,14 @@ set -e PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$PROJECT_DIR" -echo "🚀 Rendiff FFmpeg API Setup" -echo "==========================" +echo "🚀 FFmpeg API Setup" +echo "==================" # Function to show usage show_usage() { echo "Usage: $0 [OPTION]" echo "" - echo "🚀 Rendiff FFmpeg API - Production-Ready Setup Script" + echo "🚀 FFmpeg API - Production-Ready Setup Script" echo "" echo "Deployment Options:" echo " --development 🛠️ Fast local development (SQLite, debug mode, no auth)" @@ -76,14 +76,14 @@ API_LOG_LEVEL=debug API_WORKERS=1 # Database (SQLite for simplicity) -DATABASE_URL=sqlite+aiosqlite:///data/rendiff.db +DATABASE_URL=sqlite+aiosqlite:///data/ffmpeg_api.db # Queue (Redis) REDIS_URL=redis://redis:6379/0 # Storage STORAGE_PATH=./storage -TEMP_PATH=/tmp/rendiff +TEMP_PATH=/tmp/ffmpeg_api # Security (Disabled for development) ENABLE_API_KEYS=false