Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Video Transcode

A FastAPI service that uploads videos to MinIO, queues transcoding jobs with Celery, processes videos with FFmpeg, and reports job progress through Server-Sent Events.

What it does

  • Accepts MP4 uploads through an HTTP API.
  • Stores the original video in MinIO.
  • Creates one Celery job per configured resolution.
  • Transcodes videos to 480p, 720p, 1080p, and 4K by default.
  • Stores transcoded files back in MinIO.
  • Tracks each resolution status in Redis.
  • Streams job status updates from the API.

Tech stack

  • FastAPI
  • Celery
  • Redis
  • MinIO
  • FFmpeg
  • Docker Compose

Requirements

  • Python 3.10+
  • Docker and Docker Compose
  • FFmpeg installed on the machine running the Celery worker

Setup

Start Redis and MinIO:

docker compose up -d

Create and activate a virtual environment:

python -m venv venv
source venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Run

Start the API:

uvicorn server:app --reload

Start the Celery worker in another terminal:

celery -A tasks.celery_client worker --loglevel=info

API

Health check

GET /

Returns:

{
  "message": "Hello World"
}

Upload a video

POST /upload

Form field:

  • file: MP4 video file

Example:

curl -X POST http://localhost:8000/upload \
  -F "[email protected]"

Response:

{
  "job_id": "..."
}

Stream job status

GET /status/{job_id}

Example:

curl -N http://localhost:8000/status/<job_id>

Example event payload:

{
  "480": "done",
  "720": "done",
  "1080": "failed",
  "4k": "done"
}

Configuration

Default settings are in config.py:

Setting Default
REDIS_URL redis://localhost:6379
MINIO_HOST localhost
MINIO_PORT 9000
MINIO_ACCESS_KEY minioadmin
MINIO_SECRET_KEY minioadmin
MINIO_BUCKET videos

Resolutions are also configured in config.py.

Notes

  • MinIO console runs at http://localhost:9001 with the default credentials from docker-compose.yml.
  • Uploaded and transcoded files are stored in the configured MinIO bucket.
  • Local virtual environments, Python cache files, logs, and generated media files are ignored by Git.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages