Media Fundamentals
The core model
A streaming rendition is compressed media with timing and decode dependencies. The codec describes how samples are encoded. The container organizes encoded samples and metadata. The manifest later describes where timed pieces of those tracks can be found.
The same .mp4 extension can contain different video and audio codecs. That is why a filename alone cannot establish that a device can play an asset.
Why compression matters
Uncompressed video grows quickly. For a simple 1920 by 1080, 30 fps calculation using 24-bit RGB:
const bitsPerFrame = 1920 * 1080 * 24;
const bitsPerSecond = bitsPerFrame * 30;
const megabitsPerSecond = bitsPerSecond / 1_000_000;
// => about 1493 Mbps for uncompressed RGB samples
const gigabytesPerMinute = bitsPerSecond * 60 / 8 / 1_000_000_000;
// => about 11.2 GB per minute, using decimal GB
This is a rough upper-level model, not a prediction of an actual file. Real video is commonly stored with chroma subsampling such as 4:2:0, which reduces color detail relative to brightness. Audio, bit depth, color format, and frame rate also change the result.
A codec uses spatial redundancy within a frame and temporal redundancy across frames. Lossy codecs discard some information to reduce the data rate. More compression can reduce quality, but visible quality also depends on the encoder, content, motion, resolution, and display.
Codec and container
Codec means the rules for encoding and decoding media. Common video families include H.264/AVC, H.265/HEVC, VP9, and AV1. Their device support, licensing conditions, decode cost, and quality at a given bitrate differ; no single codec is universally best.
Container organizes encoded tracks and metadata. MP4/ISOBMFF and MPEG-TS can carry encoded samples; the container does not tell you which codec those samples use.
Bitrate uses bits per second. File size uses bytes, with 8 bits per byte. HLS BANDWIDTH values are expressed in bits per second, so 5000000 means 5 Mbps.
Frames, timestamps, and GOPs
Video is a sequence of timed frames. Encoders may use:
- I-frames that can be decoded without earlier pictures in the group.
- P-frames predicted from earlier pictures.
- B-frames that can use earlier and later pictures for prediction.
A GOP (Group of Pictures) is a sequence organized around random access points. With reordered B-frames, decode order and presentation order can differ; timestamps preserve both decode timing and display timing.
I B B P B B P B B I
|--------- GOP ---------|
For streaming, the important concept is the random access point, not merely a frame that happens to be called a keyframe. Segment boundaries and switching points must be compatible with the encoding and packaging profile. Apple, for example, requires HLS video segments to start with an IDR frame in its authoring specification.
Longer GOPs can improve compression efficiency but may make random access less frequent. Shorter GOPs can improve seek and switching opportunities while adding encoding overhead. The right interval depends on the delivery profile and latency goals.
Frame rate describes frames per second. Converting a 60 fps source to 30 fps removes temporal samples; converting 30 fps to 60 fps cannot invent real motion detail. Different renditions may use different frame rates, so a ladder must be designed for the device and content rather than inferred from resolution alone.
The source and the transformations
An OTT pipeline commonly receives a high-quality mezzanine master. That source gives the encoder room to make multiple output renditions without repeatedly encoding an already degraded stream.
Transcoding decodes and encodes media, often changing resolution, codec, frame rate, or bitrate. Lossy re-encoding can reduce quality, and encoding consumes compute.
Transmuxing moves encoded samples into another container or transport layout without re-encoding the samples. It is usually much cheaper than transcoding, but timestamps, codec constraints, and container compatibility still matter.
Packaging commonly combines prepared audio/video tracks, creates segments, and writes manifests. Some systems also transcode during this pipeline; the terms describe different operations even when a service performs both.
Gotchas
| Looks like | Actually | Why |
|---|---|---|
| 1080p means a known bitrate | Resolution describes dimensions only | Motion, codec, encoder settings, and quality target change bitrate |
| Keyframe means every segment can start there | Random access and closed-GOP behavior depend on encoding details | A segment may still depend on samples before its boundary |
| 60 fps always doubles file size | Encoded size depends on motion and rate control | Frame count is only one input to compression |
| Transmuxing improves picture quality | It preserves encoded samples | Quality changes require an encoding or filtering operation |
| One codec works on every device | Decoding depends on device, browser, codec profile, level, and container | Capability must be tested for the target environment |
Resources
- MDN: Video codecs: codec/container distinction and browser media concepts.
- Apple HLS authoring specification: segment continuity and random access requirements for Apple devices.
- FFmpeg documentation: tools for inspecting and transforming media.
- Back to OTT Streaming Delivery.