>FFmpegLab
DevOps & Automation

Environment Variables & Scalable Runners – FFmpegLab Server Architecture

Configure PostgreSQL, pgmq, S3 storage, and distribute rendering across multiple runners. The complete guide to scaling FFmpegLab Server.

FFmpeg is famously powerful, but its default mode of operation — a single command, on a single machine, with hard‑coded paths — doesn't scale. When you move from a one‑off conversion to a production pipeline, you quickly hit walls: inconsistent behaviour across environments, hours‑long rendering times, and manual intervention for every change.

FFmpegLab Server solves this with a complete, production‑grade architecture built on PostgreSQL, pgmq queues, S3‑compatible storage, and scalable runners. This guide walks you through the entire stack — from configuring environment variables to deploying a self‑hosted rendering cluster.

Key takeaways

The Gap: One‑off Commands Don't Scale

Most FFmpeg tutorials teach you how to write a single command for a single file. That's fine for a quick conversion, but in production you face:

FFmpegLab Server's architecture solves these problems systematically.

The FFmpegLab Server Architecture

FFmpegLab Server is built on a modern, scalable architecture:

🗄️

PostgreSQL

Primary database with Row Level Security (RLS). Stores projects, renders, users, and API keys.
📨

pgmq

PostgreSQL‑powered job queue for asynchronous rendering tasks. Provides durability and transactional guarantees.
📦

S3 Storage

S3‑compatible storage (via Supabase Storage) for media assets and rendered output.
⚙️

API Server

REST API server that receives rendering requests, manages projects, and enqueues jobs.
🏃

Render Runner

Worker that executes FFmpeg rendering jobs from the queue.
📁

File Runner

Worker that handles file operations with S3 storage.
📊

Logs Runner

Worker that processes and stores render logs (stdout).
Client API Server pgmq Runners S3 Storage
(Jobs are queued, processed asynchronously, and results stored in S3)
PostgreSQL (Projects, Renders, Users, Logs)

Powered by Supabase – Full‑Cycle Provider

FFmpegLab Server is built on Supabase — the open‑source Firebase alternative — as a full‑cycle provider for all backend services:

ServiceProviderDescription
PostgreSQLSupabasePrimary database with Row Level Security (RLS)
pgmqSupabaseJob queue for asynchronous render processing
S3‑compatible StorageSupabaseFile storage for media assets and rendered output
REST APISupabaseAuto‑generated REST API with JWT authentication
API KeysSupabaseUser‑managed API keys with role‑based access
LogsSupabaseCentralized storage of ffmpeg logs per render

As one guide explains: "Supabase provides a full PostgreSQL database with authentication, storage, and real‑time subscriptions. It's the perfect backend for scalable applications".

FFmpegLab Server Environment Variables

FFmpegLab Server uses environment variables for complete configuration. Here's the full reference:

Database (PostgreSQL)

VariableDescriptionRequired
DB_HOSTPostgreSQL host✅ Yes
DB_USERPostgreSQL user✅ Yes
DB_PORTPostgreSQL port✅ Yes
DB_PASSWORDPostgreSQL password✅ Yes
DB_NAMEPostgreSQL database name✅ Yes
DB_MIGRATION_ENABLEDAuto‑run database migrations⚠️ Optional (default: false)

Queue Database (pgmq)

The queue database can be the same as the main database or a separate instance.

VariableDescriptionRequired
QUEUE_DB_HOSTQueue PostgreSQL host✅ Yes
QUEUE_DB_USERQueue PostgreSQL user✅ Yes
QUEUE_DB_PORTQueue PostgreSQL port✅ Yes
QUEUE_DB_PASSWORDQueue PostgreSQL password✅ Yes
QUEUE_DB_NAMEQueue PostgreSQL database name✅ Yes

S3 Storage

Required for the file-runner service.

VariableDescriptionRequired
S3_ACCESS_KEYS3 access key⚠️ For file-runner
S3_SECRET_KEYS3 secret key⚠️ For file-runner
S3_REGIONS3 region (e.g., us-east-1)⚠️ For file-runner
S3_ENDPOINTS3 endpoint URL⚠️ For file-runner

Runner Mode Flags

These flags determine which runner mode the service runs in.

VariableDescriptionRequired
IS_RENDER_RUNNEREnable render runner mode⚠️ For render-runner
IS_FILE_RUNNEREnable file runner mode⚠️ For file-runner
IS_LOGS_RUNNEREnable logs runner mode⚠️ For logs-runner

Data Models

The server uses TypeORM with models defined in src/models/:

Docker Compose Configuration

The repository includes a docker-compose.yml that defines all services:

# docker-compose.yml
services:
  api:
    image: ffmpeglab/server:latest
    ports: - "3000:3000"
    environment:
      - DB_HOST=${DB_HOST}
      - DB_USER=${DB_USER}
      - DB_PORT=${DB_PORT}
      - DB_PASSWORD=${DB_PASSWORD}
      - DB_NAME=${DB_NAME}
      - QUEUE_DB_HOST=${QUEUE_DB_HOST}
      - QUEUE_DB_NAME=${QUEUE_DB_NAME}
      - DB_MIGRATION_ENABLED=${DB_MIGRATION_ENABLED}
  render-runner:
    image: ffmpeglab/server:latest
    environment:
      - DB_HOST=${DB_HOST}
      - DB_USER=${DB_USER}
      - DB_PASSWORD=${DB_PASSWORD}
      - DB_NAME=${DB_NAME}
      - QUEUE_DB_HOST=${QUEUE_DB_HOST}
      - QUEUE_DB_NAME=${QUEUE_DB_NAME}
      - IS_RENDER_RUNNER=true
  file-runner:
    image: ffmpeglab/server:latest
    environment:
      - DB_HOST=${DB_HOST}
      - S3_ACCESS_KEY=${S3_ACCESS_KEY}
      - S3_SECRET_KEY=${S3_SECRET_KEY}
      - S3_REGION=${S3_REGION}
      - S3_ENDPOINT=${S3_ENDPOINT}
      - IS_FILE_RUNNER=true
  logs-runner:
    image: ffmpeglab/server:latest
    environment:
      - DB_HOST=${DB_HOST}
      - DB_USER=${DB_USER}
      - DB_PASSWORD=${DB_PASSWORD}
      - DB_NAME=${DB_NAME}
      - IS_LOGS_RUNNER=true

Start the complete stack:

docker compose up -d

View the logs:

docker compose logs -f

Scalable Runners – The Engine

Runners are workers that execute jobs from the pgmq queue. The magic happens when you have multiple runners working in parallel.

How Runners Work

  1. The API server receives a rendering request and pushes a job to the pgmq queue.
  2. One or more render-runners poll the queue for new jobs.
  3. Each runner picks up a job, executes FFmpeg with the provided parameters, and uploads the result to S3 storage.
  4. The runner updates the job status in the database, and the client polls for completion.

Runner Types

RunnerFlagResponsibility
Render RunnerIS_RENDER_RUNNERExecutes FFmpeg rendering jobs from the queue
File RunnerIS_FILE_RUNNERHandles file operations with S3 storage
Logs RunnerIS_LOGS_RUNNERProcesses and stores system and user activity logs

As noted in the broader FFmpeg ecosystem: "You can create multiple runners and distribute the workload, significantly reducing processing time for large workloads".

Scaling the Rendering Pipeline

The queue‑based architecture makes scaling straightforward:

Scaling command:

docker compose up -d --scale render-runner=8

This spins up 8 render-runner instances, all pulling from the same pgmq queue.

Security Considerations

Frequently Asked Questions (FAQ)

What is the difference between render-runner, file-runner, and logs-runner?

render-runner executes FFmpeg rendering jobs from the queue. file-runner handles S3 file operations (upload, download, delete). logs-runner processes and stores system and user activity logs. They can all run on the same machine or be distributed across multiple machines.

Can I use the same PostgreSQL instance for both the database and the queue?

Yes. You can set QUEUE_DB_HOST and QUEUE_DB_NAME to the same values as DB_HOST and DB_NAME. They can be the same database or separate databases on the same server.

What S3-compatible storage services work with FFmpegLab Server?

Any S3-compatible storage works: Supabase Storage, AWS S3, MinIO, Cloudflare R2, Backblaze B2, or any other S3‑compatible endpoint. The S3_ENDPOINT variable lets you specify your provider's endpoint.

How do I scale the rendering pipeline?

Scale by adding more render-runner instances. Each runner pulls from the same pgmq queue, enabling parallel processing. You can use docker compose up -d --scale render-runner=8 or orchestrate with Kubernetes.

What database models does FFmpegLab Server use?

The server uses TypeORM with models defined in src/models/: Project (editor projects), Render (render jobs), User (user profiles), ApiKey (API key management), and Log (render logs).

Final Word

Environment variables and scalable runners turn FFmpegLab Server into a production‑grade media processing platform. With PostgreSQL for storage, pgmq for job queuing, S3‑compatible storage for assets, and three types of scalable runners, you can handle workloads that would be impossible with one‑off commands.

The key components work together seamlessly:

Next time you're facing a mountain of media files, remember: you don't have to process them one by one. Scale up with FFmpegLab Server.

✦  Fresh from the render queue

Better FFmpeg workflows, delivered.

Get practical commands, new templates, and deep-dive guides for the edits that are usually hardest to get right.

✓  Copy-pasteable commands    ✓  Editor templates    ✓  No noise
One useful email at a time.