codec - shrinking data

CODEC is an electronic circuit or software that compresses or decompresses digital audio/video. It converts raw (uncompressed) digital audio/video to a compressed format or vice versa. https://en.wikipedia.org/wiki/Video_codec

But if we chose to pack millions of images in a single file and called it a movie, we might end up with a huge file. Let’s do the math:

Suppose we are creating a video with a resolution of 1080 x 1920 (height x width) and that we’ll spend 3 bytes per pixel (the minimal point at a screen) to encode the color (or 24 bit color, what gives us 16,777,216 different colors) and this video runs at 24 frames per second and it is 30 minutes long.

  1. toppf = 1080 * 1920 //total_of_pixels_per_frame
  2. cpp = 3 //cost_per_pixel
  3. tis = 30 * 60 //time_in_seconds
  4. fps = 24 //frames_per_second
  5.  
  6. required_storage = tis * fps * toppf * cpp

This video would require approximately 250.28GB of storage or 1.11Gbps of bandwidth! That’s why we need to use a CODEC.