A friend handed me a 2 TB drive last month: 4,300 tracks, mostly FLAC, a few hundred ALAC, all ripped or downloaded over about eight years. He’d noticed that a handful of his “lossless” files sounded thin on his monitors but fine on his phone, and he wanted to know whether the rest of the drive was trustworthy. I don’t have golden ears and neither does he, so the only honest answer was to measure, not listen.
The plan was to look at the spectrum above 16 kHz. A genuine CD rip at 44.1 kHz can carry content up to 22.05 kHz; a 128 kbps MP3 re-encoded to FLAC almost always has a hard cliff at 16 kHz, and 320 kbps usually leaves a visible shelf around 20 kHz. I didn’t want to eyeball 4,300 spectrograms, so I used ffmpeg to dump a high-frequency energy profile per file and sorted by it.
#!/bin/bash
# hfscan.sh — print mean energy above 16 kHz, normalized
for f in "$@"; do
ffmpeg -nostdin -v error -i "$f" -af "highpass=f=16000,volumedetect" -f null - 2>&1 \
| awk -v file="$f" '/mean_volume/ {print file, $NF}'
done
That gives a rough dB figure relative to full scale. Anything below about -60 dB above 16 kHz on a track that clearly has cymbals or synths up there is worth a closer look. For the suspicious ones I generated a spectrum PNG with ffmpeg -i file.flac -lavfi showspectrumpic=s=1024x512 spec.png and looked for the cliff. About 380 files fell into the suspicious bucket; maybe 90 of those were legitimately dark recordings (old jazz, spoken word, a lot of lo-fi) and the rest were transcodes. The worst offenders were entire albums where one track was real and eleven were 128 kbps dressed up as FLAC.
The mechanism is boring and that’s the point: lossy encoders throw away high-frequency detail first, and re-encoding to a lossless container preserves the damage perfectly. FLAC’s -analysis flag or flac -t won’t catch this because the file is a valid FLAC — it’s just a FLAC of a lossy source. So bit-perfect verification only tells you the container is intact, not that the audio inside was ever lossless.
Where this falls apart: the 16 kHz cliff is a heuristic, not a verdict. Material with no real energy above 16 kHz (solo piano, a lot of acoustic folk, anything low-passed at mixdown) will look guilty and isn’t. Conversely, a 320 kbps transcode can pass a casual look because the shelf sits near 20 kHz. I also hit files that were upsampled from 32 kHz sources, which produce a cliff at 16 kHz that has nothing to do with MP3. And my script is slow — roughly 1.5 seconds per file on this machine — so a full pass took about two hours. I ran it overnight and it was fine, but don’t put it in a loop that touches a network drive.
What I’d do differently: keep a short allowlist of known-dark albums so I’m not re-flagging the same 90 files next time, and check duration metadata too, since a few of the fakes were also a second short from a bad rip.
If you’ve done this at scale: what threshold do you actually trust for the high-frequency shelf, and do you bother distinguishing a 320 kbps transcode from a genuine 44.1 kHz master, or just flag both?


0 条评论
还没有评论,写下第一条。