Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Hypermedia and multimedia on the web

How hypermedia and multimedia are carried, played, and adapted on the web: MIME and HTTP basics, HTML5 media, streaming protocols, containers, codecs, adaptive bitrate and CDN delivery.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Multimedia and hypermedia on the web are how video, audio, interactive timelines and linked resources reach users across devices and networks. An engineer designs servers, players, manifests, and CDN rules so media plays smoothly, respects bandwidth and accessibility rules, and works across browsers and platforms.

Key ideas

Start from the basics.

  • Hypermedia: data that contains links to other media or documents (text, images, audio, video) and allows non-linear navigation. Define before use: it extends "hypertext" by including multimedia types.
  • Multimedia: combination of two or more media types (text, image, audio, video, animation, interactivity) used together. In web context, multimedia is packaged, signalled and transported to browsers/clients.

Networking and formats

  • MIME type (Multipurpose Internet Mail Extensions): a string in HTTP headers (Content-Type) that declares the media type and subtype (for example video/mp4). Exact statement: an HTTP response should include a correct Content-Type header indicating the media type; browsers rely on it to select a container parser, and clients may also probe file signatures. The actual codec is identified via the codecs parameter (RFC 6381) or in-file metadata.
  • Container format: a file-level structure that carries one or more streams (audio, video, subtitles, metadata). Example containers: MP4 (ISO BMFF), WebM, Matroska (MKV). Containers do not themselves define compression — they only store tracks and timing.
  • Codec: coder-decoder algorithm that compresses/decompresses a data stream (video, audio). Examples: H.264/AVC, H.265/HEVC, VP9, AV1 for video; AAC, Opus, MP3 for audio. Exact statement: a container plus codec information (fourcc, codec string) lets the player choose the correct decompression implementation.

Delivery and streaming

  • HTTP progressive download: client requests a file using HTTP(S), server sends bytes. Player can start playback before full download if it can access initial moov/metadata box. Use Range requests for seeking.
  • Adaptive Bitrate Streaming (ABR): technique where media is encoded at multiple bitrates and the client switches between them to match available bandwidth. Two common ABR protocols: HLS (HTTP Live Streaming) and DASH (Dynamic Adaptive Streaming over HTTP). Both: media split into short segments; a manifest (playlist/MPD) describes segments and variants. HLS uses M3U8 playlists (.m3u8) with MPEG-TS or fMP4/CMAF segments; DASH uses MPD (XML) with fMP4/CMAF segments. Exact: ABR requires multiple encoded representations and a client logic for measuring bandwidth and switching at segment boundaries.
  • Chunked delivery and segment duration: segments are typically 2–10 seconds. Shorter segments give faster adaptation and lower latency; longer segments reduce overhead and HTTP requests. Low-latency HLS/DASH often use CMAF chunked transfer with sub-second chunks (e.g., 200–500 ms) within segments over HTTP/2 or HTTP/3.

Browser and web APIs

  • HTML5 media elements: <audio> and <video> elements embed media in pages. Use nested <source> elements to provide multiple MIME+codec alternatives, and <track> for captions/subtitles (WebVTT). Exact syntax: <video controls><source src="file.mp4" type="video/mp4"></video>.
  • Media Source Extensions (MSE): JavaScript API that allows dynamic feeding of media segments (from ABR manifest) into an HTMLMediaElement. This enables DASH/HLS players in-browser without native HLS support; note that Safari provides native HLS support, while other browsers typically rely on MSE-based JavaScript players.
  • Encrypted Media Extensions (EME): API for communicating with CDMs (Content Decryption Modules) for DRM-protected content.
  • WebRTC: peer-to-peer real-time streaming protocol over RTP/SRTP, used for low-latency live communications, not for VOD ABR.

Delivery infrastructure

  • CDN (Content Delivery Network): distributed cache servers that serve static media segments close to clients to reduce latency and packet loss. Exact: media origin contains manifests and segments; CDN edge caches them and responds to clients using HTTP(S).

Cross-cutting issues

  • CORS (Cross-Origin Resource Sharing): HTTP headers (Access-Control-Allow-Origin) that allow browsers to use resources from other origins. Media fetched via XHR/fetch for MSE requires correct CORS headers if origin differs. A bare <video>/<audio> element can play cross-origin without CORS (no-cors mode), but CORS is required if the crossorigin attribute is used or if you need to expose the media to canvas/WebAudio without tainting.
  • Accessibility: captions, audio descriptions and correct use of <track kind="captions"> are required by accessibility standards (e.g., WCAG) in many contexts; provide appropriate <track>s (e.g., kind="captions" vs kind="subtitles") for accessible multimedia.
  • Metadata and seeking: containers must place header/seek tables (e.g., MP4 moov box, often called an atom) at file start or provide byte-range access to enable seeking without full download.

Diagrams to draw for an exam answer (describe exactly):

  • Draw a client–CDN–origin flow: left box labelled "Client(web browser)" connected to middle box labelled "CDN edge" connected to right box labelled "Origin server". Label arrows "HTTP GET /manifest" and "HTTP GET /segment.ts". Annotate that CDN caches segments and origin serves on miss.
  • Draw time-line of ABR switching: horizontal time axis, segments 1..n, with heights showing bitrate chosen; label download durations and buffer level.

Formulas

bitrate_video = bpp · frame_rate · width · height — where bitrate_video is bits per second (b/s), bpp = bits per pixel per frame (dimensionless), frame_rate in s^-1 (Hz), width and height in pixels. Applies when estimating compressed video bitrate from bpp.

bitrate_audio = sample_rate · bits_per_sample · channels — bits per second. sample_rate in Hz, bits_per_sample in bits, channels (1 for mono, 2 for stereo). Applies for uncompressed PCM audio.

file_size_bytes = (bitrate_bps · duration_s) / 8 — convert bits to bytes. duration_s in seconds.

bytes = bits / 8 — 8 bits per byte.

seconds = file_size_bytes · 8 / bitrate_bps — duration given file size and bitrate.

HTTP request-line syntax to remember: GET /path HTTP/1.1 and header Host: example.com and Range: bytes=start-end for partial content (server replies 206 Partial Content with Content-Range: bytes start-end/total). Use Content-Type: type/subtype; codecs="..." when advertising codec parameters (e.g., video/mp4; codecs="avc1.42E01E, mp4a.40.2").

Worked examples

Example 1 — estimate video bitrate and file size (university style): Given: 1080p (1920×1080), 30 fps, choose compressed bits-per-pixel bpp = 0.1 (dimensionless), duration 10 minutes. Compute bitrate and file size.

  1. Formula: bitrate_video = bpp · frame_rate · width · height.
  2. Numbers: width·height = 1920·1080 = 2,073,600 pixels. frame_rate·pixels = 30·2,073,600 = 62,208,000 pixel-frames/s.
  3. bitrate = 0.1 · 62,208,000 = 6,220,800 b/s = 6.2208 Mbps.
  4. File size: file_size_bytes = bitrate_bps · duration_s / 8.
  5. duration = 10 min = 600 s. file_size_bytes = 6,220,800 · 600 / 8 = 466,560,000 bytes ≈ 466.56 MB (decimal megabytes). Final answer: bitrate = 6.2208 Mbps, file size ≈ 466.56 MB (600 s).

Example 2 — PCM audio file size (step-by-step): Given: PCM 16-bit, 44,100 Hz, stereo (2 channels), duration 3 minutes.

  1. Formula: bitrate_audio = sample_rate · bits_per_sample · channels.
  2. bitrate = 44,100 · 16 · 2 = 1,411,200 b/s.
  3. Bytes per second = 1,411,200 / 8 = 176,400 B/s.
  4. Duration = 3 min = 180 s, total bytes = 176,400 · 180 = 31,752,000 bytes.
  5. Convert to MiB: 31,752,000 / (1024·1024) ≈ 30.28 MiB. Final answer: file size ≈ 31,752,000 bytes ≈ 30.28 MiB.

Example 3 — ABR segments count (short): Given: live stream with segment duration 6 s, want 3 minutes of buffer. Number of segments = buffer_seconds / segment_duration = 180 / 6 = 30 segments. Final: 30 segments.

Common mistakes

  • Ignoring container overhead and indexes: real file sizes are slightly larger than bitrate·duration due to headers and indexes.
  • Using wrong units for sample rate and frame rate (Hz vs. kHz) without conversion.
  • Assuming all browsers support the same codecs and containers — always provide fallback source elements or transcode for compatibility.
  • Forgetting CORS for MSE/XHR fetched segments — player will fail if Access-Control-Allow-Origin absent.

For your exam

Types of questions:

  • Definitions and short notes: define MIME, container, codec, ABR, CDN, MSE/EME.
  • Derivations and numericals: derive bitrate from bpp and frame rate; compute file size from bitrate and duration; compute sample sizes for PCM audio.
  • Diagrams: draw client-CDN-origin flow and ABR segment timeline; label manifest, segments, caches.
  • Practical code/syntax: write minimal <video> tag with multiple sources and a <track>; show HTTP Range request format. What full-marks answers include:
  • Precise definitions with bold terms, clear assumptions (e.g., uncompressed vs compressed), units, and correct numeric conversions.
  • Step-by-step derivations for numericals with formulas given before substitution, unit carrying, and final boxed value.
  • For diagrams, clear labels and arrows, and short captions explaining each piece.

Quick check

  1. What header tells a browser the media type of an HTTP response? 2) Formula for PCM audio bitrate with symbols? 3) Name two ABR streaming protocols. Answers: 1) Content-Type (MIME type). 2) bitrate_audio = sample_rate · bits_per_sample · channels where units are b/s, Hz, bits, count. 3) HLS and DASH.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?