The Challenge
Self-hosting a full media platform means owning every layer that a managed service like YouTube, Mux, or Cloudflare Stream normally hides: durable object storage for raw and processed video, a transcoding pipeline that has to run reliably without a cloud-scale worker fleet behind it, authentication and session handling, and a browsing experience — trending, live, feeds — that has to feel responsive even without a global CDN behind it. The core tension is cost versus control: a hosted video SaaS is simple to integrate but bills per GB stored and per minute transcoded, and locks playback behind someone else's API; running your own stack removes that bill and that lock-in, but pushes every failure mode — a stalled FFmpeg job, a full disk, a slow upload — back onto you. Streaming playback in particular is unforgiving: video has to be chunked, encoded at usable bitrates, and served in a way that survives a flaky home internet connection without falling back to spinner-and-buffer. None of this gets solved by picking a framework; it gets solved by getting the boring infrastructure — storage, queues, retries, TLS — right underneath a fairly ordinary Next.js app.
The sharpest design decision was the transcoding pipeline: instead of shelling out to FFmpeg on every upload request and hoping the Next.js process survives a multi-minute encode, video processing runs as a separate, queued step decoupled from the request/response cycle — the upload lands in S3-compatible storage first, then FFmpeg picks it up asynchronously to produce the renditions the player actually needs. That separation matters more on a single-node Kubernetes cluster than it would on a fleet of cloud workers: there's no elastic burst capacity to fall back on, so a stuck or oversized encode job has to fail safely and stay isolated from the parts of the platform serving live traffic, rather than taking the whole node down with it.
"It's less a demo and more a working answer to a specific question: what does it actually take to replace a managed video SaaS with something you control end to end?"
The Solution
The stack is deliberately boring where boring buys reliability: Next.js 16 handles both the frontend and the API surface, so there's one deployable artifact instead of a separate frontend/backend split to keep in sync. PostgreSQL, accessed through Prisma, is the source of truth for users, videos, and metadata — a relational model fits a catalog with clear relationships (users, uploads, views, playlists) better than a document store would. For storage, a self-hosted S3-compatible object store runs inside the same cluster, giving S3's API and tooling ecosystem without a per-GB cloud storage bill or a dependency on any one provider's console. FFmpeg does the actual encoding work, invoked from a processing path that's decoupled from the upload request itself. The whole thing ships through a GitOps pipeline: every change to the deployment manifests in git is reconciled onto the Kubernetes cluster automatically, which means shipping StreamTube looks exactly like shipping any of the other ~10 products already running there — no bespoke deploy process per project.