0

For some time now, I have been upgrading my music library from bad-sounding MP3 files to lossless FLACs. This obviously takes much more storage space.

The 465 GB internal disk which contains my "music" directory tree now has filled up > 95% of that drive, so I am forced to think of ideas to save bytes.

While experimenting with a random FLAC file, I discovered that I can run ffmpeg like this:

ffmpeg.exe -i "original.flac" -compression_level 12 "ultra_compressed.flac"

"12" is the maximum number supported, and the file size went from:

54 149 070 bytes

to:

48 828 507 bytes

Which is something. It will add up quite a bit if I do this for all my FLACs and if they all have similar results. But this seems "too good to be true".

I don't really suspect that it will make the songs sound worse, because FLAC is per definition lossless. It just uses more complicated compression methods, as I understand it, which takes much longer to encode and possibly noticeably so even to decode. However, I cannot detect any difference in the silence between songs playing pre- and post-compressing.

I am also concerned that this drops certain valuable metadata and resets the "created at" and/or "modified at" timestamps, which I have previously used many times to determine when I obtained or exported various sound/music files.

Can you please poke holes in my idea to free up storage space by writing a script which goes through every single FLAC file in my music directory tree and converts them, one by one, to the maximum compression level? Is there something about this which is bad?

(When the disk eventually dies, I will of course get a larger one to replace it, but hopefully it doesn't happen for a long time yet. Plus I still have to think about all the backup disks which also would have to be replaced with bigger ones if I simply "threw money at it". Plus I have no money to throw anyway.)

4
  • To clarify, when you say "I have been upgrading my music library" do you mean converting existing MP3 to FLAC, or do you mean re-acquiring the music as high quality FLAC? If you mean converting, I agree with the others that this is basically useless.
    – Paul
    Commented Nov 9, 2022 at 15:15
  • @Paul Obviously I mean getting FLAC versions of the same songs/albums... I didn't think it was possible to misunderstand this.
    – C. Castoro
    Commented Nov 9, 2022 at 16:07
  • @C.Castoro part of the problem is in the use of the word "upgrading" which essentially means "taking a thing I currently have and making it better", in this case what you had is MP3s and in context implies you were working on the mp3 files rather than newly ripped sources. "Replacing" would have been clearer and more technically correct word to use.
    – Mokubai
    Commented Nov 9, 2022 at 16:20
  • About the metadata, it's easy to check if they are still there or not after conversion... You don't need to check it on all the files, just on one file.
    – PierU
    Commented Nov 10, 2022 at 15:51

3 Answers 3

1

In terms of audio quality there should be no difference between FLAC compression 0 and 12.

Computationally it depends on where you are intending to listen to the music.

Higher compression will also mean more work to decompress. It may also mean more memory for decompression buffers and so on. On battery powered devices it might mean that the higher CPU and RAM load could mean that you lose battery life. As an extreme guess, on a portable device with a low power CPU it could mean that you go from 20 hours play time down to 15.

If disk space is expensive but you are never going to worry about battery life or CPU usage of a player then you'd want the highest compression possible.

If battery life is a concern then you might want to aim for a more moderate compression level, or no compression at all.

If you have enough space and patience though you could have the best of both worlds. You could create your main archival library using the highest compression to save space and then when you want to play the files on the go you can simply copy the ones you want and thenreencode them with lower compression. In theory there should be no generation losses as it is by definition a lossless codec.


Edit: a note for for future users who may consider converting from MP3 to FLAC. Converting files directly from MP3 to FLAC is borderline useless as you have already lost data in converting to mp3 to begin with. Any benefits that FLAC might provide have already been lost at that point. You cannot claw back data that was already discarded by the mp3 encoder. This answer assumes you encoded FLAC files from a high quality source material such as the original CD or studio FLAC files.

4
  • 1
    Does converting mp3 to flac really gain any quality??
    – Moab
    Commented Nov 9, 2022 at 14:59
  • 1
    No. Mp3 to flac gains nothing. My answer assumes high quality source FLAC files to begin with. Will edit answer accordingly.
    – Mokubai
    Commented Nov 9, 2022 at 15:00
  • I'm baffled by the responses and how you all seem to assume that I'm a complete moron who is somehow trying to convert MP3s to FLAC with improved audio... That's not even what the question was about; just the context...
    – C. Castoro
    Commented Nov 9, 2022 at 16:09
  • @C.Castoro I had originally assumed that was the case and that you were ripping from original sources, the response I got made me consider future users and my edit to add the first paragraph was really just for people who may stumble upon this in the future and might think that FLAC could magically improve audio quality. I moved it to the end of the answer as it is more of a comment/addendum.
    – Mokubai
    Commented Nov 9, 2022 at 16:13
-1

FLAC is a lossless compression format. As the name implies, lossless means: nothing is lost.

The MP3 format is a lossy format. It removes audio and tries to do this in the frequencies that you won't hear in order to significantly reduce the filesize, but the lower you go, the more you will hear it.

With FLAC, it will still remove frequencies, but they are in a range humans cannot hear. This is also why a FLAC file is usually only half the size of the WAVE file whereas MP3's are 10 to 20 times smaller compared to the WAVE file. In addition, MP3 files will apply MPEG compression, which means it samples clips of the audio, and when it finds similar clips that sound almost the same, it will use that same clip everywhere. If the quality setting is high enough, you will not hear any difference compared to the source, but if you compare using a spectral analizer, you will see that it is indeed different.

That explained, because FLAC does not apply compression, it keeps the audio in tact, and as such, there is no quality loss converting between FLAC and WAVE, and as such, if you reencode a FLAC file, the quality will always be the worst that this file was. So if you encoded to quality 8 before, and now reencode to 12, the file will be larger but sound exactly the same. Now, if you had quality 12 before, and you do 12 again, but now the filesize is smaller, then this is something you definitely can do.

FLAC encoders have become better over time, being able to identify and remove non-auditable frequencies.

That said, a general rule of thumb is, the more copies of a copy you make, the worst it becomes, and that may actually be happening here. Although it will not be auditable, it may actually remove something.

My suggestion therefor is: Do it, but set the output to a new file. Then compare both files side by side, and as long as it sounds the same, delete the larger file. The difference will be tiny anyway, but don't do it for one file, test that, and if okay, blindly do it for everything. My advise is still to test it for every single file, or just don't. The filesize is not a huge difference in a world where disks get larger all the time.

3
  • Listening to each song? Why?! The whole point is that it's lossless? And as for disks getting larger, I already addressed that and I can't just randomly buy new hardware without the old one first breaking beyond repair.
    – C. Castoro
    Commented Nov 9, 2022 at 16:08
  • The reason I state this, is because if for some odd reason things are different, I just don't want you to say: but you said I could. In theory, you should be able to reconvert without ever noticing it, but if for some reason its different, just checking the converted file before deleting the source is never a bad idea. For all you know, something happened and the converted file is corrupted. deleting the source means, you don't have it anymore.
    – LPChip
    Commented Nov 9, 2022 at 17:04
  • "With FLAC, it will still remove frequencies, but they are in a range humans cannot hear." Nope, FLAC keeps absolutely ALL of the original bits, whether they are audible or not. It does remove nothing.
    – PierU
    Commented Nov 10, 2022 at 15:49
-1

Can you please poke holes in my idea to free up storage space by writing a script which goes through every single FLAC file in my music directory tree and converts them, one by one, to the maximum compression level? Is there something about this which is bad?

I understand that you are asking about FLAC->FLAC conversion, but since you are actually having disk space issues, consider converting them all to a lossy audio codec like Opus.

I have a big FLAC collection and after researching I'm going to convert my FLAC collection to Opus, using a bitrate of 96 kbit, but even 90 kbit sounds the same. I tested and while 64 kbit sounds not bad, it does not sound transparent (to anyone basically). If you don't want to bother researching if 96 kbit is enough, go with 112 kbit or 128 kbit, but you'd be surprised that 96 kbit may be more than enough/sounding no different than FLAC/sounding transparent.

You asked for a script? Here you go: To convert FLAC to Opus:

find -type f -iname '*.flac' -print0 | parallel -0 opusenc --bitrate 96 {} {.}.opus

To convert FLAC to FLAC:

find -type f -iname '*.flac' -print0 | parallel -0 ffmpeg -i {} -compression_level 12 {.}-ultra_compressed.flac

One one test run on a ~489 MB FLAC CD -compression_level 12 saved me 0,0409%, which is not much of course.

3
  • 2
    Although this text can be of interest, it is not at all an answer to the question. Moreover the discussion about Opus quality versus bitrate is opinion-based. Please have a read at superuser.com/help/how-to-answer
    – PierU
    Commented Nov 11, 2022 at 15:53
  • "Although this text can be of interest" Well, so can be of interest then. Let the topic creator decide. I think my answer is at least as valid as the other ones, as it actually has the script he asked for. Amazing that despite the text walls, nobody posted an actual script which he asked for. My answer is fine, nobody answered everything either. Yes, Opus at 96 kbit is opinion. Commented Nov 11, 2022 at 16:13
  • The Stack Exchange sites have rules, that you ignore. A text of interest is not necessarily a poprer answer. 1) Read more carefully the question: at no point the OP has asked for a script. He asked if his idea to recompress all his FLAC files with a script was making sense, which is different. 2) all opinion-based questions or answers are off-topic. 3) it's not only the OP to decide what is a good answer, but the whole community.
    – PierU
    Commented Nov 11, 2022 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .