---
title: "Deploy FFmpeg"
description: "FFmpeg REST API and web UI: convert video, audio and images over HTTP"
category: "Other"
url: https://railway.com/deploy/ffmpeg
---

# Deploy FFmpeg

FFmpeg REST API and web UI: convert video, audio and images over HTTP

**[Deploy FFmpeg on Railway](https://railway.com/template/ffmpeg)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/ffmpeg/manifest.json

- **Creator:** Two Workspaces
- **Category:** Other

## Template content

### FFmpeg https://raw.githubusercontent.com/two-workspaces/ffmpeg/main/icon.svg

- **Image:** ghcr.io/two-workspaces/ffmpeg:5e455dd
- **Health check:** /
- **Public domain:** Yes

### FFmpeg Web https://raw.githubusercontent.com/two-workspaces/ffmpeg/main/icon.svg

- **Image:** ghcr.io/two-workspaces/ffmpeg-web:5e455dd
- **Health check:** /login
- **Public domain:** Yes

## Documentation

# Deploy and Host FFmpeg on Railway

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/new/template/ffmpeg?referralCode=sLjDXb&utm_medium=integration&utm_source=button&utm_campaign=ffmpeg)

FFmpeg is the open-source tool behind most video and audio conversion. This template runs it as a service: an HTTP API that converts video to MP4 or GIF, extracts audio and frames, converts audio to MP3 or WAV, converts and resizes images and reads media metadata, plus a small password-protected web page for doing the same by hand. It is built on the open-source FFmpeg REST API (ffmpeg-rest 1.2.0, FFmpeg 7.1), locked with a generated token, and tuned so video jobs also run on small plans.

This is a community template, not made or supported by the FFmpeg project or the ffmpeg-rest author.

## About Hosting FFmpeg

Two services are deployed: **FFmpeg** (the API, its worker and their job queue) and **FFmpeg Web** (the web page).

**Use the API:** send a file to the FFmpeg service's domain with the token from its `AUTH_TOKEN` variable:

```
curl -H "Authorization: Bearer YOUR_TOKEN" -F file=@input.mov https://your-api-domain/video/mp4 -o output.mp4
```

The reply is the converted file. Endpoints: `/video/mp4`, `/video/gif`, `/video/audio`, `/video/frames`, `/audio/mp3`, `/audio/wav`, `/image/jpg`, `/image/resize` and `/media/info`. Interactive documentation is at `/reference`, the OpenAPI document at `/doc` and a version for AI assistants at `/llms.txt`; those three pages and the front page are readable without the token, everything else needs it.

**Use the web page:** open the FFmpeg Web service's domain and sign in with the password in its `WEB_PASSWORD` variable. The page talks to the API for you, so you never paste the token into a browser.

**Memory and plan size:** FFmpeg sizes its thread pools to the host's processor count, and its memory use grows with them, which on Railway's large hosts gets a small service killed on its first video. The start script reads how much memory the service has and sets the thread count, the number of jobs at once and the largest upload to fit it:

| Memory | Threads per job | Jobs at once | Largest upload |
| --- | --- | --- | --- |
| 0.5 GB | 1 | 1 | 32 MB |
| 1 GB | 2 | 1 | 64 MB |
| 2 GB to 3 GB | 4 | 2 | 100 MB |
| 4 GB to 6 GB | 8 | 2 | 100 MB |
| more | 16 | 2 | 100 MB |

The values chosen are printed at the top of the deploy logs. Railway does not always tell a service its limit; when it doesn't, the script sizes for the smallest plan the machine could belong to. Set `FFMPEG_THREADS`, `WORKER_CONCURRENCY` or `MAX_FILE_SIZE` (bytes) on the FFmpeg service to choose your own values. An upload over the limit is refused with a 413 before it is read. Uploads are held in memory while their job runs, so raise the limit only on a service with memory to spare.

**Where files go:** by default nothing is stored: the converted file comes back in the response and the working copy is deleted. To get a link instead, set `STORAGE_MODE=s3` and the `S3_` variables to an S3-compatible bucket with a public address (Cloudflare R2, for example), and call the endpoints with `/url` on the end.

**Secrets:** the API token and the web password are generated at deploy. If you empty either variable the service makes up a new one at boot and prints it in its deploy logs, so neither is ever left open.

**Custom domain:** add it to either service; nothing else needs changing.

## Common Use Cases

- Converting uploads to MP4, MP3 or JPG from your own app, without installing FFmpeg next to it
- An FFmpeg step for n8n, Make, Zapier or an AI agent: one HTTP request per conversion
- Thumbnails, preview GIFs and audio tracks cut from videos
- Reading duration, codecs and resolution of a media file before deciding what to do with it
- Converting a few files by hand in the browser

## Dependencies for FFmpeg Hosting

- None for the default setup. The job queue (Redis) runs inside the FFmpeg service.
- Optional: an S3-compatible bucket with a public address, if you want links instead of files in the response.

### Deployment Dependencies

- [FFmpeg](https://ffmpeg.org/)
- [FFmpeg REST API on GitHub](https://github.com/crisog/ffmpeg-rest)
- [Template source](https://github.com/two-workspaces/ffmpeg)

### Implementation Details

- **Tested on Railway:** every endpoint with real files (video to MP4 and GIF, audio extraction, frames, MP3 and WAV, JPG, resize, metadata); the token (401 without it and with a wrong one); the web page's password (wrong one refused, session cookie Secure and HttpOnly, a conversion through the page, no access without a session); the same set with the FFmpeg service capped at 0.5 GB and at 1 GB, where a 20-second 720p clip converts in about 20 seconds; the upload limit (413 for an 86 MB file at both sizes, a 60 MB file accepted at 1 GB); 16 conversions in the minute after a redeploy, none lost; a wrong `STORAGE_MODE` (notice page, deploy stays up); an emptied token (a new one is generated and the old one stops working). Not tested: the web page in a real browser (its sign-in and its API proxy were exercised over HTTP), S3 mode against a real bucket, videos longer than two minutes, and many requests at once.
- **Memory:** the FFmpeg service idles around 200 MB and reached about 900 MB on an 86 MB upload with no cap; the web page uses about 30 MB.
- **Job queue:** upstream's API passes the worker a path on its own disk, so the queue has to belong to one container. With a separate Redis service, during a redeploy the old container's worker took jobs whose files only the new one had and they failed with "Input file does not exist". Redis therefore runs inside the FFmpeg service, bound to localhost, and keeps nothing on disk. Set `REDIS_URL` only if you want an outside Redis anyway.
- **Restarts:** the API, the worker and Redis are restarted separately if one dies, and FFmpeg is marked as the first process to give up memory, so a job that is too large fails with an error instead of taking the service down.
- **Safety guards:** a malformed number in a variable is replaced with a working value and logged. A `STORAGE_MODE` the app would reject, S3 mode without its settings, or a broken Redis or backend address shows a notice page that says what to fix, instead of a crash loop.
- **Limits to know:** requests are synchronous, so the conversion has to finish within Railway's request timeout; a request sent without a `Content-Length` is not measured against the upload limit; converting an animated GIF to JPG fails in FFmpeg itself.
- **Images:** upstream's `ghcr.io/crisog/ffmpeg-rest-standalone:1.2.0` and `ghcr.io/crisog/ffmpeg-rest-web:1.2.0`, pinned, each with a small start script; built by GitHub Actions and deployed as finished images. The Redis program (8.12.0) is copied from the official `redis` image. The FFmpeg build in the upstream image includes GPL components; ffmpeg-rest is Apache-2.0 and this template's own files are MIT.

## Why Deploy FFmpeg on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying FFmpeg on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — Self-hosted virtual tabletop for role-playing games (license required)
- [Double Commander in your browser](https://railway.com/deploy/double-commander-in-your-browser) — The Double Commander file manager in the cloud, from any device

Open this page in a browser: https://railway.com/deploy/ffmpeg
