music-audit: fpcalc fallback shim and notes on getting fingerprints on EL9

AlmaLinux 9 packages libchromaprint but no fpcalc CLI, so beets chroma and
pyacoustid had nothing to call. The shim in this folder produces the same
fingerprint via ffmpeg's chromaprint muxer; on the same file it is byte-identical
to the official 1.5.1 static build, which also installs cleanly from the
acoustid/chromaprint GitHub release.
This commit is contained in:
ziadarafat committed 2026-11-25 20:07:02 -07:00
1 parent 40edcf1f29
commit ff82addb46
2 files changed
+90

No files matched your search

+17
View File
@@ -15,3 +15,20 @@ tags, genre sprawl, unreadable files and junk-file counts.
`report-2026-11-25.json` is the baseline taken before any clean-up; rerun after the
fix and compare the same keys.
## fpcalc (acoustid fingerprints)
AlmaLinux 9 ships `libchromaprint` but **no `fpcalc` binary** — `dnf provides */fpcalc`
is empty because `chromaprint-tools` exists in Fedora and not in EL9 base, EPEL or CRB.
Two ways to get one, both verified on yveltal:
1. Official static build (preferred): download
`chromaprint-fpcalc-1.5.1-linux-x86_64.tar.gz` from the acoustid/chromaprint
GitHub releases and install it as `/usr/local/bin/fpcalc`.
2. The `fpcalc` shim in this folder, which derives the same fingerprint through
ffmpeg's chromaprint muxer (`ffmpeg -f chromaprint -fp_format base64`). On the
same file its output is byte-identical to the official 1.5.1 binary, so it is a
valid fallback (`/usr/local/bin/fpcalc-ffmpeg` on yveltal).
AcoustID *lookups* additionally need a free AcoustID application API key; computing
and comparing fingerprints locally does not.
+73
View File
@@ -0,0 +1,73 @@
#!/usr/bin/env python3
"""fpcalc-compatible fingerprint tool built on ffmpeg's chromaprint muxer.
AlmaLinux 9 ships libchromaprint but no fpcalc binary (the chromaprint-tools
package is not in base, EPEL or CRB). ffmpeg can emit the very same fingerprint
through its chromaprint muxer, so this shim gives every consumer of fpcalc
(beets chroma, pyacoustid, any script) a working implementation.
Supported arguments mirror the ones tools actually pass:
fpcalc [-json] [-length SECONDS] FILE
"""
import json
import subprocess
import sys
def main(argv):
path = None
length = None
as_json = False
args = argv[1:]
i = 0
while i < len(args):
a = args[i]
if a in ("-json", "-json=1"):
as_json = True
elif a in ("-length", "-l"):
i += 1
length = args[i] if i < len(args) else None
elif a in ("-raw", "-plain", "-text"):
as_json = False
elif a.startswith("-"):
pass
else:
path = a
i += 1
if not path:
sys.stderr.write("fpcalc: no input file\n")
return 2
cmd = ["ffmpeg", "-v", "quiet", "-nostdin", "-i", path]
if length and length.isdigit() and int(length) > 0:
cmd += ["-t", length]
cmd += ["-f", "chromaprint", "-fp_format", "base64", "-"]
proc = subprocess.run(cmd, capture_output=True, text=True)
fingerprint = proc.stdout.strip()
dur = subprocess.run(
["ffprobe", "-v", "quiet", "-show_entries", "format=duration",
"-of", "default=nw=1:nk=1", path],
capture_output=True, text=True).stdout.strip()
try:
duration = int(float(dur))
except (TypeError, ValueError):
duration = 0
if fingerprint:
if as_json:
print(json.dumps({"duration": duration, "fingerprint": fingerprint}))
else:
print("DURATION=%d" % duration)
print("FINGERPRINT=%s" % fingerprint)
return 0
sys.stderr.write("fpcalc: could not fingerprint %s: %s\n" % (path, proc.stderr.strip()[:200]))
return 1
if __name__ == "__main__":
sys.exit(main(sys.argv))