System Design blueprint · Media & OTT
Video upload & adaptive streaming
Upload once, transcode in parallel, stream at the quality each viewer's network can take.
- Steps
- 6
- Subjective questions
- 32
- Objective questions
- 32
The problem and the outcome
Problem: One large video file stutters on slow networks and wastes bandwidth on fast ones.
Outcome: Smooth playback everywhere, with quality adjusting second by second.
Architecture
How it works, step by step
- The creator uploads the raw file straight to object storage with a pre-signed URL.
- The upload event puts a transcode job on a queue.
- Workers split the video into chunks and transcode them in parallel into several resolutions.
- Short HLS/DASH segments are published to a CDN close to viewers.
- The player measures bandwidth and switches quality segment by segment.
- Thumbnails, captions and metadata are stored for search and recommendations.
Tech stack
- S3 / GCS with multipart or resumable upload
- Queue + FFmpeg transcoders
- HLS / DASH packaging
- CDN
- Metadata DB
- DRM (Widevine, FairPlay) when needed
Key design decisions
- Upload straight to object storage with pre-signed URLs, so large files bypass the app servers.
- Split the video into chunks and transcode them in parallel into a ladder of resolutions and bitrates.
- Adaptive bitrate streaming (HLS/DASH): the player switches quality per segment as the network changes.
Common mistakes
- Uploading through the API server and tying up its memory and bandwidth.
- Transcoding a long video as one sequential job.
- Serving video from origin storage instead of a CDN, with huge egress costs.
What to measure
- Time from upload to playable
- Rebuffering ratio
- Video start time
- CDN hit ratio and egress cost
Most-asked interview questions
Subjective questions 32
1Design a video upload and streaming service like YouTube.Asked almost every time
The client uploads in resumable chunks directly to object storage using pre-signed URLs. An event queues transcoding: workers split the file, encode each chunk into several resolutions, and package HLS/DASH segments with a manifest. Metadata and thumbnails go to a database. Playback fetches the manifest and segments from a CDN, and the player adapts the bitrate to the network.
2Walk through what happens after a video is uploaded.Asked almost every time
The file lands in object storage, an event triggers a transcoding pipeline that splits it into segments and encodes several resolutions and bitrates in parallel, generates thumbnails and captions, packages HLS or DASH manifests, runs content checks, then marks the video ready and publishes it to the CDN-backed playback path.
3How does the transcoding pipeline scale?Asked almost every time
Split the source into chunks (for example a few seconds each), transcode chunks in parallel on a worker fleet (often spot instances or GPUs), then stitch outputs. A job orchestrator tracks each chunk, retries failures, and priorities let short or popular uploads finish first.
4How do you serve video to millions of viewers?Asked almost every time
Segments and manifests are cached on CDNs close to viewers, with long cache lifetimes because segments never change. The origin is object storage with an origin shield to reduce load. Popular videos are pre-warmed to edge caches; rare videos are fetched from origin on demand.
5How does adaptive bitrate streaming work?Very often asked
The video is encoded at several quality levels and cut into segments of a few seconds. A manifest lists them. The player measures bandwidth and buffer level and picks the quality for each next segment, dropping to a lower one before the buffer runs dry.
6HLS vs. DASH: what is the difference?Very often asked
Both split video into small segments listed in a manifest at several bitrates. HLS (from Apple) uses .m3u8 playlists and is required on iOS Safari; DASH is an open standard with .mpd manifests. CMAF lets one set of fMP4 segments serve both, halving storage.
7How do you store video metadata and view counts?Very often asked
Store metadata (title, owner, status, renditions) in a database, cache it heavily, and count views asynchronously through an event stream aggregated into counters, so hot videos do not lock rows.
8How would you design live streaming differently?Very often asked
Ingest RTMP or SRT streams at the nearest point, transcode in real time into short segments (or low-latency HLS parts), push them to the CDN continuously, and keep latency low with small segments. Recording for replay happens in parallel.
9How do you protect paid content?Very often asked
Use DRM (Widevine, FairPlay, PlayReady) with encrypted segments and a licence server that checks entitlements, plus signed, short-lived CDN URLs or cookies so links cannot be shared.
10How do you reduce storage and delivery costs?Very often asked
Use efficient codecs (AV1, HEVC) for popular videos, fewer renditions for rarely watched ones, per-title encoding that picks bitrates by content complexity, tiered storage for old videos, and high CDN cache hit rates.
11What is per-title or content-aware encoding?Very often asked
Choosing the bitrate ladder for each video based on its complexity: a static lecture needs far fewer bits than a sports match for the same quality, so storage and bandwidth drop without visible loss.
12How does a player choose the right quality?Very often asked
It measures download throughput and buffer level, then requests the highest bitrate it can sustain, switching between renditions at segment boundaries. Good players avoid frequent switches and start at a conservative bitrate for fast startup.
13How do you design view counting that resists fraud?Very often asked
Count a view only after a minimum watch time, deduplicate by viewer and video within a window, filter bots by behaviour and known data-centre IPs, and aggregate counts asynchronously from playback events. Show approximate counts quickly and correct them after fraud analysis.
14How would you add resumable playback across devices?Very often asked
Have the player send its position every few seconds and on pause to a progress service keyed by user and video, store the latest value in a fast store, and on open fetch the position and seek there. Ignore positions in the last few seconds so finished videos start fresh.
15How would you make uploads resumable on a bad mobile network?Often asked
Split the file into parts and upload each separately (S3 multipart or the tus protocol), recording which parts succeeded. After a drop, the client asks which parts exist and uploads only the missing ones, then completes the upload.
16How do you generate thumbnails and previews?Often asked
Extract frames at intervals during transcoding, pick candidates by quality or let creators choose, and create sprite sheets for scrubbing previews in the player.
17How are captions and subtitles handled?Often asked
Generate captions with speech recognition or accept uploaded files, store them as WebVTT tracks referenced in the manifest, and let viewers choose languages; machine translation can add more.
18How do you detect copyright or policy violations?Often asked
Fingerprint audio and video and compare against a reference database (like Content ID), run classifiers for policy violations, and queue uncertain cases for human review before or after publishing.
19How do you track playback quality?Often asked
Players send telemetry: startup time, rebuffering ratio, bitrate switches, errors and watch time. Aggregate it by CDN, region, device and ISP to find and fix problems.
20How do recommendations interact with the video platform?Often asked
Viewing events feed a recommendation system that ranks candidates by predicted watch time; the platform pre-warms caches for videos likely to be recommended widely.
21What happens if transcoding fails halfway?Often asked
Chunk-level jobs retry independently; the orchestrator resumes from completed chunks, and after repeated failure marks the upload failed and notifies the creator, keeping the original for another attempt.
22How do you estimate storage for a video service?Often asked
Multiply uploaded hours per day by the sum of rendition bitrates: 500 hours a minute of uploads at an average of 10 Mbps across renditions is roughly 2–3 PB per day before replication, which is why codec efficiency matters.
23How do you handle videos that suddenly go viral?Often asked
Most load is absorbed by the CDN, so pre-warm popular segments, enable origin shield, lower manifest cache times only if needed, and scale the metadata and view-count services, which still see a request per viewer.
24How do you design video chapters and timestamps?Often asked
Store chapters as a list of start times and titles with the video metadata, parse them from creator descriptions or generate them automatically from transcripts, and expose them in the player as markers and as deep links with a time parameter.
25How do you support downloads for offline viewing?Often asked
Let the app download an encrypted rendition at a chosen quality, protect it with DRM licences that allow offline playback for a limited period, limit the number of devices, and renew or revoke licences when the user reconnects.
26How do you moderate live streams in near real time?Often asked
Sample frames and audio continuously into classifiers, combine with user reports, show warnings or cut the stream when confidence is high, route uncertain cases to human moderators, and keep a short buffer so actions happen before most viewers see the content.
27Why use an origin shield?Sometimes asked
It is a mid-tier cache between edge locations and the origin, so many edges missing the same segment cause one origin fetch instead of hundreds.
28How do you handle very long uploads from creators?Sometimes asked
Use multipart uploads with resumable chunks (S3 multipart or tus), verify checksums, and let processing start as soon as the upload completes.
29What is low-latency HLS?Sometimes asked
An extension that publishes partial segments and preload hints so live latency drops from tens of seconds to a few seconds, at the cost of more requests.
30How do you handle video deletion?Sometimes asked
Mark the video deleted, stop serving it, purge CDN caches, and delete renditions and originals from storage asynchronously according to retention rules.
31Which metrics show the platform is healthy?Sometimes asked
Upload success rate, transcoding queue time, time to publish, playback start time, rebuffering ratio, CDN hit rate and cost per streamed hour.
32How do you choose which renditions to keep for old, rarely watched videos?Sometimes asked
Keep the source or a high-quality mezzanine plus a few common renditions, delete rarely used ones, move files to colder storage classes, and re-transcode on demand if a missing rendition is requested.
Objective questions 32
1What lets a player switch quality mid-stream?Asked almost every time
Why: Segments at several bitrates let the player pick a different quality for each next segment.
2What lets a player change quality mid-stream?Asked almost every time
Why: This is adaptive bitrate streaming.
3How is transcoding made fast for long videos?Asked almost every time
Why: Then outputs are stitched.
4Where should video segments be served from?Asked almost every time
Why: Segments never change and cache well.
5Why use pre-signed URLs for uploads?Very often asked
Why: A pre-signed URL grants time-limited permission to write one object straight to the bucket.
6Which format is required for Safari on iOS?Very often asked
Why: Apple's streaming protocol.
7What does CMAF allow?Very often asked
Why: Halves segment storage.
8Which protects paid video from copying?Very often asked
Why: Widevine, FairPlay, PlayReady.
9Per-title encoding chooses bitrates based on…Very often asked
Why: Simple content needs fewer bits.
10How are view counts kept fast?Very often asked
Why: Hot videos would block rows.
11Which ingest protocols are common for live streams?Very often asked
Why: Then transcoded into segments.
12A view should usually count only after…Very often asked
Why: Brief plays and bots would inflate counts.
13Resume positions are stored…Very often asked
Why: They change often and are read on every open.
14Which tool is most commonly used to transcode video?Often asked
Why: FFmpeg is the standard open-source encoder behind most transcoding pipelines.
15Which player metric hurts users most?Often asked
Why: Stalls drive viewers away.
16What does an origin shield reduce?Often asked
Why: It is a mid-tier cache before the origin.
17Which format stores captions?Often asked
Why: Referenced in the manifest.
18How are copyright matches found?Often asked
Why: Compared against references.
19What do thumbnail sprite sheets enable?Often asked
Why: Frames combined into one image.
20Which codec reduces bandwidth most for popular videos?Often asked
Why: Worth the encoding cost at scale.
21What should happen when one transcoding chunk fails?Often asked
Why: Only the failed chunk is retried.
22Signed CDN URLs prevent…Often asked
Why: Signed URLs expire quickly.
23During a viral spike, most segment traffic is served by…Often asked
Why: Segments are cacheable and identical for every viewer.
24Offline downloads stay protected through…Often asked
Why: Licences control how long and where content plays.
25Video chapters are stored as…Often asked
Why: The player reads them to show markers.
26Rarely watched old videos save money by…Often asked
Why: Missing renditions can be regenerated on demand.
27Low-latency HLS reduces live delay by…Sometimes asked
Why: Latency drops to seconds.
28Which upload method resumes after failures?Sometimes asked
Why: Failed chunks are retried individually.
29Deleted videos must also be…Sometimes asked
Why: Otherwise edges keep serving them.
30Why start playback at a conservative bitrate?Sometimes asked
Why: Then step up quality.
31Which manifest extension does HLS use?Sometimes asked
Why: DASH manifests use .mpd instead.
32A short broadcast delay in live moderation lets you…Sometimes asked
Why: The buffer buys time for automated checks.
Track your progress through every blueprint in your dashboard.
Start learning