Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: FLAC tag and file size ? (Read 10222 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

FLAC tag and file size ?

Hello,

I just noticed that and at a first glance it looks weird to me.

I've encoded 11 FLAC files with FLAC Frontend. I've tagged them (without album cover), but I kept a copy of the untagged files.
When I compare their size, the tagged files and the non-tagged files have the exactly same size (in bytes).
(This changes of course if I add the album cover to the files.)

So why is that that add data to the file doesn't seem to make the file bigger ?
I guess I've used the standard tag files and maybe they have their place reserved even when they are empty ? Or something like that ?


Thank you for the info.

FLAC tag and file size ?

Reply #1
FLAC adds 8 KiB of padding by default when encoding files. That padding space allows for subsequent metadata alteration without changing the file size and without having to rewrite the file entirely.

FLAC tag and file size ?

Reply #2
If the file is over 20 mins long, FLAC adds 64KB of padding by default!

I have no use for cover art inside a flac file so I find that 8KB of padding is much much too large for my purposes. I can easily get away with 2KB, and most of the time 1KB is more than sufficient even for including replaygain tags.

Use the -P switch to make the padding size smaller than the default. E.g. -P 2048 will give you 2KB, -P 1024 will give you 1KB.

FLAC tag and file size ?

Reply #3
Let's see, a 20 min. FLAC file is already over 100 MB, and you're worried about an extra 64 KB?

Of course, I'm also mystified by people who worry about an extra 0.1 or 0.2% in compression ratio.

FLAC tag and file size ?

Reply #4
Let's see, a 20 min. FLAC file is already over 100 MB, and you're worried about an extra 64 KB?

Of course, I'm also mystified by people who worry about an extra 0.1 or 0.2% in compression ratio.

I'm not 'worried' about it. But it's pointless and arbitrary to add 64KB of padding to a file just because it's 20 mins long. I have many files that long. They don't deserve 8 times as much padding just for being longer. Why waste harddrive space on it for nothing? I use -P 1024 or -P 2048 in my command line and I get the padding just the way I want it without any worries. I'm sorry if that mystifies you. I am every bit as mystified by why a track needs 64KB of padding just because it's 20 mins long or why there are always people like you who feel the need to berate others for their preferences. I have provided the OP with information that he might find useful. What have you provided of value to this discussion? Very little. But just to be sure, I will remember to run my thoughts past you first before I post them, pdq, so that I won't risk mystifying you in the future.

FLAC tag and file size ?

Reply #5
I'm not 'worried' about it. But it's pointless and arbitrary to add 64KB of padding to a file just because it's 20 mins long.


I've never worried so much that I've adjusted it, but I have wondered about this. What was the original logic behind it?

I have 67 tracks of >= 20 minutes in my 35,000 track FLAC library, for a total of around 4.2 MB of wasted space, or the equivalent of about one 45 second track of music.

FLAC tag and file size ?

Reply #6
I'm not 'worried' about it. But it's pointless and arbitrary to add 64KB of padding to a file just because it's 20 mins long.


I've never worried so much that I've adjusted it, but I have wondered about this. What was the original logic behind it?

I have 67 tracks of >= 20 minutes in my 35,000 track FLAC library, for a total of around 4.2 MB of wasted space, or the equivalent of about one 45 second track of music.

And at today's prices that cost you approximately 0.042 cents.

FLAC tag and file size ?

Reply #7
it's pointless and arbitrary to add 64KB of padding to a file just because it's 20 mins long.


I was not aware of this property, but anyway, there are a couple of possible justifications: Long files are more likely to be full CD images consisting of all tracks, and when you embed a cuesheet which includes the tags for every track, it would be more likely to exceed 8K than a single-track tag set is. Second, I suppose users who care about space usage, will think that 64K minus whatever is used for a full CD, is no worse than 8K times the number of tracks (minus whatever is used). Third, I suppose that users who care about space usage, will be more inclined to put album art in a single-image file than in every track-file (in the latter case, they would probably save a folder.jpg instead).

Anyway, you can use the --dont-use-padding option.


Edit: And those 67 tracks you multiplied by 64, you forgot to subtract the actual usage ... that brings the total cost down by another very few basispoints  . Of course if you are at the very edge of having to buy a bigger hard drive, you could go WavPack or TAK, or for whatever codec you choose: use file system compression. It will hardly compress the music part, but nils in the metadata will compress just nicely.

FLAC tag and file size ?

Reply #8
I have a question about tagging in FLAC files.  I use the program Tagscanner for my tagging needs and I noticed something odd when I updated a few of the files with album art.  The program shows you the bitrate and the compression ratio at the bottom right of the tagging window.  When I added the album art, it increased the bitrate and the compression ratio.  However, when I removed the album art, it kept the bitrate and ratio the same, which was odd because I expected it to revert back to the values before I added the art.  I tried it in mp3Tag and that program showed me slightly different bitrate numbers which was odd because it should have shown the same numbers.  Does this happen often to other people that tag FLAC files and if so, does this tagging information change the audio data in some way since the program is showing a difference in bitrate and compression ratio?  Any clarification would be appreciated.

Thanks,
Basher

FLAC tag and file size ?

Reply #9
Tagging doesn't change audio data in any way.  What's happening is that adding an image increases your file's size.  When calculating bitrate as total file size in bytes divided by file length in seconds, adding an image will increase its bitrate.  However, tagging programs often replace parts of the file with padding when removing an image in order to avoid rewriting the whole file.  This explains why your bitrate doesn't shrink when taking the image back out again.  On the other hand, if program decides to calculate bitrate as file length not counting the metadata tags, it might give a different rate than one that uses the file's total size.

But because your file is lossless, its bitrate is largely academic and not something to worry about beyond how well your file happens to be compressed.

 

FLAC tag and file size ?

Reply #10
When I added the album art, it increased the bitrate and the compression ratio.  However, when I removed the album art, it kept the bitrate and ratio the same, which was odd because I expected it to revert back to the values before I added the art.


Many tagging programs, when you remove album art, will just put that space into the padding block instead of rewriting the whole file. Mp3tag also does this. It makes saving edits much faster.

Quote
I tried it in mp3Tag and that program showed me slightly different bitrate numbers which was odd because it should have shown the same numbers.


Bitrate may be calculated differently by the two programs. I'd suspect that one may use 10^6 as a megabit and the other may use 2^20.

Quote
Does this happen often to other people that tag FLAC files and if so, does this tagging information change the audio data in some way since the program is showing a difference in bitrate and compression ratio?  Any clarification would be appreciated.


No, the audio data does not change. The reason that the bitrate and compression ratio change when you add the artwork is that they're both calculated based on the total file size vs. the uncompressed size of the audio data in the file. When the file size goes up because the metadata (or padding) size increases then the bitrate (often expressed as 'average bitrate') for the _file_ goes up.

FLAC tag and file size ?

Reply #11
That's exactly the answers I was looking for!  I can now rest peacefully knowing that my FLAC files are not modified as far as the audio goes.  Thanks tuffy and JJZolx!   

Sincerely,
Basher

FLAC tag and file size ?

Reply #12
I have 67 tracks of >= 20 minutes in my 35,000 track FLAC library, for a total of around 4.2 MB of wasted space, or the equivalent of about one 45 second track of music.


And assuming you are using a filesystem with a block size of 4K, averaged you will waste roughly 2K of drive space per file.
35,000 files X 2K is about 70MB of wasted space due to filesystem overhead.

In other words, don't sweat the small stuff. You're wasting far more space just in file system overhead than the extra metadata space in those 67 tracks.
(If you really want to cringe, if you don't use the metadata space you're wasting 280MB across 35000 8k padded FLAC files!)




FLAC tag and file size ?

Reply #13
A large disc is probably divided into 64K clusters, making the file system overhead more than a gigabyte.