Try something like the following to see if wasted bits is equal to or greater than 8 for each FLAC sub-frames.
Thanks! I used your idea to make a BASH script that prints out the average number of effective bits of FLAC files.
fbits:
#!/bin/bash
me="${0##*/}"
if [ -w "$TMPDIR" ]; then
tdir="$TMPDIR"
elif [ -w '/tmp' ]; then
tdir='/tmp'
elif [ -w "$HOME" ]; then
tdir="$HOME"
elif [ -w "$PWD" ]; then
tdir="$PWD"
else
echo "$me: error: can't find a writable directory for creating the temporary file" 1>&2 ; exit 1
fi
tf="$( TMPDIR="$tdir" mktemp "${tdir}/${me}.XXXX" 2>/dev/null )"
if [ -z "$tf" ]; then
echo "$me: error: can't create temporary file" 1>&2 ; exit 1
fi
checkbits ()
{
local bps abps tbps=0 n=0
bps="$( metaflac --show-bps "$1" )"
flac -ac "$1" 2>/dev/null | fgrep 'wasted_bits' | cut -d '=' -f 3 | cut -f 1 > "$tf"
while read wb; do
tbps=$(( tbps + ( bps - wb ) ))
((n++))
done < "$tf"
abps=$(( ( ( tbps * 10 / n) + 5 ) / 10 )) # (* 10 + 5) / 10 for proper rounding
printf "%2u/%2u bits\t%s\n" "$abps" "$bps" "$1"
}
for f in "$@"; do
case "$f" in
*.flac) checkbits "$f" ;;
*) continue ;;
esac
done
rm -f "$tf"
Usage:
fbits *.flac
Output with a lossyFLAC album (Daft Punk - Homework):
12/16 bits 01. Daftendirekt.lossy.flac
11/16 bits 02. WDPK 83.7 FM.lossy.flac
11/16 bits 03. Revolution 909.lossy.flac
10/16 bits 04. Da Funk.lossy.flac
11/16 bits 05. Phœnix.lossy.flac
10/16 bits 06. Fresh.lossy.flac
11/16 bits 07. Around the World.lossy.flac
10/16 bits 08. Rollin' & Scratchin'.lossy.flac
11/16 bits 09. Teachers.lossy.flac
10/16 bits 10. High Fidelity.lossy.flac
10/16 bits 11. Rock'n Roll.lossy.flac
12/16 bits 12. Oh Yeah.lossy.flac
11/16 bits 13. Burnin'.lossy.flac
10/16 bits 14. Indo Silver Club.lossy.flac
10/16 bits 15. Alive.lossy.flac
11/16 bits 16. Funk Ad.lossy.flac
Output with a "true" 24 bit album (The Beatles - Love):
23/24 bits 01. Because.flac
22/24 bits 02. Get Back.flac
22/24 bits 03. Glass Onion.flac
23/24 bits 04. Eleanor Rigby ∕ Julia (transition).flac
22/24 bits 05. I Am the Walrus.flac
21/24 bits 06. I Want to Hold Your Hand.flac
22/24 bits 07. Drive My Car ∕ The World ∕ What You're Doing.flac
23/24 bits 08. Gnik Nus.flac
22/24 bits 09. Something ∕ Blue Jay Way (transition).flac
22/24 bits 10. Being for the Benefit of Mr. Kite ∕ I Want You (She's So Heavy) ∕ Helter Skelter.flac
21/24 bits 11. Help.flac
22/24 bits 12. Blackbird ∕ Yesterday.flac
22/24 bits 13. Strawberry Fields Forever.flac
22/24 bits 14. Within You Without You ∕ Tomorrow Never Knows.flac
22/24 bits 15. Lucy in the Sky With Diamonds.flac
22/24 bits 16. Octopus's Garden.flac
22/24 bits 17. Lady Madonna.flac
22/24 bits 18. Here Comes the Sun ∕ The Inner Light (transition).flac
22/24 bits 19. Come Together ∕ Dear Prudence ∕ Cry Baby Cry (transition).flac
22/24 bits 20. Revolution.flac
22/24 bits 21. Back in the U.S.S.R..flac
23/24 bits 22. While My Guitar Gently Weeps.flac
22/24 bits 23. A Day in the Life.flac
22/24 bits 24. Hey Jude.flac
22/24 bits 25. Sgt. Pepper's Lonely Hearts Club Band (reprise).flac
22/24 bits 26. All You Need Is Love.flac
Output with a 16 bit album, upsampled to 24 bits (Daft Punk - Homework):
16/24 bits 01. Daftendirekt.flac
16/24 bits 02. WDPK 83.7 FM.flac
16/24 bits 03. Revolution 909.flac
16/24 bits 04. Da Funk.flac
16/24 bits 05. Phœnix.flac
16/24 bits 06. Fresh.flac
16/24 bits 07. Around the World.flac
16/24 bits 08. Rollin' & Scratchin'.flac
16/24 bits 09. Teachers.flac
16/24 bits 10. High Fidelity.flac
16/24 bits 11. Rock'n Roll.flac
16/24 bits 12. Oh Yeah.flac
16/24 bits 13. Burnin'.flac
16/24 bits 14. Indo Silver Club.flac
16/24 bits 15. Alive.flac
16/24 bits 16. Funk Ad.flac