Computer Networking › Section B · The application layer › Topic B.6
Digital audio and video
Sound and moving pictures are the largest category of traffic the internet carries. Knowing how they become bits, and how compression shrinks those bits a hundredfold or more, explains what streaming and calls demand from the network.
From sound waves to bits
Sound is a continuously varying pressure wave, which a microphone turns into a varying voltage. To digitise it, a converter does two things. Sampling measures the signal at regular intervals, a fixed number of times per second. Quantisation rounds each sample to one of a fixed set of levels and stores it as a binary number: with b bits per sample there are \(2^b\) levels, so 8 bits give 256 and 16 bits give 65,536. This is pulse code modulation (PCM). The bit rate is the sampling rate times the bits per sample times the number of channels. More levels mean less rounding error, called quantisation noise.
How fast to sample: the Nyquist rate
Sampling too slowly loses information and creates false low tones, an effect called aliasing. The sampling theorem associated with Nyquist and Shannon says a signal can be rebuilt exactly if it is sampled at more than twice its highest frequency, after filtering out anything higher. Human hearing reaches about 20 kHz, so music needs over 40,000 samples per second; CDs use 44,100. Telephone systems keep only frequencies up to about 3.4 kHz, enough for intelligible speech, and sample at 8,000 times per second. Wideband voice in modern calls keeps frequencies up to about 7 kHz and samples at 16,000 per second.
Worked example: audio bit rates
Find the bit rates of telephone and CD audio. 1. Telephone PCM: 8,000 samples per second, 8 bits each, one channel: \(8{,}000 \times 8 = 64{,}000\) bit/s, or 64 kbit/s. 2. CD audio: 44,100 samples per second, 16 bits, two channels: \(44{,}100 \times 16 \times 2 = 1{,}411{,}200\) bit/s, about 1.41 Mbit/s. 3. One minute of CD audio: \(1{,}411{,}200 \times 60 \div 8 = 10{,}584{,}000\) bytes, about 10.6 MB. Check: CD audio needs about 22 times the telephone rate, which is why music services compress it heavily before sending it over the internet.
Compressing audio
Lossless compression, such as FLAC, keeps every bit and typically shrinks music to roughly half its size. Lossy perceptual codecs go much further by exploiting human hearing: they discard sounds too quiet to hear, or masked by louder sounds at nearby frequencies. MP3 and AAC give good music quality at about 128 to 256 kbit/s, under a fifth of the CD rate. Opus, standardised by the IETF in 2012 as RFC 6716, covers everything from about 6 kbit/s for speech to 510 kbit/s for music and is used in WebRTC and many calling apps. Speech codecs for calls usually run between about 8 and 32 kbit/s.
From pictures to video
Video is a sequence of still images, called frames, shown fast enough to look like motion: typically 24, 30 or 60 frames per second. Each frame is a grid of pixels, and each pixel needs a colour, often 24 bits, 8 each for red, green and blue. A 1080p frame is 1,920 by 1,080 pixels, about 2.1 million. Raw video is therefore enormous. Compression exploits two kinds of redundancy. Spatial redundancy: within a frame, neighbouring pixels are often alike, as in a blue sky. Temporal redundancy: consecutive frames are usually almost the same, because little moves in a thirtieth of a second.
I-frames, P-frames and B-frames
Modern video codecs divide frames into blocks. An I-frame, or key frame, is compressed on its own, like a still photo, so decoding can start from it. A P-frame is predicted from an earlier frame: for each block the encoder sends a motion vector, saying where a similar block was, plus a small correction. A B-frame can be predicted from frames both before and after it, saving even more. I-frames are the largest and B-frames usually the smallest. Because predicted frames depend on others, an error or a lost packet can spread until the next I-frame arrives, which is why encoders insert them regularly.
Worked example: why video must be compressed
Take 1080p video at 30 frames per second with 24-bit colour. 1. Bits per frame: \(1{,}920 \times 1{,}080 \times 24 = 49{,}766{,}400\). 2. Raw bit rate: \(49{,}766{,}400 \times 30 \approx 1.49 \times 10^9\) bit/s, about 1.5 Gbit/s. 3. A typical 1080p stream runs at about 5 Mbit/s, a compression ratio of about \(1{,}493 \div 5 \approx 300\) to 1. 4. A 2-hour film at 5 Mbit/s: \(5 \times 7{,}200 = 36{,}000\) Mbit, which is 4,500 MB, about 4.5 GB. Check: uncompressed, the same film would need about 1.3 TB, far beyond what home links or storage plans could sensibly handle.
Video codecs today
H.264, also called AVC, published in 2003, remains the codec almost every device can decode. HEVC, or H.265, from 2013, needs roughly half the bit rate for similar quality but has complex patent licensing. Google's VP9 and AV1, a royalty-free design released in 2018 by the Alliance for Open Media, are widely used by large streaming platforms, and many recent devices decode AV1 in hardware. VVC, or H.266, finalised in 2020, compresses further still. Newer codecs save bandwidth but need more computing power to encode, and older devices may not support them, so services often store several versions of each video.
What media asks of the network
Media applications fall into three groups. Streaming stored media, such as films on demand, can buffer seconds ahead and so tolerates delay, but needs average throughput above the video's bit rate. Conversational voice and video need low delay: about 150 ms one way feels natural, as ITU-T guidance recommends, and much beyond 400 ms makes conversation awkward. Live streaming, such as sports, sits between them. All media are sensitive to jitter, the variation in packet delay, and many can tolerate some loss through concealment. The internet guarantees none of these, so applications adapt, as the topics "Video streaming and content distribution networks" and "Real-time voice and video" show.
Common mistakes to avoid
First, mixing bits and bytes: a 5 Mbit/s stream uses 0.625 MB each second. Second, thinking sampling at exactly the highest frequency is enough; the rate must exceed twice that frequency. Third, forgetting the number of channels when computing an audio bit rate. Fourth, assuming each frame is sent whole; most frames are predictions from others. Fifth, believing a newer codec is always better; it may cost more processing or lack device support. Sixth, treating all media alike: stored streaming tolerates seconds of delay, conversation does not.
Key takeaways
Audio is digitised by sampling and quantising, at a rate above twice the highest frequency. Bit rate equals samples per second times bits per sample times channels: 64 kbit/s for telephone PCM and about 1.41 Mbit/s for CD audio. Perceptual codecs such as MP3, AAC and Opus discard what people cannot hear. Raw 1080p30 video needs about 1.5 Gbit/s; codecs exploit spatial and temporal redundancy with I-, P- and B-frames and motion vectors, reaching ratios of hundreds to one. H.264, HEVC, VP9, AV1 and VVC trade efficiency, support and licensing. Stored, conversational and live media differ in how much delay they tolerate.
Flashcards
Flashcard
Measuring a signal at regular intervals
Test your understanding
Question 1 of 5
Wideband voice is sampled 16,000 times per second at 16 bits per sample, in one channel. What is its uncompressed bit rate?
Question 2 of 5
What is the raw bit rate of 720p video (1,280 × 720 pixels) at 30 frames per second with 24-bit colour?
Question 3 of 5
Speech is filtered to keep frequencies up to 7 kHz. What is the lowest sampling rate that can capture it?
Question 4 of 5
Why do video encoders insert I-frames at regular intervals?
Question 5 of 5
Which kind of media application tolerates the most delay?
