Multimedia System ApplicationUnit 711 min read
Multimedia Compression: Techniques, Formats & Applications
Unit 7 of Multimedia System Application explores how data reduction techniques (lossless, lossy, and hybrid) optimize storage and transmission of audio, video, and images—covering algorithms (e.g., JPEG, MP3, H.264), compression ratios, and real-world trade-offs between quality and efficiency.
Why Compression Matters
Multimedia files (images, audio, video) are inherently large. A single 1-minute HD video can exceed 1 GB uncompressed. Compression reduces file size while preserving perceptual quality, enabling:
- Faster streaming (e.g., YouTube, Netflix).
- Lower storage costs (e.g., cloud backups, mobile devices).
- Efficient transmission (e.g., 4G/5G data limits).
Key Trade-off: Compression vs. Quality
- Lossless: No data loss (e.g., ZIP files), but limited compression.
- Lossy: Sacrifices minor details for high compression (e.g., MP3, JPEG).
- Hybrid: Combines both (e.g., H.264 video codecs).
1. Lossless Compression: No Data Loss
Definition: Reduces file size without discarding any original data. Reconstructs the exact original file upon decompression.
How It Works
Lossless compression exploits redundancy in data:
- Repetition: Storing "aaaabbb" as "4a3b" (run-length encoding).
- Patterns: Using dictionaries (e.g., LZW in GIF/PNG).
- Entropy: Assigning shorter codes to frequent symbols (Huffman coding).
flowchart TD
A["Original Data"] -->|"Redundancy Analysis"| B["Dictionary/Codebook"]
B -->|"Replace Patterns"| C["Compressed Data"]
C -->|"Decompress"| B
B -->|"Reconstruct"| AReal-World Example: eSewa’s Transaction Logs
- Problem: eSewa processes millions of transactions daily, each with repetitive fields (e.g., user ID, timestamp).
- Solution: Lossless compression (e.g., Zstandard) reduces database size by 60–80%, speeding up queries without losing transaction records.
Common Lossless Formats
| Format | Use Case | Algorithm |
|---|---|---|
| ZIP | File archives | DEFLATE (LZ77 + Huffman) |
| PNG | Lossless images | DEFLATE + Filtering |
| FLAC | High-quality audio | Linear Prediction + Huffman |
| GIF | Simple animations | LZW |
2. Lossy Compression: Sacrificing Quality for Efficiency
Definition: Permanently removes "irrelevant" data (e.g., frequencies humans can’t hear, color imperceptible to the eye). Achieves 10x–100x smaller files than lossless.
How It Works
Lossy compression targets human perception limits:
- Audio (MP3): Removes frequencies >20 kHz (inaudible to most) and quantizes low-amplitude sounds.
- Images (JPEG): Discards high-frequency details (e.g., fine textures) using Discrete Cosine Transform (DCT).
- Video (H.264): Exploits temporal redundancy (similar frames) via motion compensation.
flowchart LR
A["Original Frame"] --> B["DCT: Frequency Domain"]
B --> C["Quantize: Discard High Frequencies"]
C --> D["Entropy Coding (Huffman)"]
D --> E["Compressed Frame"]Real-World Example: YouTube’s Video Streaming
- Problem: A 1080p video requires ~10 Mbps uncompressed. Mobile users have limited bandwidth.
- Solution: YouTube uses H.264/AVC (lossy) to stream at ~2 Mbps, reducing file size by 80% while maintaining "good enough" quality for most viewers.
Common Lossy Formats
| Format | Domain | Key Technique | Example Use |
|---|---|---|---|
| JPEG | Images | DCT + Quantization | Facebook profile pictures |
| MP3 | Audio | Psychoacoustic modeling | Spotify music |
| H.264/AVC | Video | Motion compensation + DCT | Netflix shows |
| AAC | Audio | Perceptual noise shaping | Apple Music |
3. Hybrid Compression: Best of Both Worlds
Definition: Combines lossless and lossy techniques for optimal trade-offs. Used in modern codecs like H.265 (HEVC) and AV1.
How It Works
- Lossy stage: Reduces data size aggressively (e.g., DCT for video).
- Lossless stage: Compresses residuals (remaining errors) without loss.
- Metadata: Stores parameters for perfect reconstruction.
mindmap
root((Hybrid Compression))
Lossy Stage
DCT
Quantization
Lossless Stage
Arithmetic Coding
Context Modeling
Metadata
Bitstream SyntaxReal-World Example: Daraz’s Product Images
- Problem: Daraz hosts millions of product images (e.g., clothing, electronics). Storing all as lossless PNG would require terabytes of space.
- Solution: Uses WebP (hybrid: lossy for photos, lossless for logos) to reduce image sizes by 30–50% while keeping visual quality acceptable for online shopping.
Comparison: Lossless vs. Lossy vs. Hybrid
| Feature | Lossless | Lossy | Hybrid |
|---|---|---|---|
| Quality Loss | None | High (irreversible) | Minimal (controlled) |
| Compression Ratio | 2:1 to 5:1 | 10:1 to 100:1 | 15:1 to 200:1 |
| Use Case | Text, code, medical images | Music, photos, videos | Streaming, web delivery |
| Example | ZIP, FLAC | MP3, JPEG | H.265, WebP |
4. Compression Techniques Deep Dive
A. Entropy Coding (Huffman, Arithmetic)
- Idea: Assign shorter codes to frequent symbols.
- Example: In English text, "e" appears more often than "z". Huffman coding assigns
0to "e" and100to "z". - Real Use: Used in JPEG, MP3, and ZIP files.
B. Transform Coding (DCT, Wavelet)
- Idea: Convert data into a frequency domain where redundancy is easier to exploit.
- DCT: Used in JPEG (separates image into "smooth" and "detail" frequencies).
- Wavelet: Used in JPEG 2000 (better for medical/scientific images).
graph LR
A["Original Image"] --> B["DCT: 8x8 Blocks"]
B --> C["Quantize: Keep Low Frequencies"]
C --> D["Zig-Zag Scan + Huffman"]C. Predictive Coding (Delta Encoding)
- Idea: Store differences between frames (used in video).
- Example: In a talking-head video, only the mouth region changes. Predictive coding stores the first frame fully and subsequent frames as deltas (changes).
5. Audio Compression: MP3 vs. AAC vs. Opus
How Audio Compression Works
- Filtering: Remove frequencies outside human hearing range (0–20 kHz).
- Psychoacoustic Model: Mask loud sounds with quiet ones (e.g., a drum beat masks a soft guitar).
- Quantization: Reduce precision of less important samples.
Comparison Table
| Codec | Bitrate (kbps) | Quality | Use Case | Patents/Licensing |
|---|---|---|---|---|
| MP3 | 96–320 | Good | Legacy music (iTunes) | Fraunhofer (licensed) |
| AAC | 64–256 | Better | Apple Music, YouTube | Open (ISO standard) |
| Opus | 6–512 | Best | WebRTC, Discord, Zoom | Royalty-free |
Real-World Example: Ncell’s Voice Calls
- Problem: Uncompressed voice requires 64 kbps. Mobile networks have limited bandwidth.
- Solution: Uses Opus codec (adaptive bitrate) to reduce data usage by 70% while keeping call quality clear.
6. Video Compression: H.264 vs. H.265 vs. AV1
Key Techniques
- Intra-frame compression: Compress each frame independently (like JPEG for video).
- Inter-frame compression: Exploit similarities between frames (motion compensation).
- Macroblocks: Divide frames into 16x16 pixel blocks for efficient encoding.
Comparison Table
| Codec | Compression | Bitrate Savings | Use Case | Adoption |
|---|---|---|---|---|
| H.264 | Good | ~50% vs. MPEG-2 | YouTube, Blu-ray | Universal |
| H.265 | Better | ~50% vs. H.264 | 4K streaming (Netflix) | Growing |
| AV1 | Best | ~30% vs. H.265 | YouTube, WebM | Royalty-free |
7. Worked Example: Calculating JPEG Compression Ratio
Problem: A 24-bit RGB image (8 bits per channel) is 1024×768 pixels. After JPEG compression, it’s saved as 50 KB. What’s the compression ratio?
Solution:
- Uncompressed size: .
- Compressed size: 50 KB = 0.05 MB.
- Compression ratio: .
Real-World Tie-In: This ratio is typical for Facebook profile pictures. If every user uploaded uncompressed images, Facebook’s storage costs would skyrocket.
8. Challenges and Trade-offs
| Challenge | Impact | Solution |
|---|---|---|
| Quality degradation | Artifacts (blockiness, ringing) | Adaptive quantization, higher bitrate |
| Computational cost | Slow encoding/decoding | Hardware acceleration (GPU, TPU) |
| Patents/licensing | High costs (e.g., H.264) | Royalty-free codecs (AV1, VP9) |
| Error propagation | Corrupted frames in video | Error resilience tools (e.g., B-frames) |
In the Real World
Khalti’s Transaction Data
- Idea Used: Lossless compression (e.g., Snappy or Zstandard).
- How: Khalti processes thousands of transactions/sec. Compressing logs reduces database load, ensuring low-latency responses for users.
Pathao’s Ride-Hailing App
- Idea Used: Hybrid video compression (H.265 for driver-passenger calls).
- How: Calls use adaptive bitrate streaming to work on 2G–5G networks, balancing quality and data usage.
NTC’s Fiber-Optic Backbone
- Idea Used: Audio/video compression (AAC for VoIP, H.264 for video conferencing).
- How: Compression reduces bandwidth needs, enabling more simultaneous calls on limited fiber capacity.
Exam Tip
What Examiners Look For
- Definitions: Clearly distinguish lossless vs. lossy vs. hybrid compression.
- Algorithms: Know Huffman coding, DCT, and motion compensation steps.
- Formats: Match formats to use cases (e.g., FLAC for audio, WebP for web images).
- Calculations: Practice compression ratio and bitrate problems.
- Real-World Links: Relate concepts to Nepali apps (e.g., eSewa logs, Daraz images).
Common Pitfalls
- Confusing JPEG (lossy) with PNG (lossless).
- Ignoring perceptual models (e.g., psychoacoustics in MP3).
- Overlooking metadata in hybrid codecs (e.g., H.264’s SEI messages).
Sample Exam Question & Answer
Q: Explain how MP3 compression reduces file size without significantly affecting audio quality. A:
- Frequency Filtering: Removes frequencies >20 kHz (inaudible to humans).
- Psychoacoustic Model: Discards sounds masked by louder frequencies (e.g., bass masking high notes).
- Quantization: Reduces precision of less important samples (e.g., quiet guitar strings).
- Huffman Coding: Assigns shorter codes to frequent data patterns. Visual: Include a psychoacoustic masking curve diagram to show which frequencies are discarded.
Based on the TU BITM syllabus for Multimedia System Application (IT273), unit 7.
Discussion
Loading…