r/askscience • • Jun 17 '12

Computing How does file compression work?

(like with WinRAR)

I don't really understand how a 4GB file can be compressed down into less than a gigabyte. If it could be compressed that small, why do we bother with large file sizes in the first place? Why isn't compression pushed more often?

414 Upvotes

146 comments sorted by

View all comments

Show parent comments

4

u/[deleted] Jun 18 '12

What's wrong with Huffman encoding? It's one of the easiest encoding methods to understand and it's used all the time, for example in the fast lossless video encoder huffyuv.

2

u/[deleted] Jun 18 '12

Nothing is wrong with it, it's perfectly reasonable way to demonstrate compression and a few people have done so here. I wanted to get the LZ77 sliding window encoder out there though since no one seemed to be mentioning it, and it's a large part of understanding DEFLATE (zip), LZMA2 (7zip), etc.

1

u/CrasyMike Jun 18 '12

Nothing wrong with it. I don't think he was calling my comment out, just expanding on how my example is just one example.