Sub topic 1
Clarifying Requirements and Scope
Prerequisites
This chapter assumes basic web architecture, HTTP caching, object storage, message queues, and short Python or shell snippets.
Clarifying requirements and scope
Start by defining the product before choosing infrastructure. Ask:
- Is the platform video-on-demand, live streaming, or both?
- How many uploads, viewers, and concurrent streams are expected?
- What devices, resolutions, and regions must be supported?
- What startup delay, playback quality, and availability targets apply?
- Are videos public, private, paid, or protected by DRM?
- How long must original and processed files be retained?
These answers determine storage, transcoding capacity, CDN design, security, and cost. Separate functional requirements, such as “users can upload and watch videos,” from non-functional requirements, such as “99.9% monthly availability.”
Estimating storage, bandwidth, and compute
For a first estimate:
- Storage is approximately
uploads per day × average source size × retention days, plus encoded renditions. - Egress bandwidth is approximately
viewers × average delivered bitrate × watch time. - Transcoding work depends on input duration, number of output renditions, codec, and available workers.
For example, 10,000 daily views averaging 20 minutes at 3 Mb/s produce about 450 GB of delivered data per day before caching effects. Use measurements from real traffic later. These estimates are planning inputs, not capacity guarantees.
Video basics: codecs, containers, and bitrate
A codec compresses and decompresses media, such as H.264 for video or AAC for audio. A container packages encoded streams and metadata, such as MP4 or MPEG-TS. Bitrate is the number of bits delivered per second. Higher bitrate usually improves quality but increases storage and network use.
A transcoder creates several renditions with different resolutions and bitrates:
ffmpeg -i input.mp4 -vf scale=-2:720 \
-c:v libx264 -b:v 2800k -c:a aac -b:a 128k \
-f hls -hls_time 4 -hls_playlist_type vod \
720p/index.m3u8The end-to-end architecture
Object storage holds source files and packaged segments. A queue decouples uploads from processing. Workers transcode and package the video. A CDN caches segments near viewers.
Uploading and ingesting source video
Do not send large files through the application server. The API should authorize an upload and return a time-limited, pre-signed object-storage URL. The client uploads directly, then reports completion. The service validates size, type, checksum, and ownership before placing a job on the queue.
Exercise
Why create multiple renditions instead of serving one high-bitrate file?
Show answer
Different renditions let the player match quality to the viewer’s device and current network.