Why does compressing sometimes not work?

Soldato
Joined
2 May 2004
Posts
19,943
Hi,

Just a quick question:

How come sometimes I can compress a file and loose 100mb++ off it, but then other times I compress a file and loose a few KB off it.

I always do it the same way and use the same compression program but just don't get why it does that?

Thanks,
Craig.
 
Don
Joined
21 Oct 2002
Posts
46,744
Location
Parts Unknown
it always depends on how the file has been made, and how compressed it already is

great example is a divx video or an mp3 audio file, if you compress them with XP's "compress" tool (not the zip function) or 7zip, you'll still get pretty insignificant reductions, but if you were to compress a RAW avi file, you'd get awesome compression on it, the codecs used in these files (mp3 + divx) are all aimed at lower filesizes, so are optimized to be smaller

the same goes with pictures, if you compress a bmp file, you'll get awesome results, and with a jpg or png file you'll get very little compression (as they are already compressed)

also, with an empty word document, its usually around 25-30kb yes? (i don't use office at all), but if you compress it, its probably around 10-12kb (ms want files that don't lag when you open them, so i guess they use little optimization) -maybe its just bad programming in this case!



to test it for yourself, open notepad, and type..

test test test test test

(over and over for ages) then save it, it'll be 1byte large for each character, so my passage of tests above would be 24bytes if i saved it, and its easy to compress because its repetative!, your average compression tool will see that and 'think' "ok, i'll put a key in that says, test=1(space), and will replace your text with 11111. (for example)

an mp3 will have very little duplicate information in its file, wheras a wav file, will store a lot of information that is made obsolete to us
 
Caporegime
Joined
12 Mar 2004
Posts
29,913
Location
England
Yeah pictures videos and music are already compressed, if you want to compress them more youll have to use a special program designed to do it because winrar 7zip etc only use lossless compression.
 
Soldato
Joined
25 Oct 2002
Posts
2,569
Location
Cambridge,York,Bristol
bledd. said:

Good answer this. Another point about normal text files is that the alphanumeric keyboard uses say around 65 possible different characters (lowercase,uppercase,numbers and some symbols). But each byte (character) in a text file can be one of 256 possible things - so you can chuck four text characters into one, and there you have 75% compression already!

NOTE: all above is rough examples, not exactly accurate :p
 
Soldato
OP
Joined
2 May 2004
Posts
19,943
So basically it'll suck at compressing already compressed files (as said above, mp3, compressed videos etc.)?

Thanks for clearing it up for me :)

Craig.
 
Caporegime
Joined
12 Mar 2004
Posts
29,913
Location
England
Craig321 said:
So basically it'll suck at compressing already compressed files (as said above, mp3, compressed videos etc.)?

Thanks for clearing it up for me :)

Craig.

If you really needed to, you can use another codec to compress it. Ogg is much better than mp3/wma/aac for example and x.264 is better than xvid/divx/wmv/mpeg1&2
 
Associate
Joined
19 Jul 2004
Posts
2,039
Location
West Yorkshire
Try creating a massive text file full of just 1's so it's a couple of MBs big, then zip it up and it'll go down to practically nothing (as per one of the above explanations) :D
 
Back
Top Bottom