Skip to content

powoftwo/minimal-go-transcoding-server

 
 

Repository files navigation

Minimal Go Transcoding Server

A lightweight REST API in Go that handles video uploads, stores them in S3-compatible object storage, and transcodes them into multiple HLS resolutions using FFmpeg.

Prequisties:

  • Go 1.21+
  • FFmpeg
  • A queuing solution (Redis)
  • An S3-compatible object storage solution (MinIO)

Workflow

  1. Accept Upload (API Service)
    Users upload a .mp4 file via the REST API.

  2. Store Raw Video (Object Storage)
    The uploaded video is stored in an S3-compatible object storage solution (MinIO).

  3. Queue Processing Job (Queuing Solution)
    The API does not process videos directly. Instead, it enqueues a job (via Redis) for background processing.

  4. Transcode Video (Worker + FFmpeg)
    The worker downloads the video and transcodes it into multiple resolutions:

    • 1080p
    • 720p
    • 480p

    It produces an HLS streaming package with:

    • .ts segment files
    • Individual playlists: 1080p.m3u8, 720p.m3u8, 480p.m3u8
    • A master playlist: master.m3u8
  5. Generate Thumbnail
    A single JPEG image is extracted from the video.

Example

POST /upload
    - Body: multipart/form-data
        - file: .mp4 video
    - Response: JSON with job ID

Quickstart

Local Setup

  1. Build binaries
make build
  1. Run the API & Worker
make run

Ensure a queuing solution (Redis) and a S3 compatible storage solution (MinIO) are running and accessible.

Dockerization

Run the entire stack using Docker Compose:

docker compose up -d

This will start:

  • API service
  • Worker service
  • Redis
  • MinIO

About

Minimal Go-based video transcoding server with REST API support, capable of storing uploaded videos in S3-compatible storage, queuing jobs for background transcoding, generating HLS streams in multiple resolutions, and creating thumbnails.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 94.0%
  • Makefile 6.0%