Home About lightbulbSkillUp Projects Contact Us
Client Login

Streaming Course Video on a Budget: HLS, R2 and a CDN

VideoCloudflare R2HLSArchitecture

Video is usually the most expensive part of running a learning platform. Managed players charge per minute watched; cloud storage charges again every time a student presses play. When we built learn.steleios.com we wanted Udemy-style playback — adaptive quality, resume position, instant seeking — without a per-view bill.

The answer was a boring, reliable pipeline: ffmpeg for transcoding, Cloudflare R2 for storage, and a CDN in front. R2's killer feature is zero egress fees — the thing that makes most video hosting expensive is free.

The pipeline

When an instructor uploads a lesson, the server transcodes it into three HLS quality tiers (1080p, 720p, 480p) with four-second segments and a master playlist. The whole tree is pushed to R2 with immutable cache headers, so the CDN caches every segment essentially forever.

The player is hls.js — it reads the master playlist and switches quality automatically as the student's bandwidth changes. Total cost per view after the first: effectively zero, because the CDN serves everything from cache.

Protecting paid content

Public bucket URLs are fine for previews but not for paid lessons. Our backend issues time-limited HMAC-signed URLs, and a small Cloudflare Worker verifies the signature at the edge before serving from R2. One token covers a whole video's playlist and segments, so the player never notices — but a shared link dies within hours.

The lesson: you don't need a video SaaS to ship professional course playback. A day of plumbing with open tools gets you the same experience, and your costs stop scaling with your success.

Discussion0

Log in to join the discussion.

No comments yet — start the conversation.