Stop 22 · Build Backend Portfolio ProjectsProjects · 13/14

Video Streaming Backend

Part of the Backend Developer Roadmap

In short

Nobody downloads a whole movie before pressing play. Streaming backends cut video into small chunks at several qualities, so playback starts fast and adapts to your network.

A backend supporting video upload and streaming — practice for handling large files, streaming responses, and range requests for seekable video playback.

The purple blob caterer serves hot puris one at a time onto a guest's plate.

Think of it like this

Hot puris at a wedding

The caterer doesn't dump 50 puris on your plate at once. He serves two at a time, hot, as you eat. If you slow down, he slows down. Video streaming serves small chunks the same way, just in time.

Watch it happen

From upload to playback

Upload
Queue
Transcode
Store
CDN
Player

1/6The creator uploads a large MP4 straight to object storage with a presigned URL.

The big ideas

What you need to know

Transcode in the background

Converting video is heavy CPU work. It runs in queued workers, never inside an API request.

HLS: chunks plus playlists

Each quality is a list of small segments in an .m3u8 playlist. A master playlist lists all qualities.

Adaptive bitrate

The player measures download speed and picks the best quality for the next chunk, so video rarely stalls.

CDN does the heavy lifting

Segments are static files, perfect for CDN caching. Your servers handle metadata, auth and analytics.

See it in code

Walk through the code

bash
1# Turn one upload into a 720p HLS stream: small .ts chunks plus a playlist2ffmpeg -i upload.mp4 \3  -vf scale=-2:720 -c:v libx264 -preset veryfast -b:v 2800k \4  -c:a aac -b:a 128k \5  -hls_time 6 -hls_playlist_type vod \6  -hls_segment_filename "out/720p_%03d.ts" \7  out/720p.m3u88 9# Repeat for 480p and 360p, then list all three in a master playlist,10# so the player can switch quality as the network changes.

1/3Scale to 720p height, encode video with H.264 at about 2.8 Mbps and audio with AAC.

Run this inside a worker that picks up transcode jobs. The output folder is what you upload to storage and serve through a CDN.

Save yourself the pain

Common mistakes

Oops

Serving the original MP4 from your Node.js server.

Do this instead

Every viewer then pulls the full-size file through your server. Transcode to HLS and serve from storage plus a CDN.

Oops

Running FFmpeg inside the upload request.

Do this instead

Transcoding can take minutes. Queue it, return processing status, and notify when it's ready.

Your mission

Milestone 1: play your own HLS

~40 min

Quick check

Why are videos cut into small segments at several qualities?

Go deeper

  1. 1Support HTTP range requests so users can seek within a video without downloading it fully.
  2. 2Process uploaded videos asynchronously, e.g. generating thumbnails, via a job queue.
  3. 3Store video files in cloud storage and serve them through a CDN.

More projects at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge