Video platform
A video platform that turns one upload into an adaptive-bitrate stream, encodes in parallel without visible seams, and only spends compute on the renditions people actually watch.
The problem
Course creators, publishers and product teams in Bangladesh need video that starts fast on a cheap phone over a patchy mobile connection, and they pay for every minute of encoding and every gigabyte served. It takes a single upload and produces an adaptive stream that starts at the smallest size and climbs as the connection allows, with playback links that expire and a library that is protected from casual copying.
Challenges
Parallel encoding without quality seams
Splitting a long video into chunks is the only way to encode it quickly, but chunks encoded independently tend to pump: the quality visibly jumps at every boundary. Each chunk is encoded with constant-quality rate control capped by a buffer limit, never per-chunk average bitrate, on a fixed two-second keyframe interval shared by every rendition with scene-cut keyframes disabled. Because every rendition lines up on the same boundaries, chunks stitch back together and players switch sizes mid-stream without a re-encode.
Only paying to encode what gets watched
Encoding every size up front wastes compute on renditions nobody requests. Encoding ladders are data rather than code, and the default mobile ladder encodes its smallest sizes immediately while the higher ones are deferred: the first request for them queues the work, deduplicated so a thousand viewers trigger one encode. The tradeoff is that the high-quality master has to be kept for as long as the video exists.
Protecting a library without real DRM
Customers selling courses need more than an unguessable URL. Segments are encrypted with common encryption and a key licence, with the opening seconds left in the clear so playback starts without waiting on the licence. Links can be bound to a single viewer and a watermark label, with a per-viewer device cap and origin locking on top. It is honest encryption, not studio DRM, and the documentation says so.
Importing whole libraries safely
Moving to a new host means pulling hundreds of videos from wherever they live now. Import accepts a URL, a CSV, another hosting provider or a customer’s own bucket. Because fetching arbitrary URLs from inside the network is a classic server-side request forgery hole, every fetch is checked against private address ranges and re-checked after each redirect.
Implementation
Chunked pipeline on a job queue
Upload, probe, split, encode, package and publish are separate background jobs, so a crash resumes at the failed stage instead of starting over. Each chunk encode gets one thread, and concurrency follows the container’s real CPU limit rather than the host’s core count.
Viewer analytics off the playback path
Player heartbeats land in a columnar analytics store through a buffered, non-blocking batch writer that drops rows rather than ever slowing a viewer down. Since that store has no row-level security, every query goes through one place that always scopes by organisation.
Stable identities for changing files
A video can have its file replaced, be trimmed in the built-in studio, or gain captions and chapters while its id, embed code and analytics stay the same, so a link printed in a course never breaks.
Why this stack
- Go
- Long-running media jobs, a playback server and an API in one statically-linked binary that is easy to run on a few machines.
- ffmpeg + a packager
- The industry-standard encoder for the ladder, and a dedicated packager for adaptive streaming and encryption, with perceptual quality scoring to check the output.
- PostgreSQL
- Videos, ladders, jobs and billing need transactions and row-level tenant isolation; the job queue lives in the same database.
- ClickHouse
- Viewing heartbeats are high-volume and append-only, exactly what a columnar store aggregates cheaply.
- S3-compatible storage
- Masters and renditions go to object storage, so compute and storage scale independently.
What it does
- Resumable multipart uploads and bulk import from other hosts
- Adaptive streaming with a mobile-first ladder and on-demand high renditions
- Signed, expiring playback with encryption, watermark labels and device caps
- Captions, chapters, trims and file replacement that keep the same video id
- A branded embeddable player, webhooks and nested folders
- Per-video viewer analytics and per-minute billing
- Commercial DRM: Widevine, PlayReady and FairPlay
- Importers from Vimeo, Bunny and storage buckets
- H.265, DASH and 4K