What is the compression percentage of your FLAC library? |
What is the compression percentage of your FLAC library? |
Sep 22 2012, 03:32
Post
#1
|
|
|
Group: Members Posts: 318 Joined: 26-November 04 Member No.: 18345 |
I've always been curious about the average compression rate across my whole FLAC library.
My library is just shy of 36,000 files, with a makeup of about 40% rock, 40% jazz, and the remainder a mixture of bluegrass, country, classical, folk, rap, electronic, etc. It's all encoded at the default -5 level, and the tagging consists of basic text fields, with no embedded images. I compared the total file sizes in bytes to the calculated expanded music size. It worked out to 41.9% compression on the entire library. Total FLAC files size: 925.092 GB (993,310,377,824 bytes) Total uncompressed size: 1580.926 GB (1,708,243,555,030 bytes) Ratio: 0.581 Compression: 41.9% |
|
|
|
![]() |
Sep 28 2012, 14:33
Post
#2
|
|
|
Group: Members Posts: 109 Joined: 20-August 07 Member No.: 46367 |
Not counting the metadata blocks, it works out to:
Compressed: 688.5GB (739,319,931,688 bytes) Uncompressed: 1243.7GB (1,335,454,659,871 bytes) Ratio: 0.5536 The metadata blocks take up an additional 6.2GB, which is mostly embedded cover art. |
|
|
|
Oct 6 2012, 22:58
Post
#3
|
|
|
Group: Members Posts: 276 Joined: 31-December 10 Member No.: 86948 |
Not counting the metadata blocks, it works out to: Compressed: 688.5GB (739,319,931,688 bytes) Uncompressed: 1243.7GB (1,335,454,659,871 bytes) Ratio: 0.5536 The metadata blocks take up an additional 6.2GB, which is mostly embedded cover art. Tuffy, how did you determine the amount of space taken by your metadata blocks? Thanks! |
|
|
|
Oct 7 2012, 02:52
Post
#4
|
|
|
Group: Members Posts: 109 Joined: 20-August 07 Member No.: 46367 |
|
|
|
|
Oct 10 2012, 00:08
Post
#5
|
|
|
Group: Members Posts: 276 Joined: 31-December 10 Member No.: 86948 |
Tuffy, how did you determine the amount of space taken by your metadata blocks? Thanks! I wrote a little Python script to do it. FLAC's metadata blocks are pretty easy to walk through so it didn't take long. To channel a kid/young adult in a cheesy commercial for a product I can't recall who repeatedly whines "....and?"... It would be great if you could post your admittedly clever python script |
|
|
|
Oct 10 2012, 14:21
Post
#6
|
|
|
Group: Members Posts: 109 Joined: 20-August 07 Member No.: 46367 |
To channel a kid/young adult in a cheesy commercial for a product I can't recall who repeatedly whines "....and?"... It would be great if you could post your admittedly clever python script Here goes. It's called with a single directory as the first argument which it searches recursively. It assumes your FLAC files end in ".flac" and match the spec (without any ID3 junk at the beginning, an initial STREAMINFO block and so on). There's no progress indicator either, but you're welcome to add some if you like. CODE #!/usr/bin/python import sys import os.path import struct def read_block_header(f): """takes FLAC file stream returns (is last, block ID, block length)""" i = struct.unpack(">I", f.read(4))[0] return (i >> 31, (i >> 24) & 7, i & 0xFFFFFF) def parse_streaminfo(s): """takes 34 byte STREAMINFO block as string returns (sample rate, channel count, bits per sample, PCM frames)""" i = struct.unpack(">10xQ16x", s)[0] return (i >> 44, ((i >> 41) & 7) + 1, ((i >> 36) & 0x1F) + 1, i & 0xFFFFFFFFF) def FLAC_sizes(filename): """returns (metadata length, frames length, uncompressed size) or raises IOError or ValueError if some error occurs""" metadata_length = 0 f = open(filename, "rb") if (f.read(4) == "fLaC"): metadata_length += 4 else: raise ValueError("not a FLAC file") (is_last, block_ID, block_length) = read_block_header(f) metadata_length += 4 if (block_ID == 0): (sample_rate, channel_count, bits_per_sample, PCM_frames) = parse_streaminfo(f.read(block_length)) uncompressed_size = (channel_count * (bits_per_sample / 8) * PCM_frames) metadata_length += block_length else: raise ValueError("STREAMINFO not first block in stream") while (is_last != 1): (is_last, block_ID, block_length) = read_block_header(f) metadata_length += 4 f.read(block_length) metadata_length += block_length return (metadata_length, os.path.getsize(filename) - metadata_length, uncompressed_size) if (__name__ == "__main__"): total_metadata_length = 0 total_frames_length = 0 total_uncompressed_length = 0 for (d, ds, fs) in os.walk(sys.argv[1]): for f in fs: if (f.lower().endswith(".flac")): path = os.path.join(d, f) try: (metadata_length, frames_length, uncompressed_length) = FLAC_sizes(path) total_metadata_length += metadata_length total_frames_length += frames_length total_uncompressed_length += uncompressed_length except (ValueError, IOError), err: print "*** %s: %s" % (path, err) print " metadata length : %s" % (total_metadata_length) print "total frames length : %s" % (total_frames_length) print "uncompressed length : %s" % (total_uncompressed_length) print " compression : %2.2f%%" % \ ((float(total_frames_length) * 100) / float(total_uncompressed_length)) |
|
|
|
JJZolx What is the compression percentage of your FLAC library? Sep 22 2012, 03:32
Porcus All encoded with -8, figures reported by foobar200... Sep 22 2012, 10:56
JJZolx So only 35% and 38.6%, respectively. Interesting. Sep 22 2012, 14:59
xnor I limited results to: %codec% IS flac AND %__bitsp... Sep 22 2012, 15:42
JJZolx Man, that's only 30.3%.
A sample size of thre... Sep 22 2012, 17:09
[JAZ] you didn't calculate Porcus's values corre... Sep 22 2012, 18:38
JJZolx Thanks. The 614 kbps calculation was wrong, but as... Sep 22 2012, 19:03
xnor The files I selected above have a total duration o... Sep 22 2012, 19:09
[JAZ] What is wrong is the assumtion that kilobits per s... Sep 22 2012, 19:11
xnor Afaik kbit/s means kilo bits per second = 10^3 bit... Sep 22 2012, 19:15
Porcus As long as the denominator of 1411.2 k has the sam... Sep 23 2012, 13:48
Remedial Sound FWIW my lossless library is "only" 3,800... Sep 23 2012, 19:50
shakey_snake CODEDuration : 1wk 6d 18:13:27.801 ... Sep 26 2012, 06:21
A_Man_Eating_Duck mine is
CODE GB MB B Compression
WAV... Sep 26 2012, 07:05
Porcus QUOTE (shakey_snake @ Sep 26 2012, 07:21)... Sep 26 2012, 19:10
Kohlrabi I only have FLAC -8 files, and filtering via ... Sep 26 2012, 08:09
A_Man_Eating_Duck Ha
The encode script i'm running is only che... Sep 27 2012, 23:56
imre_herceg My library is about 95% Classical music.
Average ... Oct 6 2012, 15:35
SigHunter my FLAC library has an average of 930 kbps which m... Oct 12 2012, 12:14
godrick tuffy, thank you for posting the script - it works... Oct 14 2012, 14:21![]() ![]() |
|
Lo-Fi Version | Time is now: 21st May 2013 - 11:36 |