Is there a way to "objectively" determine the sound quality of an audio file? Eg. I sometimes come across mp3 files with a high bitrate, but they sound bad which suggest that they were re-encoded from a bad/low-bitrate source. By "objectively" I mean something else than listening to them, eg. an audio spectogram etc?
> I sometimes come across mp3 files with a high bitrate, but they sound bad which suggest that they were re-encoded from a bad/low-bitrate source.<p>You could try re-compressing the mp3 file to lower and lower bitrates and check the amplitude of differences. Since mp3 is a lossy codec, there will always be a slight difference, but you should see a sudden increase in difference when you surpass the "true" encoding bitrate.<p>You could probably write a script for it using ffmpeg and some other tools to generate a bitrate-difference chart.
A private music tracker called REDacted has a good overview [0] on this subject (link should be SFW, and is on a different domain than the tracker itself). What.CD, before its demise, was the first I had seen demonstrating this, but older trackers (OiNK, Waffles.fm, et al.) may have also had it.<p>Objectivity aside, IMO the easiest way to tell when listening is paying attention to high-frequency sounds, especially hi-hat cymbals. Unless lossy encoders have gotten remarkably better since I last tried, there’s always a marked loss of shimmer / reverb on those.<p>[0]: <a href="https://interviewfor.red/en/spectrals.html" rel="nofollow">https://interviewfor.red/en/spectrals.html</a>
<a href="https://en.wikipedia.org/wiki/Perceptual_Evaluation_of_Audio_Quality" rel="nofollow">https://en.wikipedia.org/wiki/Perceptual_Evaluation_of_Audio...</a><p>PEAQ is an algorithm and scoring system that takes psychoacoustic modeling into account. When I looked into this more than ten years ago, I managed to find a command line utility called pqevalaudio <i>or something</i> that I could just use to assign a score to a file.
Try Spek [0]<p>It's a popular tool for verifying the quality of music downloaded via P2P platforms. Re-encoding YouTube rips is popular - especially bootleg tracks - and this helps weed them out.<p>[0] <a href="http://help.spek.cc/" rel="nofollow">http://help.spek.cc/</a>
Most of the work on objective quality metrics (e.g. PESQ, POLQA, ViSQOL, DNS-MOS, NISQA) focus on speech because of telecommunications demands, but some of these have an audio mode. But there are some new promising audio ones that are ML based.<p>I haven't tried it but you may want to look into PAM, which is relatively new and doesn't require a reference (you don't need the original uncompressed audio), and is open source.<p>However, all approaches are quite far from perfect. Human evaluation is still the gold standard.
All the truly objective metrics will require a reference file to compare against. If you manage to find such a reference file, you've kinda solved your initial problem (which, presumably, was wanting to find the best quality file to listen to).
Objective metrics for audio quality estimation is a tool commonly used to develop audio products, from mobile phones to headphones, hearing aids and audio codecs.
I worked briefly in that area some years ago, and have put some notes together at:
<a href="https://github.com/jonnor/machinehearing/blob/master/audio-quality/README.md">https://github.com/jonnor/machinehearing/blob/master/audio-q...</a>
In your usecases you would want a metric that only needs the single audio clip, without an original/pristine reference. This is called a "reference-free" / "non-intrusive" / "single-ended" metric.<p>Detecting re-encoding or double encoding is sometimes researched, though mostly for audio forensic purposes.<p>Conceptually it would be possible to use the encoding with different codecs and nitrates/settings on a sizable corpus of music, to learn a ML model that can learn to identify the "true" bitrate on new unseen audio clips.
<a href="https://friture.org/" rel="nofollow">https://friture.org/</a><p>spectral analyzer. not sure if you need cli or batch function, but the frequency will be cut off regardless of the purported bitrate even if it was "upscaled" since those frequencies were chopped previously. you can see a sample screenshot in the upper left showing the frequency. re-encode a 320kbps to 128kbps and you can see the frequency range diminished on the 128kbps.
I found a tool named [Lossless Audio Checker](<a href="https://losslessaudiochecker.com" rel="nofollow">https://losslessaudiochecker.com</a>) : "A utility to check whether a WAVE or FLAC file is truly lossless or not".<p>I was so sad that this project is not open-source but their Research papers give some interesting clues about detecting bad quality files.<p>On my side, I used it through a [Bash script](<a href="https://gist.github.com/madeindjs/d5e3949313b141f2e5eea62b982c2a02" rel="nofollow">https://gist.github.com/madeindjs/d5e3949313b141f2e5eea62b98...</a>) to detect bad files in my library. The tool produces a lot of false positives since it triggered on some High Res audio musics I bought on Qobuz.
Not my area, but:<p>You could use image processing/DSP methods on a sample of spectrogram images taken from the file<p>Visibly it’s obvious when it’s compressed, you get “glitchy” or “smeary” <i>repeated</i> artefacts<p>I’d also look for cuts on the high end (over ~15k hz) that clip more than normal (compared to uncompressed)
<a href="https://andrewrondeau.com/blog/2016/07/deconstructing-lossy-audio-the-case-for-lossless" rel="nofollow">https://andrewrondeau.com/blog/2016/07/deconstructing-lossy-...</a><p>Years ago, I did a study. I wrote a program to compare the original to the encoded version of a file. I used high-resolution DVD-A rips, to try to avoid artifacts introduced by downsampling the master to CD resolution.<p>The source code that I used for the above article is at: <a href="https://github.com/GWBasic/MeasureDegredation">https://github.com/GWBasic/MeasureDegredation</a>
I asked almost this exact question on Super User (part of the Stack Exchange network) a few years ago. Some of the answers are still relevant:<p><pre><code> How to objectively compare the sound quality of two files? </code></pre>
<a href="https://superuser.com/questions/693238/how-to-objectively-compare-the-sound-quality-of-two-files" rel="nofollow">https://superuser.com/questions/693238/how-to-objectively-co...</a>
Worth keeping in mind that this varies wildly per domain, and there are many different measures for different types of problems.<p>SNR is a classic, and simple enough to give you an intuitive sense for the underlying signal processing.<p><a href="https://essentia.upf.edu/reference/std_SNR.html" rel="nofollow">https://essentia.upf.edu/reference/std_SNR.html</a>
Not an answer, just got me thinking about my _subjective_ measures of “bad music quality”. It’s not as trivial as “there is clipping”, because some elements clip on purpose, but if a vocal part clips it’s an instant turn off for me, it sounds horrible. That’s not a data issue though, it’s a production issue… unless the data is exceptionally bad.
A track which uses low-bitrate mp3 compression as an effect, specifically to get the ringing artifacts on some of the instruments, would make a fun benchmark for any quality detection method.
What an awsome thread and answers, i have no personal interest on the subject but i had to read all the answers and even try a script a guy did here!!!