Why does audio and video take so much storage?

415 views

So for example, videogames are super heavy on disk space. And aparently most of that space is just the sounds, textures, models, etc. But the code takes very little space.

Why can something as complex as a physics system weight less than a bunch of images?

Code takes very little space, media takes more. But an image is just code that tells the computer how to draw something (I think)

So how come some code gets to be so small in size and some code doesn’t?

In: 53

18 Answers

Anonymous 0 Comments

Code is like looking at a picture, and describing it to someone the way you normally would – you may use a fair number of words to describe it, but most of the work is done by the brain of the person, interpreting those words to build an image in their head.

An image is like looking at a picture and describing each individual pixel, in terms of color and position. It would take *a lot* more words just to do that. You might naturally describe a small handful of major elements in a picture, and then a few dozen smaller details to really flesh an image out. Let’s go nuts and say 100 details, large and small, and each one gets 2 dozen words of description. You just used 2400 words to really deeply describe a picture.

A 4k image, just one still image, is 8.3 million pixels. To describe color and position, you’ll need at least 3 words per pixel, realistically more like 6-10 if you don’t have some sort of encoding schema for what you’re saying. So, somewhere between 25 – 75 million words, to say what you just said with 2400 words when describing the picture naturally.

The metaphor is a bit weird, but the basic idea is that code has a lot of efficiencies that allow it to do a lot with just a few “commands”. That’s the power of loops. And no matter how much you compress audio and images, at the end of the day it needs to be uncompressed and produce something extremely close to the original. It’s gonna need to serve 8.3 million pixels to your eyeball.

So, let’s talk about what kinda code you’d need to write to take that 4k resolution image and display it on your screen, so you can see it. This is a reductive example, you’d never write a program like this because many of these problems are already “solved” by the operating system and the game developer gets to just use the tools provided by the OS “for free” to do a lot of the heavy lifting for things like sending an image to your monitor, but we’ll roll with it. That’s another reason the code gets to be small – it doesn’t have to literally run your whole computer, it just has to run itself.

So, ignoring all of that, you’ve got a 4k image on your hard drive and you’re writing a program to display it on the screen. The image is uncompressed, 8.3 million pixels that all have their own location and color, and a little bit extra to define what kind of image it is, when it was created, what’s the filename, etc.

(Basically) all you have to write to get that to the screen is:

* set position to 1, which corresponds to the first pixel

* read pixel data

* send to corresponding pixel on the monitor

* increment position by 1

* check to see if there’s any more data

* if more data, go back to the first step

* if there’s not, you’re done

And there you have it. Small, but it displays the whole image for you. It runs 8.3 million times, but you don’t have to write each and every one of those interactions, and it doesn’t live as 8.3 million interactions on your hard drive, it lives like a machine code version of just what you see here.

You are viewing 1 out of 18 answers, click here to view all answers.