INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Why does the Flac Compression Level affect the bitrate?  (Read 3509 times)

EnglishTiger

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1084
Why does the Flac Compression Level affect the bitrate?
« on: June 19, 2020, 08:08:42 am »

I decided to do some experimenting with the Flac Compression Level to see what effect it would have and after having ripped a disc using the Compression Level at 0 and then, to a different folder, with the Compression Level set to the recommended level 6.

The first thing I noticed was that when ripping with the level set to 6 the speed MC took less time and the drive speed showing in the rip progress window was usually higher.
However when I loaded the "ripped files" into Playing Now I spotted a noticeable difference between the bitrate, including 1 incidence where the bitrate had more than doubled.
See attached Screenie - the Tracks where the sequence number is odd are the ones ripped with the Compression Level set to 0

During playback I also spotted that the bitrate displayed in the player varied between 779 (lowest) and 1256 (highest) for one of the Compression Level 0 but the same track where the Compression Level was 6 only varied between 555 and 1027.
I realise I'm using a Non-Quantifiable Subjective Measure but the "uncompressed tracks" sounded clearer and cleaner than their "compressed equivalent".
Logged
Apple Mac Mini Desktop Computer with M4 Pro chip with 12 core CPU and 16 core GPU: 24GB Unified Memory, 512GB SSD Storage, Gigabit Ethernet, 3 Thunderbolt5 + 2USBC ports.

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72439
  • Where did I put my teeth?
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #1 on: June 19, 2020, 08:11:16 am »

Compression level is only related to the file size that is produced.  You can use it to reduce the size, but the encoding takes longer.  The savings in size is very small.  Less than 5%.  It's not worth doing.  Just use the default.

Try Google if you want to learn more.
Logged

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3119
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #2 on: June 19, 2020, 10:10:35 am »

 The amount of the compression depends on the data in the file.  Some files have repeating patterns that are easy to compress, some do not. A general observation would be that the greater the complexity of the music, the harder it is to compress.

Flac compression level 0 is actually compressed quite a bit - often in the 40% range.  Levels above that increase the compression, but  not by that much. A file that is compromised 40% at level 0 may go to 50% at the highest level of compression. The algorithms are set up so that the compression process takes increasing amount of CPU time, but decompression is pretty much the same for all levels.

dBpoweramp has implemented am "uncompressed" flac format, which has no compression. It is basically a wav file with a flac header. I think they are the only ones who have implemented that.

Bitrate is based on the size of the compressed file, not on the size of the uncompressed file. That is why it has lower values for more compressed files. It has nothing to do with the final, uncompressed data and should not be used to determine the quality of a recording.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #3 on: June 19, 2020, 12:22:27 pm »

Bitrate is based on the size of the compressed file, not on the size of the uncompressed file. That is why it has lower values for more compressed files. It has nothing to do with the final, uncompressed data and should not be used to determine the quality of a recording.

dtc gave you the correct answer.

Tiger, you're confused about the nature of bitrate in the context of mathematically lossless files.  You're thinking about MP3 CBR, a lossy compression, where bitrate directly correlates with quality.  There is no such correlation for FLAC.

MP3:  more compressed=lower bitrate, lower quality
FLAC: more compressed=lower bitrate, unchanged (perfect) quality

Regarding your listening test with uncompressed sounding better, I'm afraid that is cognitive bias. The decompressed waveforms are mathematically identical. Sorry.
Logged

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #4 on: June 19, 2020, 12:47:18 pm »


dBpoweramp has implemented am "uncompressed" flac format, which has no compression. It is basically a wav file with a flac header. I think they are the only ones who have implemented that.


There is certainly an “uncompressed” Flac compression setting. But IMHO it is not “basically a wav file”. And IMHO it is neither proprietary nor specific to dBpoweramp. Indeed any player that can decode Flac should be able to handle “uncompressed” Flac out of the box..

Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3119
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #5 on: June 19, 2020, 12:58:30 pm »

There is certainly an “uncompressed” Flac compression setting. But IMHO it is not “basically a wav file”. And IMHO it is neither proprietary nor specific to dBpoweramp. Indeed any player that can decode Flac should be able to handle “uncompressed” Flac out of the box..

As far as I know, dBpoweramp is the only program that has implemented "creating" an uncompressed flac file. But, yes, any flac player should be able to play it.

I call an uncompressed flac file a wav file with a flac header because, as I understand it, the data bits are the same as you find in a wav file. The header is a flac header rather than a wav header.  Therefore, I see it as essentially a wav file with a flac header, rather than a wav header. This allows for flac tagging. Is there something else to the uncompressed format?
Logged

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #6 on: June 19, 2020, 02:56:01 pm »

As far as I know, dBpoweramp is the only program that has implemented "creating" an uncompressed flac file. But, yes, any flac player should be able to play it.

I call an uncompressed flac file a wav file with a flac header because, as I understand it, the data bits are the same as you find in a wav file. The header is a flac header rather than a wav header.  Therefore, I see it as essentially a wav file with a flac header, rather than a wav header. Is there something else to the uncompressed format?

See this https://xiph.org/flac/

A Flac file is a highly refined structure comprising frames (that contain either media or metadata). Whereas a Wav file comprises a very short header succeeded by a plain linear list of media samples. These formats are NOT “very similar”. In the Flac design, the media frames may contain data that is compressed to a greater or lesser degree; and in the limit the media frame data is not compressed at all. The consequence of this is that an uncompressed Flac file is actually larger than a Wav file (due to its refined structure).

Anyone can implement or use Flac. It is an open standard. The published open source code allows the use of uncompressed Flac (either via an API, or command line switches).

As far a as a user is concerned, all Flac files will play and sound the same. The only difference is that on highly compressed Flac, your CPU will run hotter than on uncompressed Flac.

PS just so you know: Whitebear Media Server has also implemented transcoding to uncompressed Flac. One reason for so doing, is that (unlike compressed Flac) an uncompressed Flac file has a determinate file size (Content-Length) that depends ONLY on its duration, channel count, bit depth, and sample rate; i.e. independent of the complexity of the audio content.
Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3119
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #7 on: June 19, 2020, 03:33:15 pm »

I fully understand that flac in an open standard. As far as I know, dBpoweramp is the only software that allows a user to create and store a uncompressed flac file. Its good to know that your software uses the format.

I was not trying to say that a uncompressed flac file was exactly a wav file with a different header. I was speaking from a user perspective, rather than a programming perspective. This is why I included the imprecise term "basically". So, let me restate. 

From a compression standpoint, uncompressed flac has no compression, just like the data in a wav file has no compression. The audio data bits are the same in a uncompressed flac file as in a wav file.

From a user's perspective, an uncompressed flac file is basically a wav file with a flac header, although the internal formats of the files are different.

Is that better?
Logged

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #8 on: June 19, 2020, 03:53:12 pm »

No. Not at all.

The formats Wav, uncompressed Flac, AIFF, L16/24, uncompressed Wavpack, and probably some others, do indeed store their audio bits as — well— bits. But the bits are wrapped differently. They may be written in a different byte order (big/little endian). They may have different framing formats, different meta-data formats, headers, or whatever. They are quite quite different.

Your statement that “music files are music files” is nevertheless true. But that hardly contributes to our level of understanding.
Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3119
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #9 on: June 19, 2020, 04:08:17 pm »

My statements were meant for non-technical users in an attempt to explain the differences between uncompressed flac and  flac level 0, with an analogy to wav. 

So, please, how would you explain this to a quick phrase to a non-technical user?

By the way, I am a retired computer science professor and I do understand the technical differences in these internal file formats. I just do not think that the average person here is interested in the internal file structures.
Logged

EnglishTiger

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1084
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #10 on: June 20, 2020, 05:52:52 am »

Guys - what got me confused and the reason why I started this thread was something I'd found on the FLAQ FAQ page:-https://xiph.org/flac/faq.html

"What is the lowest bitrate (or highest compression) achievable with FLAC?

With FLAC you do not specify a bitrate like with some lossy codecs. It's more like specifying a quality with Vorbis or MPC, except with FLAC
the quality is always "lossless" and the resulting bitrate is roughly proportional to the amount of information in the original signal.
You cannot control the bitrate much and the result can be from around 100% of the input rate (if you are encoding noise), down to almost 0 (encoding silence)."

Since I was comparing the output from successive rips of the same cd where the only change was the "compression level" I could not work out how the compression level could affect the "original signal" - hence the confusion.

This morning I did a bit of investigation into why some of the tracks had a very significant difference in file size and, by implication, bitrate.
I loaded the album that was ripped with the Compression Level set to 0 into playing now, set them playing then opened the DSP Studio Analyzer which provided me with what I believe to be a significant clue. Out of the 20 tracks on the cd/album 14 of them were very obviously Stereo recordings, but the other 6 were "mirror stereo" (CD's equivalent of Mono) initially the orange (volume) and the yellow (right channel) wave were visible, but the blue (left channel wave) was not; but I then noticed that the right channel wave had a green tint to it.

When I checked the file sizes for the Stereo tracks the Compression Level 0 files were around 10% larger than their Compression Level 6 equivalent but for the Mirror Stereo/Mono tracks the Compression Level 0 files were around 50% larger than their Compression Level 6 equivalent.
Logged
Apple Mac Mini Desktop Computer with M4 Pro chip with 12 core CPU and 16 core GPU: 24GB Unified Memory, 512GB SSD Storage, Gigabit Ethernet, 3 Thunderbolt5 + 2USBC ports.

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3119
Re: Why does the Flac Compression Level affect the bitrate?
« Reply #11 on: June 20, 2020, 06:43:35 am »

Flac analyzes the correlation between the left and right channels and can do compression if there is correlation. In the case on mono/stereo the correlation is 100% and the flac compression recognizes that. This is part of the complicated structure that Andrew was discussing.  Flac looks for patterns and, in this case, those patterns do not have to be in the same channel.

I am not sure at what level interchannel correlation starts, but a simple experiment using levels starting at level 0 and working up should tell you.
Logged
Pages: [1]   Go Up